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

classification()

@type classification() :: Agentic.LLM.Error.classification()

Functions

classify_auth(lowered)

@spec classify_auth(String.t()) :: :auth | nil

Classify transient auth errors (invalid key, expired token) from a lowered message string.

classify_auth_permanent(lowered)

@spec classify_auth_permanent(String.t()) :: :auth_permanent | nil

Classify permanent auth errors (revoked keys, disabled accounts) from a lowered message string.

classify_billing(lowered)

@spec classify_billing(String.t()) :: :billing | nil

Classify billing/payment errors from a lowered message string.

classify_context_overflow(lowered)

@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.

classify_format(lowered)

@spec classify_format(String.t()) :: :format | nil

Classify bad-request format errors from a lowered message string.

classify_message(message)

@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.

classify_model_not_found(lowered)

@spec classify_model_not_found(String.t()) :: :model_not_found | nil

Classify model-not-found errors from a lowered message string.

classify_overloaded(lowered)

@spec classify_overloaded(String.t()) :: :overloaded | nil

Classify service-overloaded errors from a lowered message string.

classify_rate_limit(lowered)

@spec classify_rate_limit(String.t()) :: :rate_limit | nil

Classify rate-limiting errors from a lowered message string.

classify_session_expired(lowered)

@spec classify_session_expired(String.t()) :: :session_expired | nil

Classify session-expired errors from a lowered message string.

classify_timeout(lowered)

@spec classify_timeout(String.t()) :: :timeout | nil

Classify timeout and network errors from a lowered message string.