Understanding communication flows in Agency Swarm.
SendMessage
mechanism. This is fundamentally different from sequential handoffs:
output_type
, and control always returns to the Portfolio Manager who compiles the final recommendation.
agency_chart
. So, in the example below, the CEO can initiate communication and send tasks to the Developer and the Virtual Assistant, and it can respond back to him in the same thread, but the Developer or the VA cannot initiate a conversation and assign tasks to the CEO.
agency_chart
(ceo, dev
), can talk to the user.
To allow Developer to initiate communication with the CEO, you need to simply add it to the agency_chart
list:
SendMessage
to allow agents to communicate with each other. By adding agents to the second-level list, it simply adds a new recipient to the SendMessage
function. If you’d like to modify the behavior of this tool, you can do so by creating your own Custom Communication Flows (Advanced).
It’s important to understand that each defined communication flow (e.g., [ceo, dev]
) establishes a distinct context for interaction. When the SendMessage
tool is invoked by a sender agent (e.g., CEO) to a recipient agent (e.g., Developer), this happens within a dedicated conversation thread specific to that CEO-Developer pair. In this thread, the sender agent effectively takes on the role of a “user,” and the recipient agent responds as the “assistant.” This ensures that the history and context of communication between any two agents are isolated and maintained separately for each specific flow.
"user->AgentName"
for user interactions and "SenderAgent->RecipientAgent"
for agent-to-agent communication. This is implemented through:src/agency_swarm/thread.py
) - Manages multiple conversation threadssrc/agency_swarm/thread.py
) - Stores individual thread historysrc/agency_swarm/tools/send_message.py
) - Handles agent-to-agent communicationsrc/agency_swarm/agent.py
) - Processes messages and manages thread retrieval