From the Inside Claude Code - The Claude Code Ecosystem architecture map

Control-protocol failures escape the SDK exception hierarchy

risk · medium · verified

Control Protocol Query and SDK MCP Bridge raise plain Exception at 13 sites: control request timeouts, CLI error responses, missing callbacks, unsupported subtypes and closed MCP sessions (query.py:404, 591-751, 1145; sdk_mcp_bridge.py:76-370). The Errors module defines ClaudeSDKError and typed subclasses, but none is used here.

Impact: Callers who catch ClaudeSDKError around interrupt(), set_model() or get_mcp_status() miss these failures and must string-match messages, which makes every wording change a breaking change.

Recommendation (small effort): Add ControlRequestError and ControlRequestTimeoutError subclasses of ClaudeSDKError (the timeout also subclassing TimeoutError) and raise them from _send_control_request and the bridge.

The trail

  1. Control Protocol Query
  2. Errors
Open on the map

More from this board