Skip to content

fix: resolve fallback pool helper in conversation loop#27903

Closed
hrakotom wants to merge 1 commit into
NousResearch:mainfrom
hrakotom:fix/gateway-fallback-pool-helper
Closed

fix: resolve fallback pool helper in conversation loop#27903
hrakotom wants to merge 1 commit into
NousResearch:mainfrom
hrakotom:fix/gateway-fallback-pool-helper

Conversation

@hrakotom

Copy link
Copy Markdown

Summary

  • add a lazy conversation_loop wrapper for run_agent._pool_may_recover_from_rate_limit
  • preserve run_agent patchability after the run_conversation extraction
  • cover the gateway/Discord fallback NameError path with a regression test

Reference

Observed in local Discord gateway logs when Codex primary hit HTTP 429 and fallback_model was configured:

agent.conversation_loop: API call failed ... provider=openai-codex ... HTTP 429
File "agent/conversation_loop.py", line 2254, in run_conversation
    pool_may_recover = _pool_may_recover_from_rate_limit(...)
NameError: name '_pool_may_recover_from_rate_limit' is not defined

The helper lives in run_agent.py, but the extracted conversation loop referenced it as a module-local global. Gateway sessions call the extracted loop directly, so the eager fallback branch crashed before activating the configured fallback provider.

Test Plan

  • /usr/local/lib/hermes-agent/venv/bin/python -m pytest tests/run_agent/test_provider_fallback.py tests/agent/test_gemini_fast_fallback.py -q -o 'addopts='
  • /usr/local/lib/hermes-agent/venv/bin/python -m py_compile agent/conversation_loop.py run_agent.py
  • git diff --check

@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 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) — same NameError on _pool_may_recover_from_rate_limit() in conversation_loop.py:2254 after run_agent.py extraction refactor. 10+ duplicate fix PRs already exist.

@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