AI Agent Error Categorization 2026
Timeouts, rate limits, bad arguments, third-party outages, malformed output. Adding a try-except per case rots the code. Six categories, one strategy each, and the code gets shorter.
📜 Table of Contents
Six Error Categories for Agents and How to Handle Each
Agent failures are broader than service failures: network timeouts, invalid JSON from the model, and plans that were never sensible. One try-except per error rots the code within months.
The six categories
| Type | Symptoms | Strategy | Retry |
|---|---|---|---|
| Transient | timeout, 429, connection reset | exponential backoff with jitter | yes, capped |
| Input | missing or malformed arguments | clear message to the user | no |
| Tool | upstream 5xx, changed response shape | fallback or degrade | limited |
| Auth | expired key, missing scope | alert and stop | no |
| Format | invalid JSON, missing fields | regenerate with the error | once |
| Logic | bad plan, tool loops | degrade or hand off | no |
A large "unknown" bucket means the categories are wrong, not that the errors are exotic.
Classify by exception type
import httpx
def classify(e):
if isinstance(e, (httpx.TimeoutException, httpx.ConnectError)):
return "transient"
if isinstance(e, httpx.HTTPStatusError):
code = e.response.status_code
if code == 429: return "transient"
if code in (401, 403): return "auth"
if code >= 500: return "tool"
if isinstance(e, ValueError): return "format"
if isinstance(e, KeyError): return "input"
return "unknown"
Match on types, never on message text.
Handling
- Transient: backoff from one second, three attempts, jitter. Honour
Retry-Afteron 429. - Input: never retry. Say what is missing, in what format, with an example.
- Tool: switch to a fallback, otherwise report degraded service and alert. Looping on a dead service is the fastest way to burn budget.
- Auth: breaker open, alert, no retries.
- Format: resend with the validation error, once. Twice failing means the schema is wrong.
- Logic: cap steps and per-tool call counts, then degrade to a fixed flow and keep the trace.
Error budget and alerts
Track rates per category. Rising tool errors usually mean upstream changes; rising format errors mean model or prompt changes; rising logic errors usually follow a shift in traffic mix. Alert on sliding-window ratios, and add "N consecutive failures opens the breaker" per category.
Record errors in traces
| Field | Use |
|---|---|
| category | trend by type |
| tool | which integration degraded |
| attempts | whether retries help |
| recovered | recovery rate |
| trace_id | join to the full run |
FAQ
How many categories? Six to eight. More splits each bucket too thin to show trends; use sub-tags instead.
Retry counts? Three for transient, one for format, zero for the rest. Retries cost money.
Tell the user everything? No. Silent on recovered transients, explicit about degraded features, generic on auth failures with details in alerts.
Detecting logic errors? Alert on total steps, consecutive calls to one tool, and repeated identical inputs. Stop the run instead of letting it spin.
Exception types differ by HTTP client; adjust the mapping to the library you use.
Related
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.