Back to catalog / Agent operations
Classify agent failures by structured exception
Separate missing CLI, connection loss, process failure, and terminal model errors instead of retrying every exception.
Goal
Convert SDK errors into auditable failure classes and appropriate recovery actions.
Steps
- Import
CLINotFoundError,CLIConnectionError,ProcessError,ResultError, andCLIJSONDecodeError. [readme] - Catch concrete types; for
ResultError, inspectsubtype,terminal_reason,api_error_status,result, orerrors. [readme] - Retry only transient connection failures with a cap; report terminal errors, configuration failures, and decode failures separately. [readme]
How to verify
Simulate each exception class and assert distinct alert/recovery handling with no unbounded retries.
Troubleshooting
If an error escapes, inspect the exception hierarchy and preserve structured fields; do not log full prompts or credentials.
Permissions
Prerequisites
- Python 3.10+, SDK; exception mapping can be unit-tested without a live model call.
Permissions
- Log the error class and necessary status fields; protect api_error_status under organizational policy.
Limitations
Error classification does not establish business correctness; exception fields are tied to the pinned SDK version.
Pinned upstream source
- Repository
- anthropics/claude-agent-sdk-python
- File path
- README.md
- Pinned commit
b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Take a coding Agent change from context to verification