Amindadgar PR#8486 retry ci fix#13519
Open
amindadgar wants to merge 4 commits into
Open
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
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.
What does this PR do?
Finishes the retry/backoff work intended for PR #8486 by wiring configurable retry settings all the way from config into
AIAgent, and by fixing the actual retry behavior inrun_agent.py.This change adds:
agent.max_api_retriesfor full API-call retriesagent.max_stream_retriesfor transient streaming reconnect retriesIt also fixes the outer retry loop so it no longer uses a hardcoded retry count, honors
Retry-Afterheaders, applies smarter rate-limit vs generic retry backoff, and keeps streaming reconnect recovery separate from full-request retries. This approach stays small and idiomatic by extending the existing retry paths instead of introducing a new abstraction.Related Issue
Fixes #5570
Type of Change
Changes Made
agent.max_api_retriesandagent.max_stream_retriesdefaults and normalization inhermes_cli/config.pycli.pygateway/run.pyAIAgentretry config handling and retry behavior inrun_agent.pyRetry-Afterhandling and smarter backoff logic for rate limits vs other retryable errorstests/test_api_retry_config.pytests/hermes_cli/test_config.pytests/cli/test_cli_init.pytests/run_agent/test_run_agent.pycli-config.yaml.exampledocs/acp-setup.mdHow to Test
~/.hermes/config.yaml, for example:HERMES_HOME=/tmp/hermes-ci-home python -m pytest \ tests/run_agent/test_run_agent.py \ tests/run_agent/test_provider_fallback.py \ tests/run_agent/test_streaming.py \ tests/run_agent/test_openai_client_lifecycle.py \ tests/test_api_retry_config.py \ tests/hermes_cli/test_config.py \ tests/cli/test_cli_init.py \ -q -o addopts=''max_api_retriesmax_stream_retriesRetry-Afteris honored and cappedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Focused verification passed locally:
Command used:
HERMES_HOME=/tmp/hermes-ci-home python -m pytest \ tests/run_agent/test_run_agent.py \ tests/run_agent/test_provider_fallback.py \ tests/run_agent/test_streaming.py \ tests/run_agent/test_openai_client_lifecycle.py \ tests/test_api_retry_config.py \ tests/hermes_cli/test_config.py \ tests/cli/test_cli_init.py \ -q -o addopts=''