Delegation

Control how the team leader delegates tasks to members.

When you call run() on a team, the leader decides how to handle the request: respond directly, use tools, or delegate to members.

Team delegation flow

The default flow:

  1. Team receives user input
  2. Leader analyzes the input and decides which members to delegate to
  3. Leader formulates a task for each selected member
  4. Members execute and return results. Multiple async member calls can run concurrently.
  5. Leader synthesizes results into a final response

Modes define whether the leader delegates, routes to one member, broadcasts to all members, or runs a task loop. Modes are explicit orchestration patterns you can swap without changing member logic. Members can also be provided by callable factories and resolved at run time. See Callable Factories.

You can customize this flow with team modes:

ModeConfigurationBehavior
Coordinate (default)mode=TeamMode.coordinate (or omit mode)Leader selects members, formulates tasks, synthesizes results
Routemode=TeamMode.routeWhen delegating, the leader routes to one member and returns that response directly
Broadcastmode=TeamMode.broadcastWhen delegating, the leader sends the same task to every member
Tasksmode=TeamMode.tasksLeader builds and executes a shared task list until the goal is complete

Use TeamMode from agno.team.mode to set the mode explicitly. The leader can still answer directly or use its own tools. The legacy flags still work, but mode is the recommended approach.

Member selection and run tracking use member IDs. Set explicit id values on members for stable delegation identity.

Setup

Create and activate a Python virtual environment. The examples use OpenAI; the broadcast example also imports the arXiv and DuckDuckGo tool dependencies:

uv pip install -U agno openai yfinance arxiv pypdf ddgs
export OPENAI_API_KEY="your-openai-api-key"

On Windows PowerShell, use $env:OPENAI_API_KEY = "your-openai-api-key". Save and run each complete example separately. Fragments containing members=[...] require your own configured members.

Coordinate Mode (Default)

The leader selects members, writes their tasks, and combines their outputs.

from agno.team import Team
from agno.agent import Agent
from agno.team.mode import TeamMode
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools

team = Team(
    name="Research Team",
    model=OpenAIResponses(id="gpt-5.4-mini"),
    members=[
        Agent(name="News Agent", role="Get tech news", tools=[HackerNewsTools()]),
        Agent(name="Finance Agent", role="Get stock data", tools=[YFinanceTools()])
    ],
    mode=TeamMode.coordinate,
    instructions="Research the topic thoroughly, then synthesize findings into a clear report."
)

team.print_response("What's happening with AI companies and their stock prices?")

Use this when:

  • Tasks need decomposition into subtasks
  • You want quality control over the final output
  • The leader should add context or reasoning to member outputs

Route Mode

The leader selects which member handles the request and returns the member's response directly. By default the leader can still craft the task; set determine_input_for_members=False to pass the user input through unchanged.

Route mode flow
from agno.team import Team
from agno.agent import Agent
from agno.team.mode import TeamMode
from agno.models.openai import OpenAIResponses

team = Team(
    name="Language Router",
    model=OpenAIResponses(id="gpt-5.4-mini"),
    members=[
        Agent(name="English Agent", role="Answer questions in English"),
        Agent(name="Japanese Agent", role="Answer questions in Japanese"),
    ],
    mode=TeamMode.route,
    determine_input_for_members=False # Pass user input unchanged to member
)

team.print_response("How are you?")        # Routes to English Agent
team.print_response("お元気ですか?")        # Routes to Japanese Agent

Use this when:

  • You have specialized agents and want automatic routing
  • The member should receive the request unchanged
  • You want lower latency (no synthesis step)

Legacy Configuration Flags

These flags still work, but are overridden by mode when set.

respond_directly=True: Return member responses without leader synthesis (maps to TeamMode.route).

Direct response flow

determine_input_for_members=False: Send the user-message content to members instead of having the leader formulate a task. This applies to coordinate, route, and broadcast delegation.

Raw input flow

Combine both for a full passthrough:

team = Team(
    members=[...],
    respond_directly=True,
    determine_input_for_members=False,
)

Broadcast Mode

The leader delegates the same task to all members. Synchronous runs execute members sequentially. Asynchronous runs execute them concurrently.

Broadcast mode flow
import asyncio
from agno.team import Team
from agno.agent import Agent
from agno.team.mode import TeamMode
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
from agno.tools.arxiv import ArxivTools
from agno.tools.duckduckgo import DuckDuckGoTools

team = Team(
    name="Research Team",
    model=OpenAIResponses(id="gpt-5.4-mini"),
    members=[
        Agent(name="HackerNews Researcher", role="Find discussions on HackerNews", tools=[HackerNewsTools()]),
        Agent(name="Academic Researcher", role="Find academic papers", tools=[ArxivTools()]),
        Agent(name="Web Researcher", role="Search the web", tools=[DuckDuckGoTools()]),
    ],
    mode=TeamMode.broadcast,
    instructions="Synthesize findings from all researchers into a comprehensive report."
)

# Use async for concurrent execution
asyncio.run(team.aprint_response("Research the current state of AI agents"))

Use this when:

  • You want multiple perspectives on the same topic
  • Members can work independently
  • You can use arun() for concurrent member execution

If both delegate_to_all_members=True and respond_directly=True are set and mode is not set, initialization logs a warning, disables respond_directly, and sets team.mode to TeamMode.broadcast. Set mode explicitly instead of combining these flags.

Tasks Mode

Tasks mode is an autonomous loop where the leader decomposes the goal into tasks, executes them, and marks the goal complete. The run stops if it reaches max_iterations first.

from agno.team import Team
from agno.agent import Agent
from agno.team.mode import TeamMode
from agno.models.openai import OpenAIResponses

team = Team(
    name="Ops Team",
    model=OpenAIResponses(id="gpt-5.4-mini"),
    members=[
        Agent(name="Research Agent", role="Collect findings"),
        Agent(name="Writer Agent", role="Draft the final report"),
    ],
    mode=TeamMode.tasks,
    max_iterations=6
)

team.print_response("Compile a short report on recent AI agent frameworks.")

Structured Input

When using determine_input_for_members=False, a Pydantic input is serialized to JSON in the user-message content sent to members:

from pydantic import BaseModel, Field
from agno.team import Team
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools

class ResearchRequest(BaseModel):
    topic: str
    num_sources: int = Field(default=5)

research_agent = Agent(
    name="Research Agent",
    role="Research topics on HackerNews",
    tools=[HackerNewsTools()]
)

team = Team(
    name="Research Team",
    model=OpenAIResponses(id="gpt-5.4-mini"),
    members=[research_agent],
    determine_input_for_members=False  # Pass serialized user-message content to the member
)

request = ResearchRequest(topic="AI Agents", num_sources=10)
team.print_response(input=request)

Production Considerations

Model Calls

ModeDelegated run pattern
CoordinateLeader selection, one or more member runs, then leader synthesis
RouteLeader selection and one member run. The member response is returned directly
BroadcastLeader delegation, every member run, then leader synthesis
TasksRepeated leader and member calls until completion or max_iterations

Latency

  • Coordinate: Selection and synthesis add leader model calls. Multiple async delegations can overlap.
  • Route: Skips leader synthesis after a member is selected.
  • Broadcast: Sync runs members sequentially. Async runs members concurrently before synthesis.
  • Tasks: Runs multiple cycles until tasks are complete or max_iterations is reached.

Error Handling

Member and team retries are configured separately. Inspect TeamToolCallError, TeamRunError, member events, and member responses instead of assuming a partial result is complete. Test failure behavior for the selected mode and sync or async path.

Developer Resources