fix(agent): jittered backoff for empty-response retries (#35296 salvage) - #77608
Merged
kshitijk4poor merged 2 commits intoAug 3, 2026
Merged
Conversation
Empty content retries previously fired back-to-back with no delay, wasting up to 3 rapid API calls, and could not be cancelled mid-wait. Apply the same jittered_backoff() already used for rate-limit and API-error retries, sleeping in small increments so a user interrupt aborts the wait instead of blocking until it elapses. Fixes NousResearch#35230
The retry loop gates on real time.time() < sleep_end; with sleep mocked to a no-op the test hot-spun 7.5 wall-clock seconds. Advance a fake clock by each sleep amount instead (pattern precedent: test_session_activity_persist.py).
kshitijk4poor
enabled auto-merge (rebase)
August 3, 2026 11:40
10 tasks
This was referenced Aug 3, 2026
Open
|
Code Review: #77608 Verdict: Approve Delegate per-call model tests: comprehensive tests for model resolution. LGTM - Reviewed diff. Changes are sound. |
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.
Salvage of #35296 by @arimu1 — commit cherry-picked to preserve authorship, plus one test-only follow-up commit.
Context — what this changes for users
Empty-response retries slept a fixed pattern; under repeated empty responses from a struggling endpoint, all Hermes instances retried in sync. arimu1 routes the wait through the existing shared jittered_backoff util (agent/retry_utils.py, already used at 2 other retry sites — good reuse), capped at 60s, with the interrupt path preserved (0.2s increments, activity touch every 30s, established interrupt pattern).
Review follow-up folded (test-only; production code untouched)
test_empty_response_retry_backoff_status busy-spun 7.5 WALL-CLOCK seconds: it mocked time.sleep to a no-op while the loop gates on real time.time() < sleep_end. Folded a fake clock advanced by each sleep amount (pattern precedent: test_session_activity_persist.py). Suite time for the empty-response tests: 7.5s+ -> ~1s.
Verification
Closes #35296.