From 72dfb8418c21616e9808a731de00bb584649eaa3 Mon Sep 17 00:00:00 2001 From: nikos efthias Date: Mon, 18 May 2026 15:24:43 +0400 Subject: [PATCH] fix(conversation_loop): use _ra() accessor for _pool_may_recover_from_rate_limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The eager-fallback path on 429 calls _pool_may_recover_from_rate_limit() as a bare name, but the function lives in run_agent.py and is never imported into conversation_loop.py. When a rate-limit error actually reaches this code path, it crashes with NameError instead of evaluating the pool-recovery check — which means the fallback chain never fires for single-credential providers that can't rotate. Use _ra()._pool_may_recover_from_rate_limit() to access it through the lazy run_agent reference, consistent with every other cross-module call in this file. The bug is latent because the code path only executes when BOTH conditions are met: (1) a 429/rate-limit error occurs AND (2) the fallback chain has available entries. With few fallback entries or rare rate limits, the buggy line is never reached. Introduced in 1fc77f995 (fix(agent): fall back on rate limit when pool has no rotation room). --- agent/conversation_loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/conversation_loop.py b/agent/conversation_loop.py index d3d47a5a10120..706f0dcb311b8 100644 --- a/agent/conversation_loop.py +++ b/agent/conversation_loop.py @@ -2317,7 +2317,7 @@ def _stop_spinner(): # still recover. See _pool_may_recover_from_rate_limit # for the single-credential-pool and CloudCode-quota # exceptions. Fixes #11314 and #13636. - pool_may_recover = _pool_may_recover_from_rate_limit( + pool_may_recover = _ra()._pool_may_recover_from_rate_limit( agent._credential_pool, provider=agent.provider, base_url=getattr(agent, "base_url", None),