Direct Response with Team History

Give the team leader history for delegation while returning a member response directly.

The team leader routes each request to the appropriate member, and that member responds directly to the user.

add_history_to_context=True gives the leader prior turns so it can include relevant details in delegated tasks. To send the prior team transcript to members, also set add_team_history_to_members=True as shown in Team History. The tools below return demonstration data; they do not fetch live weather or news.

respond_directly_with_history.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.team.team import Team


def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."


weather_agent = Agent(
    name="Weather Agent",
    role="You are a weather agent that can answer questions about the weather.",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_weather],
)


def get_news(topic: str) -> str:
    return f"The news about {topic} is that it is going well!"


news_agent = Agent(
    name="News Agent",
    role="You are a news agent that can answer questions about the news.",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_news],
)


def get_activities(city: str) -> str:
    return f"The activities in {city} are that it is going well!"


activities_agent = Agent(
    name="Activities Agent",
    role="You are a activities agent that can answer questions about the activities.",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_activities],
)


geo_search_team = Team(
    name="Geo Search Team",
    model=OpenAIResponses(id="gpt-5.2"),
    respond_directly=True,
    members=[
        weather_agent,
        news_agent,
        activities_agent,
    ],
    instructions="You are a geo search agent that can answer questions about the weather, news and activities in a city.",
    db=SqliteDb(
        db_file="tmp/geo_search_team.db"
    ),  # Add a database to store the conversation history
    add_history_to_context=True,  # Ensure that the team leader knows about previous requests
)


geo_search_team.print_response(
    "I am doing research on Tokyo. What is the weather like there?", stream=True
)

geo_search_team.print_response(
    "Is there any current news about that city?", stream=True
)

geo_search_team.print_response("What are the activities in that city?", stream=True)

Usage

Create a Python file

Create respond_directly_with_history.py with the code above.

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai sqlalchemy

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run Team

python respond_directly_with_history.py