fix(error_classifier): classify generic-typed timeout messages as transient (carve-out of #22664)#22857
Merged
Merged
Conversation
…nsient (carve-out of #22664) RuntimeError('claude CLI turn timed out') from a local OpenAI-compatible shim was falling through to FailoverReason.unknown, surfacing as 'Empty response from model' and burning 3 retry slots on the same failing endpoint. _classify_by_message had no timeout-message branch — only billing/rate_limit/auth/context_overflow/model_not_found patterns. The type-based check at line 565 also requires isinstance(error, (TimeoutError, ConnectionError, OSError)) — a plain RuntimeError doesn't match. Add _TIMEOUT_MESSAGE_PATTERNS for 'timed out', 'deadline exceeded', 'request timed out', 'operation timed out', 'upstream timed out', 'turn timed out'. _classify_by_message returns FailoverReason.timeout (retryable=True) when any pattern matches. Salvage of #22664's classifier portion. The original PR also bundled a fallback self-selection guard which is now redundant (already on main via #22780) plus DeepSeek thinking and session_search fixes that are their own separate concerns. Follow-up to #22780 — fixes the still-broken classification of generic-typed provider-shim timeouts that #22780's dedup didn't cover.
Contributor
🔎 Lint report:
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvage of #22664's classifier portion —
_classify_by_messagenow recognizes timeout-shaped messages on generic exception types (e.g.RuntimeError("claude CLI turn timed out")from a local OpenAI-compatible shim).Root cause
agent/error_classifier.py::_classify_by_messagecovered billing / rate_limit / auth / context_overflow / model_not_found patterns but had no timeout-message branch. The type-based check requiresisinstance(error, (TimeoutError, ConnectionError, OSError)), so a plainRuntimeError("…timed out")didn't match. Result: timeouts from a local shim fell through toFailoverReason.unknown, surfaced as "Empty response from model", and burned 3 retry slots on the same dead endpoint.Changes (carve-out from #22664)
agent/error_classifier.py: new_TIMEOUT_MESSAGE_PATTERNSlist ("timed out","deadline exceeded","request timed out","operation timed out","upstream timed out","turn timed out")._classify_by_messagereturnsFailoverReason.timeout(retryable=True) when any pattern matches.Carve-out rationale
The original PR #22664 also bundled:
This carve-out keeps just the title-described classifier work.
Validation
Follow-up to #22780 — fixes the still-broken classification of generic-typed provider-shim timeouts that #22780's dedup couldn't cover.