Retry
Review retry settings and why invalid model IDs cannot reliably exercise the retry path.
The source imports SiliconFlow, but the current exported class is Siliconflow. That import fails before a request. This example also assumes an invalid model ID triggers the configured retries. Invalid-model responses commonly use terminal 400 or 404 statuses, which Agno does not retry. Do not run this source as a retry test.
"""Example demonstrating how to set up retries with SiliconFlow."""
from agno.agent import Agent
from agno.models.siliconflow import SiliconFlow
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# We will use a deliberately wrong model ID, to trigger retries.
wrong_model_id = "siliconflow-wrong-id"
agent = Agent(
model=SiliconFlow(
id=wrong_model_id,
retries=3, # Number of times to retry the request.
delay_between_retries=1, # Delay between retries in seconds.
exponential_backoff=True, # If True, the delay between retries is doubled each time.
),
)
agent.print_response("What is the capital of France?")
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
passCurrent Alternative
Complete the basic example's setup, including its credentials and model selection. Replace your_enabled_siliconflow_model_id with the enabled model chosen in that setup. Save this program as siliconflow_retry.py and run python siliconflow_retry.py.
The current class is Siliconflow. SDK retries are disabled so Agno's attempts are not multiplied. Terminal 400/404 errors are not retried. A successful call does not exercise retries; test using a controlled transient 429, connection failure, or 5xx response.
from agno.agent import Agent
from agno.models.siliconflow import Siliconflow
agent = Agent(
model=Siliconflow(
id="your_enabled_siliconflow_model_id",
base_url="https://api.siliconflow.com/v1",
client_params={"max_retries": 0},
retries=3,
delay_between_retries=1,
exponential_backoff=True,
)
)
agent.print_response("What is the capital of France?")Full source: cookbook/90_models/siliconflow/retry.py