Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
With
-c N, each trial retries a rate-limited provider on its own schedule. When one trial gets a 429/529 withretry-after, the other N−1 keep sending into the same exhausted limit, each burning retries from the ~10-minute budget, and a heavy run can turn one limit into a storm.Miniswen::SharedBackoffis a Faraday middleware installed next to the adapter on every ruby_llm connection, in the same way as the existing transport tweaks. It keeps one resume time per host, shared by the trials' threads:retry-after(seconds or HTTP date) pauses that host for the given time;anthropic-ratelimit-*-remainingis0pauses until the matching*-reset, so the next call waits instead of drawing a 429;retry_max_interval, and other hosts are unaffected.Waiting happens before the request, inside the existing retry loop. Retry counts and intervals are unchanged; only the timing of calls to an already rate-limited host changes. As with retries today, the wait counts toward the trial's wall-clock limit.
We use the same idea, across processes, for a 4- to 6-trial-concurrent run against the direct Anthropic, OpenAI and Gemini APIs.
Tests:
test/miniswen/shared_backoff_test.rb(3 runs).bundle exec rake testpasses (348 runs, 0 failures) andbundle exec rubocopis clean.