From 03f9386dc8e1930950c185c234fad9fe7296db1b Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 26 Oct 2026 21:36:30 +0000 Subject: [PATCH 1/2] test(server): reproduce issue 22198 MCP registration timeout dropping the Claude session Co-Authored-By: Claude Opus 5.5 --- .../testkit/ProviderSwitch.integration.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts index 452509bb97b0d..0fd201750464c 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts @@ -36,6 +36,7 @@ import * as SqlClient from "effect/sql/SqlClient"; import * as SqlitePersistence from "../../persistence/Sqlite.ts"; import { CommandPolicyCapabilityUnsupportedError } from "../CommandPolicy.ts"; import { + ClaudeAgentSdkQueryRunnerError, ClaudeAppendSystemPromptFileError, ClaudeBackgroundWorkBlocksQueryReplacementError, ClaudeProviderCapabilitiesV2, @@ -404,6 +405,12 @@ const waitForIdle = Effect.fn("ProviderSwitchTest.waitForIdle")(function* ( return idle; }); +// Same tag as the adapter's unexported error raised when Claude never answers setMcpServers. +class ClaudeMcpRegistrationTimeoutError extends Schema.TaggedError()( + "ClaudeMcpRegistrationTimeoutError", + {}, +) {} + describe("orchestration v2 provider switching", () => { it.live.each([ "compact-native", @@ -1311,6 +1318,13 @@ describe("orchestration v2 provider switching", () => { it.live.each([ ["background work", new ClaudeBackgroundWorkBlocksQueryReplacementError()], ["an unreadable append file", new ClaudeAppendSystemPromptFileError({ path: "missing.md" })], + [ + "an MCP registration timeout", + new ClaudeAgentSdkQueryRunnerError({ + method: "setMcpServers", + cause: new ClaudeMcpRegistrationTimeoutError(), + }), + ], ] as const)("keeps the native session after turns refused for %s", ([, refusalCause]) => Effect.scoped( Effect.gen(function* () { From 44a07ece341013093385bc9454da7d8934966bbb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 26 Oct 2026 21:40:32 +0000 Subject: [PATCH 2/2] fix(server): Claude MCP registration timeouts keep the native session A setMcpServers timeout while the query opens happens before the prompt is offered, so treat it as a pre-prompt refusal: the unsent handoff bookkeeping is restored and the existing native session resumes on the next turn. Fixes pingdotgg/t3code#22198 Co-Authored-By: Claude Opus 5.5 --- apps/server/src/orchestration-v2/ProviderTurnStartService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts index 97fdb7c85ca71..c2c7c69fcc3ab 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts @@ -72,12 +72,14 @@ const isProviderTurnStartError = Schema.is(ProviderTurnStartError); /** * Claude refuses these before it reads the prompt: replacing a process running background work, - * or launch arguments whose appended system prompt cannot be read. + * launch arguments whose appended system prompt cannot be read, or MCP registration that never + * answers while the query opens. */ const PROMPT_REFUSAL_TAGS = [ "ClaudeBackgroundWorkBlocksQueryReplacementError", "ClaudeAppendSystemPromptFileError", "ClaudeAppendSystemPromptMissingValueError", + "ClaudeMcpRegistrationTimeoutError", ] as const; const refusedBeforePrompt = (error: unknown): boolean =>