retries.py
"""
Retries
=============================
Demonstrates team retry configuration for transient run errors.
"""
from agno.agent import Agent
from agno.team import Team
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
sarah = Agent(
name="Sarah",
role="Data Researcher",
tools=[WebSearchTools()],
instructions="Focus on gathering and analyzing data",
)
mike = Agent(
name="Mike",
role="Technical Writer",
instructions="Create clear, concise summaries",
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
members=[sarah, mike],
retries=3,
delay_between_retries=1,
exponential_backoff=True,
)
# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
team.print_response(
"Search for latest news about the latest AI models",
stream=True,
)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U agno ddgs openai
3
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run the example
Save the code above as
retries.py, then run:python retries.py