sdk-python
sdk-python copied to clipboard
[FEATURE] Configurable retry strategies with exception filtering
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:
- Exception allowlist/denylist for retriable errors
- Custom retry predicates (e.g., should_retry(exception) -> bool)
- Per-tool or per-model retry configuration
- Configurable backoff strategies
Use Case
In production workloads:
- Retry on transient network errors (ConnectionError, Timeout)
- Do not retry on authentication failures (403, 401)
- Do not retry on validation errors (400)
- 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
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 🤔