Agentic.LLM.ErrorPatterns
(agentic v0.2.2)
Copy Markdown
Generic pattern tables for classifying LLM provider errors from
response body text. Ported from openclaw's failover-matches.ts.
Each classify_* /1 function tests a lowercased message against a
set of string/regex patterns. Returns the matching classification
atom or nil.
classify_message/1 runs all classifiers in priority order and
returns the first match.
Summary
Functions
Classify transient auth errors (invalid key, expired token) from a lowered message string.
Classify permanent auth errors (revoked keys, disabled accounts) from a lowered message string.
Classify billing/payment errors from a lowered message string.
Classify context-overflow errors from a lowered message string.
Classify bad-request format errors from a lowered message string.
Run all pattern classifiers against message in priority order.
Returns the first matching classification, or nil.
Classify model-not-found errors from a lowered message string.
Classify service-overloaded errors from a lowered message string.
Classify rate-limiting errors from a lowered message string.
Classify session-expired errors from a lowered message string.
Classify timeout and network errors from a lowered message string.
Types
@type classification() :: Agentic.LLM.Error.classification()
Functions
@spec classify_auth(String.t()) :: :auth | nil
Classify transient auth errors (invalid key, expired token) from a lowered message string.
@spec classify_auth_permanent(String.t()) :: :auth_permanent | nil
Classify permanent auth errors (revoked keys, disabled accounts) from a lowered message string.
@spec classify_billing(String.t()) :: :billing | nil
Classify billing/payment errors from a lowered message string.
@spec classify_context_overflow(String.t()) :: :context_overflow | nil
Classify context-overflow errors from a lowered message string.
Uses two-pass detection: first explicit patterns, then a generic two-keyword heuristic.
@spec classify_format(String.t()) :: :format | nil
Classify bad-request format errors from a lowered message string.
@spec classify_message(String.t()) :: classification() | nil
Run all pattern classifiers against message in priority order.
Returns the first matching classification, or nil.
Context overflow is tested separately (last) because it's the one classification that doesn't trigger failover — it triggers compaction instead. We still detect it here so the caller can route it appropriately.
@spec classify_model_not_found(String.t()) :: :model_not_found | nil
Classify model-not-found errors from a lowered message string.
@spec classify_overloaded(String.t()) :: :overloaded | nil
Classify service-overloaded errors from a lowered message string.
@spec classify_rate_limit(String.t()) :: :rate_limit | nil
Classify rate-limiting errors from a lowered message string.
@spec classify_session_expired(String.t()) :: :session_expired | nil
Classify session-expired errors from a lowered message string.
@spec classify_timeout(String.t()) :: :timeout | nil
Classify timeout and network errors from a lowered message string.