Error reasons up to the UI
Flattened to a string, a rate limit, a rejected key and an overlong conversation look alike and offer nothing to do. Scope: the main chat-turn streaming error. Retry and compact-failure strings stay plain.
reason | Enum | Retryable | Chat headline |
|---|---|---|---|
rate_limit | RATE_LIMIT | yes | Rate limited — try again in {retry_after_s}s |
auth | AUTHENTICATION | no | Your API key was rejected — check it in Settings → Model services |
authz | AUTHORIZATION | no | Not authorized — check your plan / access for this model |
blocked | NETWORK_BLOCK | no | The provider's network refused the address you connect from — switch your proxy node or turn off the VPN, then try again |
context | CONTEXT_LENGTH | no | This conversation is too long — compact it or start a new chat |
policy | CONTENT_POLICY | no | The provider blocked this request (content policy) |
provider | PROVIDER_INTERNAL | yes | Temporary provider / network error — try again |
transport | TRANSPORT | yes | Temporary provider / network error — try again |
timeout | TIMEOUT | no | The request timed out — try again |
invalid | INVALID_REQUEST | no | raw message only |
unknown | UNKNOWN | no | raw message only |
A memory policy error is unknown and not retryable; error_kind: memory_unavailable names it, so the reason stays inside the set.
Event
{"type": "error", "content": "<text>", "reason": "<reason>",
"retryable": true, "retry_after_s": 30.0}
Where it happens
| Place | Does |
|---|---|
models/providers/utils/failures/errors.py | ErrorReason, LLMError, classify_error, taxonomy_fields; stream_retry drives backoff from them. error_kind gives a narrower stable name (stream_idle, stream_total, model_unavailable, auth…) found through wrapped causes |
runtime/agent/loop/driver.py | Agent boundary; sets error_reason, error_retryable, error_retry_after_s on the message. A refusal the provider states outright (no credit or quota, a rejected or expired sign-in, a plan or region it does not serve) is logged as one warning line with the provider and the reason; any other failure keeps its traceback on stderr |
runtime/conversation/turn_runtime/error_path.py | Chat turn; classifies, stores error_metadata, fills TurnResult |
apps/web/components/chat/messages/bubbles/assistant-bubble.tsx | Headline by errorReason, raw message below |
interfaces/server/transcript/rows.py | Projects the fields from a stored message, so a reload keeps the headline |
API consumers, logs and other channels read the reason too. No change to auto-retry policy; this only exposes the fields. A wider audit of except Exception sites is separate.
Verifying
A rejected key gives auth, fatal. A 429 gives rate_limit, retryable, with the hint. An oversized context gives context, fatal. Unit tests cover the mapping and that the Agent boundary keeps an LLMError's reason.
End to end needs a repeatable failure on the model the frontend selected, since it sends its own choice: an expired key for auth, or an OpenRouter :free model that returns 503 for provider.