Delegate To All Members
Broadcast the same research task to every member with TeamMode.broadcast, fanning it out to Reddit and HackerNews researchers.
Demonstrates collaborative team execution with delegate-to-all behavior.
"""
Delegate To All Members
=============================
Demonstrates collaborative team execution with delegate-to-all behavior.
"""
import asyncio
from textwrap import dedent
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.team import Team, TeamMode
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
reddit_researcher = Agent(
name="Reddit Researcher",
role="Research a topic on Reddit",
model=OpenAIResponses(id="gpt-5-mini"),
tools=[WebSearchTools()],
add_name_to_context=True,
instructions=dedent("""
You are a Reddit researcher.
You will be given a topic to research on Reddit.
You will need to find the most relevant posts on Reddit.
"""),
)
hackernews_researcher = Agent(
name="HackerNews Researcher",
model=OpenAIResponses(id="gpt-5-mini"),
role="Research a topic on HackerNews.",
tools=[HackerNewsTools()],
add_name_to_context=True,
instructions=dedent("""
You are a HackerNews researcher.
You will be given a topic to research on HackerNews.
You will need to find the most relevant posts on HackerNews.
"""),
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
agent_team = Team(
name="Discussion Team",
model=OpenAIResponses(id="gpt-5-mini"),
members=[
reddit_researcher,
hackernews_researcher,
],
instructions=[
"You are a discussion master.",
"You have to stop the discussion when you think the team has reached a consensus.",
],
markdown=True,
mode=TeamMode.broadcast,
show_members_responses=True,
)
async def run_async_collaboration() -> None:
await agent_team.aprint_response(
input="Start the discussion on the topic: 'What is the best way to learn to code?'",
stream=True,
)
# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync ---
agent_team.print_response(
input="Start the discussion on the topic: 'What is the best way to learn to code?'",
stream=True,
)
# --- Async ---
asyncio.run(run_async_collaboration())In broadcast mode, one delegate_task_to_members tool call sends the same task to every member. The leader decides when to call it and may answer directly. Sync member execution is sequential; the async path can run members concurrently.
This file runs both the sync and async demonstrations, making two separate research runs. The Reddit researcher uses web search, while HackerNewsTools reads HackerNews stories; neither the role text nor the consensus instruction guarantees a particular retrieval result or agreement.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ddgs openaiExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as delegate_to_all_members.py, then run:
python delegate_to_all_members.pyFull source: cookbook/03_teams/01_quickstart/03_delegate_to_all_members.py