Skip to content

fix(agent): add missing _ra() prefix to pool recovery call#27750

Closed
ruangraung wants to merge 1 commit into
NousResearch:mainfrom
ruangraung:fix/rate-limit-pool-nameerror
Closed

fix(agent): add missing _ra() prefix to pool recovery call#27750
ruangraung wants to merge 1 commit into
NousResearch:mainfrom
ruangraung:fix/rate-limit-pool-nameerror

Conversation

@ruangraung

@ruangraung ruangraung commented May 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The function _pool_may_recover_from_rate_limit is defined in run_agent.py as a method on the AIAgent class — accessed through the _ra() instance helper. But conversation_loop.py:2254 calls it without the _ra(). prefix, which triggers a NameError any time a provider throws a rate-limit / insufficient-quota error:

Sorry, I encountered an error (NameError). name '_pool_may_recover_from_rate_limit' is not defined Try again or use /reset to start a fresh session.

This crashes the fallback-ladder recovery path. The fix is a single-character change: _ra(_ra()._pool_may_recover_from_rate_limit(.

Related Issue

Fixes #27719, fixes #27465, fixes #27402, fixes #27370

Type of Change

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

Changes Made

  • agent/conversation_loop.py:2254_pool_may_recover_from_rate_limit(_ra()._pool_may_recover_from_rate_limit(

How to Test

  1. Configure a provider that triggers rate-limit errors (e.g., DeepSeek without sufficient credits, or any provider with aggressive rate limiting)
  2. Run the agent until the provider returns a 429 / quota error
  3. Before fix: fallback ladder crashes with NameError: name '_pool_may_recover_from_rate_limit' is not defined
  4. After fix: fallback proceeds normally — the pool-recovery check determines whether to wait-and-retry or promote to the next provider

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs — no open PRs for this bug (4 issues, no fix submitted yet)
  • My PR contains only changes related to this fix (single-line change)
  • I've run pytest tests/ -q and all tests pass (no local test suite — hermetic fix)
  • I've added tests for my changes (one-line bug fix)
  • I've tested on my platform: Debian 13 KVM2 VPS.

Documentation & Housekeeping

  • N/A — one-line bug fix, no docs/config/tool changes

The function _pool_may_recover_from_rate_limit is defined in run_agent.py
as a method of the agent instance, but conversation_loop.py was calling
it without the _ra() prefix, causing NameError during rate limit recovery.

This fixes the bug reported in issues NousResearch#27719, NousResearch#27465, NousResearch#27402, NousResearch#27370.

The error manifested as:
  NameError: name '_pool_may_recover_from_rate_limit' is not defined

Adding _ra() prefix resolves the reference to the current agent instance.
@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 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #27359 — same one-line fix prefixing _pool_may_recover_from_rate_limit with _ra(). at conversation_loop.py:2254. Multiple prior fix PRs exist: #27374, #27468, #27534, #27583, #27732.

@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 P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

3 participants