Retry

Review retry settings and why invalid model IDs cannot reliably exercise the retry path.

The preserved source imports CohereChat, which is no longer exported. Use Cohere in new code. The current adapter also omits HTTP status codes when wrapping SDK errors, so Agno's retry filter cannot distinguish terminal 400/404 responses on this path. An invalid model ID is unsuitable for testing recovery.

retry.py
"""Example demonstrating how to set up retries with Cohere."""

from agno.agent import Agent
from agno.models.cohere import CohereChat

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# We will use a deliberately wrong model ID, to trigger retries.
wrong_model_id = "cohere-wrong-id"

agent = Agent(
    model=CohereChat(
        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__":
    pass

Current Alternative

Use the current class and a valid model:

from agno.agent import Agent
from agno.models.cohere import Cohere

agent = Agent(
    model=Cohere(
        id="command-a-03-2025",
        retries=2,
        delay_between_retries=1,
        exponential_backoff=True,
    )
)
agent.print_response("What is the capital of France?")

Install agno cohere and export CO_API_KEY as shown in the basic example. These settings control Agno retries in addition to any SDK retry policy. Exercise recovery with a controlled transient failure and a valid model ID. With the current adapter, configuring retries can also repeat terminal failures.

Full source: cookbook/90_models/cohere/retry.py