fix(agent): share fallback pool recovery helper#27734
Closed
qWaitCrypto wants to merge 1 commit into
Closed
Conversation
Collaborator
This was referenced May 19, 2026
Collaborator
Closing as fixed-on-mainThanks for the patch — appreciated! Closing as redundant: the same one-line Several contributors converged on the same fix here (#27370, #27465, #27468, #27583, #27686, #27732, #27734, #27735, #27750, #27891, #27903, #28304) — your diagnosis was correct in every case. Sorry for the duplicate-work cleanup; the volume of independent reports made it hard to coordinate. |
This was referenced May 19, 2026
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?
This PR fixes a post-refactor fallback crash in the extracted agent conversation
loop.
agent/conversation_loop.pynow owns the mainrun_conversation()body, but therate-limit fallback path still referenced
_pool_may_recover_from_rate_limit()as if it were local to that module. The helper was still defined in
run_agent.py, so quota/rate-limit fallback could raiseNameErrorbefore theconfigured fallback provider was attempted.
The fix moves the helper into a small shared module and imports it from the
conversation loop.
run_agent._pool_may_recover_from_rate_limitremains as acompatibility alias for existing tests and external patch/import sites.
Related Issue
Related to #27719 and #27370.
Type of Change
Changes Made
agent/fallback_utils.pywithpool_may_recover_from_rate_limit().agent/conversation_loop.pyto import and call the shared helperdirectly in the rate-limit fallback path.
run_agent._pool_may_recover_from_rate_limitas a compatibility alias.conversation loop imports the shared helper and the old
run_agentaliasstill points to the same function.
How to Test
Run the focused fallback tests:
pytest -q tests/agent/test_gemini_fast_fallback.py tests/run_agent/test_provider_fallback.py -k "pool or cloudcode or fallback"Run ruff on the touched files:
Local results:
Checklist
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