feat: configurable max API retries + stream retries with smarter backoff#8486
Open
iRonin wants to merge 3 commits into
Open
feat: configurable max API retries + stream retries with smarter backoff#8486iRonin wants to merge 3 commits into
iRonin wants to merge 3 commits into
Conversation
agent.max_api_retries in config.yaml (default 3, user set to 10).
Backoff improvements:
- Respects Retry-After header from API response (capped at 5 min)
- Rate limits: exponential 5s*2^n with ±20% jitter, cap 5 min
- Other errors: exponential 2^n, cap 60s
- Was: fixed min(2**n, 60) for all cases, ignored Retry-After
Usage:
agent:
max_api_retries: 10 # in ~/.hermes/config.yaml
…ection errors
agent.max_stream_retries in config.yaml (default 2, means 3 attempts).
Controls inner stream retry loop for ReadTimeout/connection drops.
Works alongside max_api_retries (outer loop) for two-layer retry strategy.
Usage:
agent:
max_api_retries: 10 # outer: full API call retries
max_stream_retries: 5 # inner: stream/connection retries
|
I'm willing to work on this but first wanted to know if anyone worked on a PR like this before? |
Contributor
Author
|
@amindadgar I am a little bit busy this week but will try my best to help |
|
Let me see if I can fix the CI errors we're facing here :) |
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Configurable Two-Layer Retry Strategy
Configuration
Retry behavior
max_api_retries, default 3): Respects Retry-After header, rate-limit backoff 5s * 2^n with jitter (cap 5 min), other errors 2^n (cap 60s)max_stream_retries, default 2): Retries streaming requests on ReadTimeout/connection drops, rebuilds primary client to purge dead connectionsCloses #5570