The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): reuse _RATE_LIMIT_REASONS for app-server failover; document the eligible failure classes
teknium11b0cb4d150e8
diff --git a/agent/turn_recovery.py b/agent/turn_recovery.pyindex 3f0f45e7410..b7dc891a4dd 100644--- a/agent/turn_recovery.py+++ b/agent/turn_recovery.py@@ -19,7 +19,7 @@ from typing import Any, Dict, List, Optional, Tuplefrom agent.conversation_compression import COMPRESSION_RETRY_CONTEXT_REDUCED_STATUS_TEMPLATEfrom agent.model_metadata import is_output_cap_error, parse_available_output_tokens_from_errorfrom agent.retry_utils import is_zai_coding_overload_error, zai_coding_overload_retry_ceiling-from agent.error_classifier import FailoverReason+from agent.error_classifier import FailoverReason, classify_api_errorfrom agent.message_sanitization import (_looks_like_image_content_rejection, _sanitize_messages_non_ascii,_sanitize_messages_surrogates, _sanitize_structure_non_ascii, _sanitize_structure_surrogates,@@ -1440,11 +1440,6 @@ def _eager_fallback_status(classified: Any, is_upstream: bool, is_transport_failreturn "⚠️ Rate limited — switching to fallback provider..."-_CODEX_APP_SERVER_FALLBACK_REASONS = frozenset({- FailoverReason.billing, FailoverReason.rate_limit, FailoverReason.upstream_rate_limit,-})--def activate_codex_app_server_fallback(agent: Any, result: Dict[str, Any]) -> bool:"""The codex app-server runtime reports a failed turn as ``result["error"]`` text instead ofraising, so the generic classify -> ``fallback_providers`` chain never saw it (#71633).@@ -1453,11 +1448,10 @@ def activate_codex_app_server_fallback(agent: Any, result: Dict[str, Any]) -> boerror = result.get("error")if not error or result.get("interrupted") or not agent._has_pending_fallback():return False- from agent.error_classifier import classify_api_errorclassified = classify_api_error(RuntimeError(str(error)), provider=getattr(agent, "provider", "") or "", model=getattr(agent, "model", "") or "",)- if classified.reason not in _CODEX_APP_SERVER_FALLBACK_REASONS:+ if classified.reason not in _RATE_LIMIT_REASONS:return Falseagent._buffer_diagnostic_status(_eager_fallback_status(classified, classified.reason == FailoverReason.upstream_rate_limit, False))diff --git a/website/docs/user-guide/features/codex-app-server-runtime.md b/website/docs/user-guide/features/codex-app-server-runtime.mdindex 9c85c018912..9277fd34b4c 100644--- a/website/docs/user-guide/features/codex-app-server-runtime.md+++ b/website/docs/user-guide/features/codex-app-server-runtime.md@@ -408,6 +408,7 @@ Known limitations:- **Hermes auth and codex auth are separate sessions.** You need both `codex login` AND `hermes auth add openai-codex` for the cleanest UX (the runtime uses codex's session for the LLM call). This is a deliberate design choice in Hermes' `_import_codex_cli_tokens` — Hermes won't share OAuth state with codex CLI to avoid clobbering each other on token refresh.- **`delegate_task`, `memory`, `session_search`, `todo` are unavailable on this runtime.** They need the running AIAgent context which a stateless MCP callback can't provide. Use `/codex-runtime auto` when you need these.- **No inline patch preview in approval prompts when codex doesn't track the changeset.** Codex's `fileChange` approval params don't always carry the changeset. Hermes caches the data from the corresponding `item/started` notification when possible, but if approval arrives before the item has streamed, the prompt falls back to whatever `reason` codex provides.+- **`fallback_providers` fail over only on quota and rate-limit failures.** When a codex app-server turn fails with a billing / usage-limit / rate-limit error, Hermes switches to the configured [fallback provider](./fallback-providers.md) and retries the same turn on it; auth failures (`codex login` expired), turn timeouts and unknown-model errors do not fail over on this runtime and surface as the turn's error instead.- **Sub-second cancellation isn't guaranteed.** Mid-stream interrupts (Ctrl+C while codex is responding) are sent via `turn/interrupt`, but if codex has already flushed the final message, you get the response anyway.If you find a bug, [open an issue](https://github.com/NousResearch/hermes-agent/issues) with the output of `hermes logs --since 5m`. Mention `codex-runtime` in the title so it's easy to triage.