fix: fallback to new session on Internal error (-32603) during session/load#30
Conversation
…n/load Some ACP agents (e.g. claude-agent-acp) cannot restore sessions after a process restart. When session/load is attempted, they return a JSON-RPC Internal error (-32603) instead of a resource-not-found error. Previously, shouldFallbackToNewSession() only recognized resource-not-found errors, causing the Internal error to propagate and break persistent session mode entirely. This change adds isAcpInternalError() and uses it in shouldFallbackToNewSession() so that -32603 errors trigger a graceful fallback to createSession, matching the existing recovery path.
|
Can confirm this fixes the issue. We hit the exact same failure path with For additional context on why PR #22 added detection for The upstream fix on |
|
Thanks for confirming and for the detailed context on the Hopefully this can get merged soon so the fix lands in the next release. |
|
FYI: we also filed the upstream fix — zed-industries/claude-agent-acp#363. It makes |
|
Nice, thanks for the heads-up! Good to have this as defense-in-depth either way — the broader catch ensures we handle any unexpected session errors gracefully regardless of the upstream error code. |
Problem
Some ACP agents (e.g.
claude-agent-acp) cannot restore sessions after a process restart. Whensession/loadis attempted on a reconnect, they return a JSON-RPC Internal error (-32603) instead of a resource-not-found error.shouldFallbackToNewSession()only recognized resource-not-found errors, so the Internal error propagated as an unrecoverable failure — breaking persistent session mode entirely.Root Cause
claude-agent-acpreturns:{"code": -32603, "message": "Internal error", "data": {"details": "Query closed before response received"}}This error code was not in the fallback allowlist.
Fix
isAcpInternalError()helper inacp-error-shapes.tsto detect-32603shouldFallbackToNewSession()insession-runtime.tsto treat Internal errors as recoverable, falling back tocreateSessionThis matches the existing recovery path for resource-not-found errors.
Testing
Manually verified: after patching,
acpx --approve-all claude "hello"successfully falls back to a fresh session whensession/loadreturns-32603, instead of crashing with[error] RUNTIME: Internal error.