How to Implement Multi-Agent Coordination Using Team in Agno
The Team class in Agno enables multi-agent coordination through four distinct execution modes—coordinate, route, broadcast, and tasks—allowing a leader agent to orchestrate member agents via synchronous run() or asynchronous arun() methods.
The Agno framework (agno-agi/agno) provides a robust architecture for building collaborative AI systems. When you implement multi-agent coordination using Team in Agno, you leverage a leader-delegation pattern where the Team class manages member agents through configurable execution strategies defined in TeamMode.
Architecture and Execution Modes
The coordination system centers on the Team class defined in libs/agno/agno/team/team.py, which encapsulates members, configuration settings, and execution methods including run(), arun(), and continue_run(). The actual dispatch logic resides in libs/agno/agno/team/_run.py, while member initialization is handled by libs/agno/agno/team/_init.py.
Core Components
| Component | Role | Source Path |
|---|---|---|
| Team | Stores members, settings, and provides public API methods | libs/agno/agno/team/team.py |
| TeamMode | Defines four execution patterns altering coordination strategy | libs/agno/agno/team/mode.py |
| _run module | Implements dispatchers for run, arun, and continuation flows |
libs/agno/agno/team/_run.py |
| _init module | Handles member initialization and default model selection | libs/agno/agno/team/_init.py |
| _response module | Assembles model responses and formats TeamRunOutput |
libs/agno/agno/team/_response.py |
TeamMode Execution Patterns
The TeamMode enum determines how the leader processes inputs across members:
- coordinate (default): The leader selects a subset of members, crafts task-specific prompts, and synthesizes member replies into a coherent response. Use this for general problem-solving requiring multiple perspectives.
- route: The leader delegates the entire input to a single specialist member and returns that member's raw output. Ideal for delegating to agents with exclusive expertise, such as calculators or code executors.
- broadcast: The leader sends identical inputs to all members concurrently, then aggregates results. Suitable for ensemble voting or parallel opinion gathering.
- tasks: The leader decomposes high-level goals into a shared task list, assigns tasks to members, and iterates until completion. Designed for complex, multi-step workflows requiring autonomous task management.
Step-by-Step Implementation
Basic Setup
First, import the required classes and instantiate individual agents to serve as team members:
from agno.team import Team, TeamMode
from agno.agent import Agent
# Create specialized members
reasoner = Agent(name="reasoner", model="gpt-4o-mini")
calculator = Agent(name="calculator", model="gpt-4o-mini")
Instantiate the Team with your desired coordination mode:
team = Team(
members=[reasoner, calculator],
mode=TeamMode.coordinate,
name="MathSolver",
description="Coordinates reasoning and calculation agents to solve math problems.",
system_message="You are a team leader that delegates to specialized agents.",
)
Running the Team
Execute the team synchronously or asynchronously. The run() method in libs/agno/agno/team/team.py delegates to the internal _run module based on your selected mode:
# Synchronous execution
response = team.run(
"What is the sum of the first 100 prime numbers?",
stream=False,
)
# Asynchronous execution with streaming
# response = await team.arun("What is the factorial of 12?", stream=True)
The method returns a TeamRunOutput object containing output, metadata, messages, and optional session_state.
Human-in-the-Loop with continue_run
For interactive workflows, use continue_run() to resume execution with additional requirements:
follow_up = team.continue_run(
run_response=response,
requirements=["clarify the definition of prime numbers"],
)
This method, implemented in the _run module, maintains conversation context while incorporating new constraints.
Console Output Helpers
The _cli module provides convenience methods for formatted console output:
team.print_response(
"What is the sum of the first 100 prime numbers?",
stream=False,
markdown=True,
)
Advanced Configuration
Configure sophisticated behaviors through the Team constructor:
| Feature | Parameter | Implementation Details |
|---|---|---|
| Custom system message | system_message="..." |
Defines leader behavior in libs/agno/agno/team/_init.py |
| Tool exposure | tools=[search_tool] |
Makes functions callable from the leader model |
| Session persistence | session_id="my-session" |
Maintains memory across runs via cache_session=True |
| Knowledge retrieval | knowledge=my_knowledge |
Enables search_knowledge=True for RAG capabilities |
| Streaming events | stream=True, stream_events=True |
Returns incremental updates during execution |
| Telemetry control | telemetry=False |
Disables analytics logging in the _run dispatchers |
Complete Working Example
This example demonstrates coordinate mode with reasoning and calculation agents:
from agno.agent import Agent
from agno.team import Team, TeamMode
# 1. Create specialized agents
reasoner = Agent(
name="Reasoner",
model="gpt-4o-mini",
description="Performs logical reasoning and explanation.",
)
calculator = Agent(
name="Calculator",
model="gpt-4o-mini",
description="Handles numeric calculations precisely.",
)
# 2. Build the coordinating team
solver = Team(
members=[reasoner, calculator],
mode=TeamMode.coordinate,
name="MathReasoner",
description="Combines reasoning with calculation to answer math questions.",
system_message="You are a team leader that delegates to a Reasoner and a Calculator.",
cache_session=True,
)
# 3. Execute the query
question = "What is the factorial of 12 plus the 7th Fibonacci number?"
result = solver.run(
question,
stream=False,
markdown=True,
)
print("\n--- Final Team Output ---")
print(result.output)
Execution flow:
- Initialization:
_init._initialize_memberconfigures both agents - Coordination: The leader prompts the Reasoner to formulate a plan, then queries the Calculator for numeric results
- Synthesis: Responses are merged via logic in
libs/agno/agno/team/_response.pyinto the finalTeamRunOutput
Summary
- The Team class in
libs/agno/agno/team/team.pyprovides the primary interface for multi-agent coordination with support for nested teams. - Four TeamMode options—coordinate, route, broadcast, and tasks—determine delegation strategies.
- The
_runmodule handles synchronousrun()and asynchronousarun()execution flows, while_initmanages member setup. - continue_run() enables human-in-the-loop interactions by resuming execution with new requirements.
- Responses return as TeamRunOutput objects containing structured output, metadata, and message history.
Frequently Asked Questions
What is the difference between coordinate and route modes in Agno Teams?
Coordinate mode allows the leader to select multiple members, delegate specific subtasks, and synthesize their responses into a unified answer. Route mode delegates the entire input to a single specialist member and returns that member's raw output without synthesis. Use route when you have a clear specialist for the task, and coordinate when the problem requires combining multiple perspectives.
How do I enable streaming responses when implementing multi-agent coordination?
Pass stream=True to the run() or arun() methods. For granular event streaming, combine with stream_events=True to receive incremental updates as the team leader delegates to members and processes responses. This is handled by the dispatch logic in libs/agno/agno/team/_run.py.
Can I nest Teams within other Teams for hierarchical coordination?
Yes, the Team class accepts both Agent instances and other Team instances in its members parameter. This allows you to create hierarchical structures where higher-level teams delegate to sub-teams, each potentially operating in different modes (e.g., a coordinating team containing a broadcast sub-team).
How does session persistence work in Agno Teams?
Set cache_session=True during Team instantiation and provide a consistent session_id parameter when calling run(). The _init module handles session state management, allowing the team to maintain context, memory, and conversation history across multiple execution calls.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →