Documentation Index
Fetch the complete documentation index at: https://agency-swarm.ai/llms.txt
Use this file to discover all available pages before exploring further.
In the following sections, we’ll look at some common use cases for creating custom communication flows and how to implement them in Agency Swarm.
1. Adjusting Parameters and Descriptions
Customize parameters by subclassing SendMessage and declaring extra fields directly on the class:
from pydantic import Field
from agency_swarm import SendMessage
class SendMessageTask(SendMessage):
"""Use this tool to send tasks to other agents within your agency."""
tool_name = "send_message_task" # optional, defaults to "send_message"
task: str = Field(
description=(
"Specify the task required for the recipient agent to complete. Focus on "
"clarifying what the task entails rather than providing exact instructions."
)
)
2. Adding Additional Fields
You can add extra fields to capture more context, like key moments and decisions:
from pydantic import Field
from agency_swarm import SendMessage
class SendMessageWithContext(SendMessage):
"""SendMessage with key moments and decisions tracking."""
tool_name = "send_message_with_context"
key_moments: str = Field(
description=(
"Document critical moments and decision points from the current conversation "
"that the recipient agent needs to understand. Include context about what "
"has been decided or prioritized that will guide the recipient's tool selection "
"and task execution. For example: 'User decided to prioritize performance over cost', "
"'Analysis focus shifted to Q4 optimization', etc."
)
)
decisions: str = Field(
description=(
"Summarize the specific decisions made that will directly impact which tools "
"or approaches the recipient agent should use. Be explicit about choices that "
"narrow down the scope of work. For example: 'Prioritized performance analysis "
"over cost reduction', 'Selected React over Vue for frontend', etc. This helps "
"the recipient agent choose the most appropriate tools and approach."
)
)
Usage:
from agency_swarm import Agency, Agent
agent = Agent(
name="MyAgent",
instructions="You are a helpful assistant.",
)
other_agent = Agent(name="OtherAgent", instructions="Provide supporting context.")
agency = Agency(
agent,
other_agent,
communication_flows=[(agent > other_agent, SendMessageWithContext)],
)
If you have any ideas for new communication flows, please either adjust this page in docs, or add your new send
message tool in the agency_swarm/tools/send_message folder and open a PR!