Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/conversation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,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),
Expand Down
16 changes: 16 additions & 0 deletions tests/agent/test_gemini_fast_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
Gemini OAuth) the 429 is an account-wide throttle, so waiting for pool
rotation is pointless — prefer fallback immediately.
"""
import inspect
from unittest.mock import MagicMock

from agent import conversation_loop
from run_agent import _pool_may_recover_from_rate_limit


Expand Down Expand Up @@ -60,3 +62,17 @@ def test_exhausted_pool_skips_rotation():

def test_no_pool_skips_rotation():
assert _pool_may_recover_from_rate_limit(None) is False


def test_conversation_loop_resolves_pool_helper_through_run_agent_module():
"""Extracted conversation loop must honor tests/patches on run_agent.

conversation_loop intentionally lazy-loads run_agent via _ra(). If this
call site uses a bare imported helper, monkeypatching run_agent in tests (and
production wrappers that patch run_agent) will not propagate into the
extracted loop; older code also hit NameError in this branch.
"""
source = inspect.getsource(conversation_loop.run_conversation)

assert "_ra()._pool_may_recover_from_rate_limit(" in source
assert "pool_may_recover = _pool_may_recover_from_rate_limit(" not in source