Repository navigation
Conversation
The ACP SDK allows null title, content and locations on tool_call_update. The bridge's schema rejected them, so an update carrying a call's final status was dropped and the call later closed as completed. Read null as absent for every SDK-nullable tool call field. When an agent rejects session/prompt because it lost or locked the session (-32002, or "session not found" / "session lock unavailable" in -32602/-32603 errors from OpenCode, Gemini, Copilot, Qwen and Cursor), the bridge kept prompting the dead session and every later message failed. Mark the session for rebuild, the way a failed cancellation already does, so the next turn restarts the agent and reloads the session through rebuildAgentSession. Turns, /compact and session option changes all mark it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
deleted the
bb/fix-acp-nullable-tool-fields-and-lost-session-re-thr_diqec62hhe
branch
November 18, 2026 22:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Two ACP bridge bugs, both in
packages/provider-bridge-acp, affecting OpenCode, Cursor, Copilot, Gemini, Qwen and other ACP threads.Null tool call fields. ACP SDK 1.9.0 types
ToolCallUpdate.title,contentandlocationsasT | null.acpToolCallFieldsSchema(wire.ts) accepted null only forname(andkind/statusthrough the enum preprocess). Anytool_call_updatewithtitle: null,content: nullorlocations: nullfailedsafeParse, anddelta-translation.tsdropped it as unhandled, even when it carried the call's finalfailed/completedstatus and output. The call then closed ascompletedat end of turn with no output.Lost agent session. When the agent rejected
session/promptbecause it no longer had the session,runTurnreported the error and kept the same session. Every later message in the thread failed with the same error until bb restarted the bridge.ACP_RESOURCE_NOT_FOUND_CODEwas defined but unused. Real agents don't only use-32002. Probing installed agents with a prompt on an unknown session id gave:-32602 "Invalid params: session not found: <id>"-32602 "Session not found: <id>"-32602 "Session <id> not found"-32603 "Internal error",data.details: "Session not found: <id>"-32603 "Internal error",data.details: "Session <id> not found"T3 Code adds Copilot's
session lock unavailable …cause.What changed
wire.ts: newacpNullAsAbsent(schema), used for every SDK-nullable tool call field (title,name,content,locations). It also replaces the duplicateacpOptionalString/acpToolCallNameSchema. Null means "unchanged", as the SDK documents forname. This also covers the tool call insidesession/request_permission, which shares the schema.bridge/bridge.ts:restartAfterCancelError: booleanbecomesrebuildBeforeNextPrompt: "cancel-error" | "lost-session" | null.isLostSessionErrormatches-32002, or an agent error whose message (includingdata.details) says the session was not found or its lock is unavailable. A lost-session error marks the session for rebuild in all three places a session-scoped request can fail: the turn prompt (and the settings reconcile before it), the/compactprompt, andturn/startsession option changes. The next turn rebuilds through the existingrebuildAgentSession: restart the agent, thensession/load/session/resume, or a fresh session with the existing "could not restore" warning.session/replacedreports "The ACP agent lost its session; the session was rebuilt before continuing." The failed turn is not retried automatically.fake-acp-agent.mjs:FAKE_ACP_LOST_SESSION_ERROR+FAKE_ACP_LOST_SESSION_FILEmake the first launched process reject every prompt with a given JSON-RPC error.Credit: T3 Code #26651 (Copilot lost/locked session restart) and #21448/#25559 (ACP tool calls ending as completed) pointed at these.
How you verified
Real repro, lost session (bb's ACP bridge + real
opencode acp2.0.22). A driver sendsthread/startandturn/startto the bridge'shandleLine, deletes the agent's session withopencode session delete <id>whileopencode acpis still running, then sends three turns.origin/main: all three turns fail withInvalid params: session not found: ses_…; nosession/replacednotification, same session each time.session/replaced(reason above,contextLost: truesince the deleted session can't load), the warning, and the prompt goes to the new sessionses_e0f9ac9d…. On this machine, OpenCode's only configured provider then answeredcredit_balance_exhaustedfrom OpenAI. That is an agent-side billing error, so I could not show a model reply through OpenCode; the bridge tests cover the completed reply.Real repro, null fields (bb's ACP bridge + an agent built on
@agentclientprotocol/sdk1.9.0'sAgentSideConnection) sending SDK-typed updates: apnpm testcall, thentool_call_update {status: "in_progress", title/content/locations: null}, then{status: "failed", title: null, locations: null, content: "3 tests failed"}.origin/main: both null updates dropped asunhandled;call_1closescompleted.call_1closesfailed, and a read call closed with null fields closescompleted.I didn't find a production agent that sends these nulls in a capture; the SDK types allow them.
Tests (fail on main, pass here):
wire.test.ts: nulltitle/name/content/locationsparse as absent; a permission request tool call with nulls parses.delta-translation.test.ts: a call whose updates send nulls settlesfailedwith its output.bridge.test.ts: a table of five real error shapes (-32002, OpenCode, Copilot, Cursor, Copilot lock): turn 1 fails, turn 2 completes after one restart,session/loadof the same id and onesession/replaced. Also a/compactfailure followed by a rebuilt next turn. A negative row (-32603"upstream model overloaded") keeps the process and fails both turns, so the matcher can't widen silently.origin/main's source: the three null-field tests and the six lost-session tests fail; the negative row passes.Commands:
pnpm exec turbo run typecheck lint test --filter=@bb/provider-bridge-acp→ 621 passed, 4 skippedpnpm exec turbo run typecheck lint:type-aware --filter='...@bb/provider-bridge-acp'→ 155/155 tasks🤖 Generated with Claude Code