fix(agent): preemptively pace low RPM buckets - #78612
Open
konsisumer wants to merge 1 commit into
Open
konsisumer wants to merge 1 commit into
konsisumer wants to merge 1 commit into
Conversation
Contributor
Author
|
Rebased onto current Focused regressions: 16 passed. Ruff, Windows-footgun scan, bytecode compilation, and |
konsisumer
force-pushed
the
fix/preemptive-rpm-throttling-followup
branch
from
August 13, 2026 07:27
b135b22 to
14e4ee6
Compare
This branch has not been deployed
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 changed and why
Per the follow-up on #7489, this is a clean, smaller successor to Refs #7490. It captures rate-limit headers for non-streaming OpenAI-compatible calls, parses OpenAI compact durations and Anthropic RFC 3339 reset values, then delays the next request when a matching request bucket has at most two requests remaining.
The captured state is in-memory and is accepted only when both the active provider and normalized base URL still match, so a provider or route switch cannot inherit an unrelated bucket. OpenRouter is intentionally not enabled by default because successful routed responses do not reliably provide the necessary headers. A custom provider may opt in with
rpm_throttle_thresholdon its configured route.Scope justification: the 5-file / 347-line diff is limited to the existing rate-limit state model (parsing plus a pure, interruptible wait), the two existing API entry paths (non-streaming capture and preflight), the one capture call that records route identity, custom-provider normalization/lookup, and focused regressions. It adds no new manager, provider integration, dependency, or configuration migration.
How to test
pytest -q --timeout=60 tests/agent/test_rate_limit_tracker.py tests/agent/test_cron_inline_api_call_62151.py tests/run_agent/test_anthropic_response_header_capture.py(16 passed)ruff check agent/rate_limit_tracker.py agent/chat_completion_helpers.py run_agent.py hermes_cli/config.py tests/agent/test_rate_limit_tracker.pypython -m py_compile agent/rate_limit_tracker.py agent/chat_completion_helpers.py run_agent.py hermes_cli/config.py tests/agent/test_rate_limit_tracker.pyThe requested full suite was attempted, but collection is blocked in this worktree because FastAPI is absent and its automatic install is rejected by the externally managed Homebrew Python.
What platforms tested on
Related reference
Refs #7489