Team History
Demonstrates sharing team history with member agents across a session.
"""
Team History
=============================
Demonstrates sharing team history with member agents across a session.
"""
from uuid import uuid4
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
german_agent = Agent(
name="German Agent",
role="You answer German questions.",
model=OpenAIResponses(id="gpt-5-mini"),
)
spanish_agent = Agent(
name="Spanish Agent",
role="You answer Spanish questions.",
model=OpenAIResponses(id="gpt-5-mini"),
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
multi_lingual_q_and_a_team = Team(
name="Multi Lingual Q and A Team",
model=OpenAIResponses(id="gpt-5-mini"),
members=[german_agent, spanish_agent],
instructions=[
"You are a multi lingual Q and A team that can answer questions in English and Spanish. You MUST delegate the task to the appropriate member based on the language of the question.",
"If the question is in German, delegate to the German agent. If the question is in Spanish, delegate to the Spanish agent.",
"Always translate the response from the appropriate language to English and show both the original and translated responses.",
],
db=SqliteDb(
db_file="tmp/multi_lingual_q_and_a_team.db"
), # Add a database to store the conversation history. This is a requirement for history to work correctly.
respond_directly=True,
determine_input_for_members=False, # Send input directly to members.
add_team_history_to_members=True, # Send all interactions between the user and the team to the member agents.
)
# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
session_id = f"conversation_{uuid4()}"
# First give information to the team
# Ask question in German
multi_lingual_q_and_a_team.print_response(
"Hallo, wie heißt du? Meine Name ist John.",
stream=True,
session_id=session_id,
)
# Then watch them recall the information (the question below states:
# "Tell me a 2-sentence story using my name")
# Follow up in Spanish
multi_lingual_q_and_a_team.print_response(
"Cuéntame una historia de 2 oraciones usando mi nombre real.",
stream=True,
session_id=session_id,
)The members are German and Spanish agents. Correct the first team instruction from “English and Spanish” to “German and Spanish” when copying this example. The generated session ID is shared within this script invocation; retain it explicitly if you want to resume the same conversation later.
respond_directly=True selects route mode, so a delegated answer bypasses a final leader response. The leader's translation instruction therefore does not add an English translation after the member answers. Put that instruction on each member, or use coordinate mode if you want the leader to translate the result.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai sqlalchemyExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as team_history.py, then run:
python team_history.pyFull source: cookbook/03_teams/01_quickstart/05_team_history.py