Retries
Demonstrates team retry configuration for transient run errors.
"""
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,
)Retry scope
retries=3 permits the initial attempt plus three retries, with delays of 1, 2, and 4 seconds for this configuration. The sample does not inject a failure; a successful run will not demonstrate the retry path. Team retries apply to the leader's run loop. Members have their own retry settings, and cancellation and guardrail failures take separate terminal paths.
With no explicit model, the team selects OpenAIResponses(id="gpt-5.4"); members without a model inherit it. Set the team's model explicitly if you want a different model.
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 retries.py, then run:
python retries.pyFull source: cookbook/03_teams/14_run_control/retries.py