Agent Wealth HubFree public resources
中文 EN العربية

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

  1. Import CLINotFoundError, CLIConnectionError, ProcessError, ResultError, and CLIJSONDecodeError. [readme]
  2. Catch concrete types; for ResultError, inspect subtype, terminal_reason, api_error_status, result, or errors. [readme]
  3. 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

Permissions

Limitations

Error classification does not establish business correctness; exception fields are tied to the pinned SDK version.

Pinned upstream source

https://github.com/anthropics/claude-agent-sdk-python/blob/b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c/README.md

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

Related resources