Module 11: Error Handling
Handle protocol errors from agents on the client side.What You’ll Learn
- Catching
AcpClientSession.AcpError - Standard error codes in
AcpErrorCodes - Throwing
AcpProtocolExceptionfrom agent handlers - Error recovery — continuing after errors
The Code
ACP uses structured errors based on JSON-RPC error codes. On the client side, protocol errors arrive asAcpClientSession.AcpError exceptions. You can inspect the error code to determine what went wrong:
AcpProtocolException with a standard error code. The SDK converts it to a JSON-RPC error response:
Error Codes
| Code | Constant | When to Use |
|---|---|---|
-32602 | INVALID_PARAMS | Bad input from client |
-32603 | INTERNAL_ERROR | Unexpected agent failure |
-32001 | SESSION_NOT_FOUND | Unknown session ID |
-32002 | PERMISSION_DENIED | Client lacks permission |
AcpProtocolException with one of these codes. The SDK converts it to a JSON-RPC error response. Clients catch it as AcpClientSession.AcpError.