Make your product agent-ready
Error Handling
Structured errors that enable agents to diagnose failures and recover autonomously
Last verified 2026-09-24
Summary
Error Handling covers structured failures that tell agents what happened and what to do next. Use it for HTTP errors, tool errors, errors, retry policy, validation feedback, and recovery.
- Owns: Problem Details, agent extensions, retry signals, idempotency keys, recovery suggestions, IDs, and CLI error contracts.
- Does not own: authentication flows themselves; see Authentication. Tool naming and schemas; see Tool Design.
- Agent-ready means: the failure body is structured enough for the agent to retry, change input, switch tools, wait, or escalate without parsing prose.
Start Here
- RFC 9457 - Use Problem Details as the base error shape, plus agent extensions (retriable flags, suggestions, trace IDs, field errors).
- Errors for Agents - Write failures as recovery contracts, not blame.
- Retry Patterns - Separate transient failures from terminal ones.
- Idempotency - Make write retries safe.
- CLI Errors - Map command failures to structured output and stable exit codes.
Related
- API Surface - Expose error types as part of the HTTP contract.
- CLI Design - Make command failures parseable and automatable.
- Tool Design: Idempotency and Safety - Classify tool operations before retrying them.
- Authentication - Use structured auth failures instead of opaque 401/403 responses.
- Testing - Verify recovery and retry behavior with evals and contract tests.