The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent): route status-less render errors through _MESSAGE_HEAD_RULES (#62662)
kshitijk4poorc9a1c3d6f5ee
diff --git a/agent/error_classifier.py b/agent/error_classifier.pyindex 0e067bc5b92..4d54803b989 100644--- a/agent/error_classifier.py+++ b/agent/error_classifier.py@@ -609,10 +609,15 @@ _400_TAIL_RULES = _OVERFLOW_AS_5XX_RULES + ((_RATE_LIMIT_PATTERNS, _V_RATE_LIMIT), (_BILLING_PATTERNS, _billing_hints),)+# LM Studio / llama.cpp raise a bare status-less ``APIError`` when chat-template Jinja rendering+# fails mid-stream (#62662). Deterministic for the request, so fall back instead of retrying.+_STREAM_RENDER_ERROR_PATTERNS = ("error rendering", "rendering prompt", "jinja template", "jinja render")+# Status-less message path, head (before usage-limit disambiguation)._MESSAGE_HEAD_RULES = ((_MEMORY_CEILING_PATTERNS, _V_OVERLOADED),(_PAYLOAD_TOO_LARGE_PATTERNS, _V_PAYLOAD_TOO_LARGE),- (_ROLE_ALTERNATION_PATTERNS, _V_ROLE_ALTERNATION)) + _IMAGE_TOOL_RULES+ (_ROLE_ALTERNATION_PATTERNS, _V_ROLE_ALTERNATION),+ (_STREAM_RENDER_ERROR_PATTERNS, _V_FORMAT_ERROR)) + _IMAGE_TOOL_RULES# Status-less tail. Overload before rate_limit/billing so "overloaded" backs off# instead of rotating; policy block before model_not_found; timeout/connection@@ -944,23 +949,11 @@ def _by_status(c: _Ctx) -> Optional[Verdict]:return _STATUS_HANDLERS[status](c) if status in _STATUS_HANDLERS else default-# LM Studio / llama.cpp raise a bare status-less ``APIError`` when chat-template Jinja rendering-# fails mid-stream (#62662). Deterministic for the request, so fall back instead of retrying.-_STREAM_RENDER_ERROR_PATTERNS = ("error rendering", "rendering prompt", "jinja template", "jinja render")---def _streaming_render_error(c: _Ctx) -> Optional[Verdict]:- """Status-less template render failure → format_error with fallback (only when no HTTP status)."""- if c.status_code is None and any(p in c.msg for p in _STREAM_RENDER_ERROR_PATTERNS):- return _v(_R.format_error, retryable=False, should_fallback=True)- return None--# Stage order: plugin hooks → the provider's own profile hook → provider-specific special cases →-# status-less stream render errors → HTTP status → MoA shapes → structured error code → message patterns → SSL → disconnect ++# HTTP status → MoA shapes → structured error code → message patterns → SSL → disconnect +# large session → transport types → unknown (retryable with backoff)._STAGES: Sequence[Callable[[_Ctx], Optional[Verdict]]] = (- _plugin_verdict, _profile_verdict, _provider_special_cases, _streaming_render_error, _by_status, _moa_special_cases,+ _plugin_verdict, _profile_verdict, _provider_special_cases, _by_status, _moa_special_cases,_by_error_code, _by_message, _by_transport,)