Skip to main content
ExecutionConfig retry settings re-run retryable tool failures and guardrail validation errors with exponential backoff and jitter.

Quick Start

from praisonaiagents import Agent

agent = Agent(
    name="Resilient Agent",
    instructions="Fetch data from flaky APIs",
    tools=[my_flaky_tool],
    max_retry_limit=3,  # Retries with backoff are automatic
)
agent.start("Get me the latest report")
Fine-tune backoff via ExecutionConfig:
from praisonaiagents import Agent, ExecutionConfig

agent = Agent(
    name="Resilient Agent",
    instructions="Fetch data from flaky APIs",
    tools=[my_flaky_tool],
    execution=ExecutionConfig(
        max_retry_limit=3,
        retry_initial_delay=0.5,
        retry_backoff_factor=2.0,
        retry_jitter=0.2,
    ),
)

How It Works

Total attempts = 1 + max_retry_limit. Default max_retry_limit=2 → up to 3 attempts. Delay: min(initial_delay × factor^(attempt−1), 60s) + random(0, jitter × base).

Choosing Your Settings


Configuration

FieldTypeDefaultDescription
max_retry_limitint2Max retries after the first attempt
retry_initial_delayfloat1.0First retry delay (seconds)
retry_backoff_factorfloat2.0Exponential multiplier per attempt
retry_jitterfloat0.1Jitter fraction of base delay
For per-tool RetryPolicy overrides, see Tool Retry Policy.

What Gets Retried

OutcomeRetried?
Tool timeouts
Circuit breaker open
Unexpected exceptions (not ValueError / TypeError / AttributeError)
Guardrail validation failures
Tool returns {"error": ...} without timeout / circuit_open
Programming errors (ValueError, TypeError, AttributeError)

Common Patterns

Disable retries:
agent = Agent(name="strict", max_retry_limit=0)
Rate-limited APIs:
execution=ExecutionConfig(
    max_retry_limit=4,
    retry_initial_delay=2.0,
    retry_backoff_factor=3.0,
    retry_jitter=0.3,
)
Low-latency tools:
execution=ExecutionConfig(
    max_retry_limit=2,
    retry_initial_delay=0.1,
    retry_backoff_factor=1.5,
)

Best Practices

Jitter spreads retry timing across agents and reduces thundering-herd spikes on shared APIs.
ValueError, TypeError, and AttributeError are treated as code bugs and are not retried.
Very large backoff factors cannot exceed a 60-second base delay per attempt.
Guardrail validation retries use the same ExecutionConfig backoff values.

ExecutionConfig

Full execution configuration reference

Guardrails

Input and output validation

Loop Guardrails

Cap tool calls per turn

Structured LLM Errors

LLM-level retry and error handling