@devries-cameron20 / t3code Mirror · read-only / commits / fe867b86c8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 14:30 UTC

fix(server): Claude MCP timeouts preserve the native session (#25660)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 26, 2026 at 22:40 UTC fe867b86c89eacf876a27a15874e6089ab33fc9d
2 files changed +17 -1
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+3 -1
@@ -93,12 +93,14 @@ const isProviderTurnStartError = Schema.is(ProviderTurnStartError);
93
94 /**
95 * Claude refuses these before it reads the prompt: replacing a process running background work,
96 - * or launch arguments whose appended system prompt cannot be read.
96 + * launch arguments whose appended system prompt cannot be read, or MCP registration that never
97 + * answers while the query opens.
98 */
99 const PROMPT_REFUSAL_TAGS = [
100 "ClaudeBackgroundWorkBlocksQueryReplacementError",
101 "ClaudeAppendSystemPromptFileError",
102 "ClaudeAppendSystemPromptMissingValueError",
103 + "ClaudeMcpRegistrationTimeoutError",
104 ] as const;
105
106 const refusedBeforePrompt = (error: unknown): boolean =>
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+14
@@ -36,6 +36,7 @@ import * as SqlClient from "effect/sql/SqlClient";
36 import * as SqlitePersistence from "../../persistence/Sqlite.ts";
37 import { CommandPolicyCapabilityUnsupportedError } from "../CommandPolicy.ts";
38 import {
39 + ClaudeAgentSdkQueryRunnerError,
40 ClaudeAppendSystemPromptFileError,
41 ClaudeBackgroundWorkBlocksQueryReplacementError,
42 ClaudeProviderCapabilitiesV2,
@@ -404,6 +405,12 @@ const waitForIdle = Effect.fn("ProviderSwitchTest.waitForIdle")(function* (
405 return idle;
406 });
407
408 +// Same tag as the adapter's unexported error raised when Claude never answers setMcpServers.
409 +class ClaudeMcpRegistrationTimeoutError extends Schema.TaggedError<ClaudeMcpRegistrationTimeoutError>()(
410 + "ClaudeMcpRegistrationTimeoutError",
411 + {},
412 +) {}
413 +
414 describe("orchestration v2 provider switching", () => {
415 it.live.each([
416 "compact-native",
@@ -1311,6 +1318,13 @@ describe("orchestration v2 provider switching", () => {
1318 it.live.each([
1319 ["background work", new ClaudeBackgroundWorkBlocksQueryReplacementError()],
1320 ["an unreadable append file", new ClaudeAppendSystemPromptFileError({ path: "missing.md" })],
1321 + [
1322 + "an MCP registration timeout",
1323 + new ClaudeAgentSdkQueryRunnerError({
1324 + method: "setMcpServers",
1325 + cause: new ClaudeMcpRegistrationTimeoutError(),
1326 + }),
1327 + ],
1328 ] as const)("keeps the native session after turns refused for %s", ([, refusalCause]) =>
1329 Effect.scoped(
1330 Effect.gen(function* () {