Retry

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

An invalid model ID cannot demonstrate successful recovery. The current WatsonX adapter wraps SDK failures without preserving HTTP status codes, so Agno's terminal 400/404 filter cannot distinguish those failures here. Configured retries can repeat them.

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

from agno.agent import Agent
from agno.models.ibm import WatsonX

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

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

agent = Agent(
    model=WatsonX(
        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

Configure your project, regional URL and key as shown in the basic example, then use a valid model:

from agno.agent import Agent
from agno.models.ibm import WatsonX

agent = Agent(
    model=WatsonX(
        id="mistralai/mistral-small-3-1-24b-instruct-2503",
        retries=2,
        delay_between_retries=1,
        exponential_backoff=True,
    )
)
agent.print_response("What is the capital of France?")

Test recovery with a controlled transient failure. Agno retry settings are separate from any IBM SDK retry policy. The SDK can also reject unavailable model IDs during client setup, before an inference request.

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