# `Agentic.LLM.ErrorPatterns`

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.

# `classification`

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

# `classify_auth`

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

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

# `classify_auth_permanent`

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

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

# `classify_billing`

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

Classify billing/payment errors from a lowered message string.

# `classify_context_overflow`

```elixir
@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`

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

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

# `classify_message`

```elixir
@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`

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

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

# `classify_overloaded`

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

Classify service-overloaded errors from a lowered message string.

# `classify_rate_limit`

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

Classify rate-limiting errors from a lowered message string.

# `classify_session_expired`

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

Classify session-expired errors from a lowered message string.

# `classify_timeout`

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

Classify timeout and network errors from a lowered message string.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
