Skip to content

fix(conversation_loop): use _ra() prefix for _pool_may_recover_from_r… - #27896

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

fix(conversation_loop): use _ra() prefix for _pool_may_recover_from_r…#27896
0xchainer wants to merge 1 commit 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 as a module-level function in run_agent.py but was called as a bare name in agent/conversation_loop.py after the conversation loop was extracted into its own module. When a rate-limit or billing error occurs and the agent has a fallback provider configured, Python raises a NameError at runtime because the name isn't defined or imported in that module.

The fix prefixes the call with _ra(). — the same pattern already used throughout the file for _set_interrupt, handle_function_call, and AIAgent._get_tool_call_name_static. _ra() is a lazy module reference to run_agent, so existing patches in tests keep working without changes.

Related Issue

No issue filed. Discovered during static analysis after the conversation-loop extraction refactor.

Fixes # N/A

Type of Change

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

Changes Made

  • agent/conversation_loop.py:2320 — changed _pool_may_recover_from_rate_limit(...) to _ra()._pool_may_recover_from_rate_limit(...)

How to Test

  1. Configure a fallback model (fallback_model in config.yaml)
  2. Trigger a 429 (rate-limit) response from the primary provider
  3. Before fix: NameError: name '_pool_may_recover_from_rate_limit' is not defined
  4. After fix: agent correctly evaluates credential-pool rotation and falls back to the backup provider

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(conversation_loop):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (single-line bug fix)
  • I've updated cli-config.yaml.example — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md — N/A
  • I've considered cross-platform impact — N/A (Python name resolution is platform-agnostic)
  • I've updated tool descriptions/schemas — N/A

…ate_limit

_pool_may_recover_from_rate_limit is defined in run_agent.py but
was called as a bare name in conversation_loop.py, causing a
NameError at runtime when a rate-limit/billing error occurs and
a fallback provider is available.

Fixes the refactoring gap introduced when the conversation loop
was extracted from run_agent.py into its own module.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #27359 (fix PR) / #27370 (bug report) — identical one-line _ra() prefix fix for NameError on _pool_may_recover_from_rate_limit() at conversation_loop.py:2254. Many duplicate fix PRs already exist for this bug.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint 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.

2 participants