The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent/chat_completion_helpers): fold silent-hang hint and exhausted-cooldown helpers
Teknium24a6b8d20276
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.pyindex daf486311af..a190cee4afd 100644--- a/agent/chat_completion_helpers.py+++ b/agent/chat_completion_helpers.py@@ -1075,12 +1075,10 @@ def _resolve_nonstream_watchdogs(agent, api_kwargs: dict) -> _NonStreamWatchdogsdef _codex_silent_hang_hint(agent, api_kwargs: dict) -> Optional[str]:hint_fn = getattr(agent, "_codex_silent_hang_hint", None)- if not callable(hint_fn):- return None- try:- return hint_fn(model=api_kwargs.get("model"))- except Exception:- return None+ with contextlib.suppress(Exception):+ if callable(hint_fn):+ return hint_fn(model=api_kwargs.get("model"))+ return Noneclass _NonStreamRequest:@@ -1818,8 +1816,8 @@ def _fallback_chain_exhausted(agent, reason: "FailoverReason | None") -> bool:short cooldown so next turn's restore_primary_runtime stays gated instead of replaying the wholecontext across every provider again."""if agent._fallback_chain and reason not in _RATE_LIMIT_FAILOVER_REASONS:- existing = getattr(agent, "_rate_limited_until", 0) or 0- agent._rate_limited_until = max(existing, time.monotonic() + _FALLBACK_EXHAUSTED_COOLDOWN_S)+ agent._rate_limited_until = max(+ getattr(agent, "_rate_limited_until", 0) or 0, time.monotonic() + _FALLBACK_EXHAUSTED_COOLDOWN_S)return False