Skip to content

fix(agent): resolve NameError in rate-limit fallback decision#27359

Closed
0xchainer wants to merge 5 commits into
NousResearch:mainfrom
0xchainer:fix/conversation-loop-undefined-pool-may-recover
Closed

fix(agent): resolve NameError in rate-limit fallback decision#27359
0xchainer wants to merge 5 commits into
NousResearch:mainfrom
0xchainer:fix/conversation-loop-undefined-pool-may-recover

Conversation

@0xchainer

Copy link
Copy Markdown
Contributor

What does this PR do?

_pool_may_recover_from_rate_limit() is defined in run_agent.py but conversation_loop.py's run_conversation() called it as a bare name without importing it. After the run_agent.py refactor that extracted conversation_loop.py, this dependency was missed, causing a NameError at runtime when a rate-limited API call triggered the fallback logic.

Fixed by routing through _ra() (the existing lazy-reference pattern used throughout conversation_loop.py for run_agent symbols), which resolves the function at call time via a deferred import.

Fixes a regression introduced during the run_agent.py extraction.

Related Issue

This is a regression from the recent run_agent.py refactor that extracted conversation_loop.py as a standalone module. Previously both the caller and callee lived in the same file, so no import was needed.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/conversation_loop.py:2254 — prefixed _pool_may_recover_from_rate_limit() call with _ra(). to resolve the function via the existing lazy-import pattern

How to Test

  1. Set up a credential pool with a single key
  2. Trigger a 429 rate-limit from the provider
  3. Without the fix: NameError: name '_pool_may_recover_from_rate_limit' is not defined
  4. With the fix: agent correctly detects single-credential pool and falls back to the configured fallback_model

Checklist

Code

Documentation & Housekeeping

  • N/A — one-line bug fix, no docs needed

Screenshots / Logs

N/A — runtime NameError, no visual change.

@cardtest15-coder

This comment was marked as spam.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder P1 High — major feature broken, no workaround labels May 17, 2026
@0xchainer 0xchainer force-pushed the fix/conversation-loop-undefined-pool-may-recover branch 2 times, most recently from d931e82 to e2de05f Compare May 17, 2026 12:27
0xchainer added 4 commits May 17, 2026 16:01
test_startup_plugin_gating::test_builtin_set_covers_every_registered_subcommand checks that _BUILTIN_SUBCOMMANDS includes every live subcommand. The 'send' subcommand was recently added but not included in the set, causing a CI failure.
_pool_may_recover_from_rate_limit() is defined in run_agent.py
but conversation_loop.py's run_conversation() called it as a bare
name without importing it. After the run_agent.py refactor that
extracted conversation_loop.py, this dependency was missed, causing
a NameError at runtime when a rate-limited API call triggered the
fallback logic.

Fixed by routing through _ra() (the existing lazy-reference pattern
used throughout conversation_loop.py for run_agent symbols), which
resolves the function at call time via a deferred import.

Fixes a regression introduced during the run_agent.py extraction.
@JeremyDev87

Copy link
Copy Markdown

ddalggak review — CHANGES_REQUESTED / superseded conclusion.

Blocking first: this duplicates the same agent/conversation_loop.py one-line fix already present in #27374, but carries unrelated scope and failing checks.

Evidence checked:

Requested path:

@christianmahardhika

Copy link
Copy Markdown

when this PR ready to production or available next update patch?

@0xchainer 0xchainer closed this May 18, 2026
@0xchainer 0xchainer deleted the fix/conversation-loop-undefined-pool-may-recover branch May 18, 2026 09:10
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 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.

5 participants