Skip to content

Python: [Bug]: Duplicate messages in Handoff workflow #4695

@cecheta

Description

@cecheta

Description

I ran the handoff_simple.py sample, but noticed that there were duplicate messages being sent within each agent's chat history.

Code Sample

I ran handoff_simple.py, however I used AzureOpenAIChatClient so I could clearly see the full list of messages sent to each agent.

Here is the full list of messages saved for the refund agent:

{"type": "message", "role": "user", "contents": [{"type": "text", "text": "Hello, I need assistance with my recent purchase.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "I'd be happy to help you with your recent purchase. Could you please tell me more about the issue you're experiencing? For example, are you looking to track your order, request a return, or inquire about a refund? This will help me connect you with the right specialist.", "additional_properties": {}}], "author_name": "triage_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "My order 1234 arrived damaged and the packaging was destroyed. I'd like to return it.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "I'm sorry your order arrived damaged. I've initiated a return for order 1234. You will receive detailed return instructions via email soon. \n\nIf you need further assistance with your refund or have additional questions, please let me know!", "additional_properties": {}}], "author_name": "return_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "Please also process a refund for order 1234.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "function_call", "call_id": "call_xBL1WNsjs2cshZzhgb4LBxIq", "name": "process_refund", "arguments": "{\"order_number\":\"1234\"}", "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "tool", "contents": [{"type": "function_result", "call_id": "call_xBL1WNsjs2cshZzhgb4LBxIq", "result": "Refund processed successfully for order 1234.", "items": [{"type": "text", "text": "Refund processed successfully for order 1234.", "additional_properties": {}}], "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "Your refund for order 1234 has been processed successfully. You should see the refunded amount on your original payment method soon.\n\nIf you have any more questions or need further assistance, feel free to ask!", "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "Hello, I need assistance with my recent purchase.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "I'd be happy to help you with your recent purchase. Could you please tell me more about the issue you're experiencing? For example, are you looking to track your order, request a return, or inquire about a refund? This will help me connect you with the right specialist.", "additional_properties": {}}], "author_name": "triage_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "My order 1234 arrived damaged and the packaging was destroyed. I'd like to return it.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "I'm sorry your order arrived damaged. I've initiated a return for order 1234. You will receive detailed return instructions via email soon. \n\nIf you need further assistance with your refund or have additional questions, please let me know!", "additional_properties": {}}], "author_name": "return_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "Please also process a refund for order 1234.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "function_call", "call_id": "call_xBL1WNsjs2cshZzhgb4LBxIq", "name": "process_refund", "arguments": "{\"order_number\":\"1234\"}", "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "tool", "contents": [{"type": "function_result", "call_id": "call_xBL1WNsjs2cshZzhgb4LBxIq", "result": "Refund processed successfully for order 1234.", "items": [{"type": "text", "text": "Refund processed successfully for order 1234.", "additional_properties": {}}], "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "Your refund for order 1234 has been processed successfully. You should see the refunded amount on your original payment method soon.\n\nIf you have any more questions or need further assistance, feel free to ask!", "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}
{"type": "message", "role": "user", "contents": [{"type": "text", "text": "Thanks for resolving this.", "additional_properties": {}}], "additional_properties": {}}
{"type": "message", "role": "assistant", "contents": [{"type": "text", "text": "You\u2019re very welcome! If you have any more questions or need help in the future, feel free to reach out. Have a great day!", "additional_properties": {}}], "author_name": "refund_agent", "additional_properties": {}}

It shows that messages are duplicated.

Package Versions

agent-framework-core: 1.0.0rc4

Python Version

3.13.11

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions