hermes - 💡(How to fix) Fix NameError: _pool_may_recover_from_rate_limit is not defined — missing _ra() prefix in conversation_loop.py [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

When the upstream API returns a 429 (rate limit) error AND the agent has a fallback model configured, the agent crashes with: The user sees: Sorry, I encountered an error (NameError).

  • Error: upstream returned 429 "当前分组上游负载已饱和" Traceback (from gateway.log)

Root Cause

Root Cause

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Bug Description

When the upstream API returns a 429 (rate limit) error AND the agent has a fallback model configured, the agent crashes with:


NameError: name '_pool_may_recover_from_rate_limit' is not defined


The user sees: Sorry, I encountered an error (NameError).

Root Cause

In agent/conversation_loop.py line 2335, the function _pool_may_recover_from_rate_limit() is called without the _ra(). lazy import wrapper that this file uses for all other run_agent symbols:

python
Line 2335 — BROKEN (bare name, not in this module)
pool_may_recover = _pool_may_recover_from_rate_limit(
    agent._credential_pool,
    provider=agent.provider,
    base_url=getattr(agent, "base_url", None),
)


Other calls in the same file correctly use the _ra() wrapper, e.g.:

python
Line 553 — correct pattern
_ra()._set_interrupt(False, agent._execution_thread_id)

Line 555 — correct pattern
_ra()._set_interrupt(True, agent._execution_thread_id)


The function _pool_may_recover_from_rate_limit is defined in run_agent.py line 239. The lazy import wrapper _ra() is defined at line 76 of conversation_loop.py.

Fix

One-line fix — add _ra(). prefix:

python
Line 2335 — FIXED
pool_may_recover = _ra()._pool_may_recover_from_rate_limit(


Reproduction Conditions

1. Configure an agent with fallback_model (so agent._fallback_chain is non-empty)
2. Trigger a 429 rate limit from the primary provider
3. The code enters the is_rate_limited branch and calls the bare name → NameError

Environment

- Version: v2026.5.16-279-g52e3bfc2f
- Provider: custom (OneAPI proxy routing to DeepSeek)
- Error: upstream returned 429 "当前分组上游负载已饱和"

Traceback (from gateway.log)


File "/root/.hermes/hermes-agent/agent/conversation_loop.py", line 2335, in run_conversation
    pool_may_recover = _pool_may_recover_from_rate_limit(
NameError: name '_pool_may_recover_from_rate_limit' is not defined

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING