Skip to content

The agent that grows with you

fix: retain exhausted-chain cooldown classification after extraction

Teknium68b16aa7e3a3
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.py
index c72584a1ac9..e06c4b0b55a 100644
--- a/agent/chat_completion_helpers.py
+++ b/agent/chat_completion_helpers.py
@@ -1716,6 +1716,7 @@ def _fallback_chain_exhausted(agent, reason: "FailoverReason | None") -> bool:
"""Chain exhausted (always False). A non-empty chain walked on a non-rate-limit failure arms a
short cooldown so next turn's restore_primary_runtime stays gated instead of replaying the whole
context across every provider again."""
+ from agent.fallback_cooldown import _RATE_LIMIT_FAILOVER_REASONS
if agent._fallback_chain and reason not in _RATE_LIMIT_FAILOVER_REASONS:
agent._rate_limited_until = max(
getattr(agent, "_rate_limited_until", 0) or 0, time.monotonic() + _FALLBACK_EXHAUSTED_COOLDOWN_S)