feat(retries): configurable max_api_retries + max_stream_retries with smarter backoff#5571
Open
iRonin wants to merge 3 commits into
Open
feat(retries): configurable max_api_retries + max_stream_retries with smarter backoff#5571iRonin wants to merge 3 commits into
iRonin wants to merge 3 commits into
Conversation
2 tasks
iRonin
added a commit
to iRonin/hermes-agent-nous
that referenced
this pull request
Apr 10, 2026
iRonin
added a commit
to iRonin/hermes-agent-nous
that referenced
this pull request
Apr 10, 2026
787c43f to
3871bf1
Compare
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
8b905cb to
cae15cf
Compare
iRonin
added a commit
to iRonin/hermes-agent-nous
that referenced
this pull request
Apr 12, 2026
Collaborator
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.
Two-Layer API Retry Strategy
Makes both the outer API retry loop and the inner stream retry loop configurable.
Configuration
```yaml
~/.hermes/config.yaml
agent:
max_api_retries: 10 # Outer loop: full API call retries (provider errors, rate limits, invalid responses)
max_stream_retries: 10 # Inner loop: transient stream/connection retries (ReadTimeout, dropped connections)
```
Retry behavior
Outer loop (
max_api_retries, default 3):Retry-Afterheader from API response (capped at 5 min)Inner loop (
max_stream_retries, default 2):HERMES_STREAM_RETRIESenv var onlyHow it works
The two layers work together -- stream retries happen first for transient connection issues. If those exhaust, the outer loop catches the error and retries the entire API call (with backoff).
Files changed