Skip to content

fix(agent): wire _pool_may_recover_from_rate_limit through _ra() in extracted conversation_loop#28304

Closed
soynchux wants to merge 1 commit into
NousResearch:mainfrom
soynchux:fix/conversation-loop-pool-rotation-nameerror
Closed

fix(agent): wire _pool_may_recover_from_rate_limit through _ra() in extracted conversation_loop#28304
soynchux wants to merge 1 commit into
NousResearch:mainfrom
soynchux:fix/conversation-loop-pool-rotation-nameerror

Conversation

@soynchux

Copy link
Copy Markdown
Contributor

What

Fixes a NameError regression in agent/conversation_loop.py:2335. The extracted run_conversation calls _pool_may_recover_from_rate_limit as a bare name, but the helper lives in run_agent.py and was never imported. Any rate-limited (429/billing) turn with a configured fallback_model chain crashes.

Introduced by commit 053025238 (refactor(run_agent): extract run_conversation to agent/conversation_loop.py).

Fix

Route the call through the existing _ra() lazy reference (same pattern as _ra()._set_interrupt, _ra().handle_function_call). A top-level from run_agent import ... would create a circular import.

Test

tests/run_agent/test_provider_fallback.py — new TestRateLimitFallbackWiringFromConversationLoop class:

  • Without the fix: fails with NameError at the exact buggy line.
  • With the fix: 24/24 pass.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround duplicate This issue or pull request already exists comp/agent Core agent loop, run_agent.py, prompt builder labels May 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #27359 (fix PR) / #27370 (bug report). This is the 18th+ duplicate fix PR for the NameError on bare _pool_may_recover_from_rate_limit() call in conversation_loop.py after the run_agent.py extraction refactor. Same _ra() prefix fix.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as fixed-on-main

Thanks for the patch — appreciated! Closing as redundant: the same one-line _ra()._pool_may_recover_from_rate_limit(...) wrap landed via PR #28345 (salvage of @AceWattGit's PR #28159), merged 2026-05-19, before this PR could be reviewed. Same code change, just a different cherry-pick.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants