from textwrap import dedent
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.reasoning import ReasoningTools
web_agent = Agent(
name="Web Search Agent",
role="Handle web search requests",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[DuckDuckGoTools()],
instructions="Always include sources",
add_datetime_to_instructions=True,
)
research_agent = Agent(
name="Research Agent",
role="Handle research and news requests",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[
DuckDuckGoTools(search=True, news=True)
],
instructions=[
"You are a research specialist. Provide comprehensive and accurate information.",
"Use tables to display research findings and data comparisons.",
"Clearly state sources and provide relevant context.",
"Summarize recent news and developments if available.",
"Focus on delivering the requested research data points clearly.",
],
add_datetime_to_instructions=True,
)
team_leader = Team(
name="Reasoning Research Team Leader",
mode="coordinate",
model=Claude(id="claude-3-7-sonnet-latest"),
members=[
web_agent,
research_agent,
],
tools=[ReasoningTools(add_instructions=True)],
instructions=[
"Only output the final answer, no other text.",
"Use tables to display data",
],
markdown=True,
show_members_responses=True,
enable_agentic_context=True,
add_datetime_to_instructions=True,
success_criteria="The team has successfully completed the task.",
)
def run_team(task: str):
team_leader.print_response(
task,
stream=True,
stream_intermediate_steps=True,
show_full_reasoning=True,
)
if __name__ == "__main__":
run_team(
dedent("""\
Analyze the impact of recent global technology policy changes on development across these key sectors:
- Artificial Intelligence & Machine Learning
- Semiconductor Industry
- Renewable Energy Technology
- Electric Vehicle Technology
- Telecommunications Infrastructure
For each sector:
1. Compare development trends before and after policy changes
2. Identify innovation disruptions and investment impact
3. Analyze companies' strategic responses (R&D investments, partnerships, market positioning)
4. Assess expert outlook changes directly attributed to policy shifts
""")
)
Create a virtual environment
Terminal
and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Set your API key
export OPENAI_API_KEY=xxx
export ANTHROPIC_API_KEY=xxx
Install libraries
pip install -U openai anthropic agno
Run Example
python cookbook/reasoning/teams/reasoning_research_team.py
Was this page helpful?