A2A Error Handling
Before writing code
Fetch live docs:
- Fetch
https://a2a-protocol.org/latest/specification/for the error handling section - Web-search
site:github.com a2aproject A2A error codesfor error code definitions - Web-search
site:github.com a2aproject a2a-samples errorfor error handling examples - Fetch SDK docs for error classes and exception types
Conceptual Architecture
Error Categories
A2A has three categories of errors:
- JSON-RPC Protocol Errors — Malformed requests, invalid methods, parse failures
- A2A-Specific Errors — Protocol-level issues specific to A2A operations
- Task-Level Failures — The task itself fails during processing (task state →
failed)
JSON-RPC 2.0 Error Format
All errors follow the JSON-RPC 2.0 error response format:
{
"jsonrpc": "2.0",
"id": "request-id",
"error": {
"code": -32600,
"message": "Invalid Request",
"data": { "details": "..." }
}
}
Standard JSON-RPC Error Codes
| Code | Name | Meaning |
|---|---|---|
-32700 | Parse error | Invalid JSON |
-32600 | Invalid request | Not a valid JSON-RPC request |
-32601 | Method not found | Method doesn't exist or isn't supported |
-32602 | Invalid params | Method parameters are invalid |
-32603 | Internal error | Server internal error |
A2A-Specific Error Codes
| Code | Name | Meaning |
|---|---|---|
-32001 | TaskNotFoundError | The referenced taskId doesn't exist |
-32002 | TaskNotCancelableError | Task is in a state that can't be canceled (terminal state) |
-32003 | PushNotificationNotSupportedError | Agent doesn't support push notifications |
-32004 | UnsupportedOperationError | The requested operation is not supported |
-32005 | ContentTypeNotSupportedError | Client's accepted output modes don't match agent's capabilities |
-32006 | InvalidAgentResponseError | The agent returned an invalid or malformed response |
-32007 | ExtendedAgentCardNotConfiguredError | Extended Agent Card is not configured |
-32008 | ExtensionSupportRequiredError | A required extension is not supported |
-32009 | VersionNotSupportedError | The requested protocol version is not supported |
Task Failure vs Protocol Error
Important distinction:
- Protocol errors return a JSON-RPC error response — the request itself was invalid or couldn't be processed
- Task failures return a normal response with the task in
failedstate — the request was valid but the task's processing failed
Example: If a client sends message/send with invalid JSON → -32700 (protocol error). If a client sends a valid message but the agent's LLM call fails → task state becomes failed with an error message.
Server-Side Error Handling
The server should:
- Validate JSON-RPC structure — Return
-32600/-32700for malformed requests - Validate method — Return
-32601for unsupported methods - Validate parameters — Return
-32602for invalid params - Check task existence — Return
-32001for unknown task IDs - Check capabilities — Return
-32003/-32005for unsupported features - Handle extended card — Return
-32007if extended Agent Card is not configured - Handle internal errors — Return
-32603for unexpected server errors - Set task state — Transition to
failedfor task-level processing errors
Client-Side Error Handling
The client should:
- Parse the response — Check for
errorfield vsresultfield - Handle by error code — Different codes need different responses
- Retry transient errors —
-32603(internal error) may be retryable - Don't retry permanent errors —
-32601(method not found) won't succeed on retry - Handle task failures — Check task state for
failedand read the error message - Fallback — Try alternative agents if one fails
Retry Strategy
| Error Code | Retryable? | Strategy |
|---|---|---|
-32700 | No | Fix the request |
-32600 | No | Fix the request |
-32601 | No | Method not available on this agent |
-32602 | No | Fix the parameters |
-32603 | Yes | Exponential backoff, max 3 retries |
-32001 | No | Task doesn't exist |
-32002 | No | Task can't be canceled |
-32005 | No | Content type mismatch |
-32007 | No | Extended Agent Card not configured |
Best Practices
- Always include meaningful error messages, not just codes
- Use the
datafield in JSON-RPC errors for additional debugging context - Log errors with request IDs and task IDs for traceability
- Implement circuit breakers for agents that are consistently failing
- Set task state to
failedwith a descriptive message when processing fails - Don't expose internal implementation details in error messages to external clients
- Implement graceful degradation — if one agent in a pipeline fails, handle it upstream
- Test error paths explicitly — they're as important as the happy path
Fetch the specification for the complete list of error codes, their semantics, and any error handling requirements before implementing.