sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[FEATURE] Configurable retry strategies with exception filtering

Open nagabharann opened this issue 10 months ago • 1 comments

Problem Statement

Current retry behavior treats all failures as retriable. There is no ability to define specific exceptions or criteria for when to retry versus when to fail immediately. This leads to wasted retries on non-recoverable errors and delayed failure reporting.

Proposed Solution

Provide configurable retry strategies:

  1. Exception allowlist/denylist for retriable errors
  2. Custom retry predicates (e.g., should_retry(exception) -> bool)
  3. Per-tool or per-model retry configuration
  4. Configurable backoff strategies

Use Case

In production workloads:

  1. Retry on transient network errors (ConnectionError, Timeout)
  2. Do not retry on authentication failures (403, 401)
  3. Do not retry on validation errors (400)
  4. Custom retry logic for domain-specific exceptions

Alternatives Solutions

We implement retry logic in our hooks, but native support would be cleaner and more consistent.

Additional Context

No response

nagabharann avatar Jan 29 '26 20:01 nagabharann

I think this issue can be closed by #3340? The use cases are covered by the new option of subclassing and overriding is_retryable. Other customization aspects might need their own specific issue 🤔

crazybolillo avatar Jul 21 '26 20:07 crazybolillo