Skip to main content

Module retry

Module retry 

Source
Expand description

Retry middleware for per-backend request retries with exponential backoff.

Uses tower-resilience’s RetryLayer with a response-based predicate to retry MCP error responses with transient error codes (internal errors, timeouts). Tool-not-found and other client errors are not retried.

§Retry Budget

When budget_percent is configured, a token bucket budget limits retries. The budget is sized as a percentage of expected request volume, preventing retry storms during widespread backend failures. A min_retries_per_sec floor ensures low-traffic backends can still retry.

§Configuration

[[backends]]
name = "flaky-api"
transport = "http"
url = "http://localhost:8080"

[backends.retry]
max_retries = 3
initial_backoff_ms = 100
max_backoff_ms = 5000
budget_percent = 20.0    # max 20% of requests can be retries
min_retries_per_sec = 10 # floor for low-traffic backends

Functions§

build_retry_layer
Build a tower-resilience RetryLayer from our RetryConfig.