@@ -11017,6 +11017,68 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1101711017 ),
1101811018 );
1101911019
11020+ it.effect("fails a turn start with the MCP registration timeout as its cause", () =>
11021+ Effect.scoped(
11022+ Effect.gen(function* () {
11023+ const fileSystem = yield* FileSystem.FileSystem;
11024+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
11025+ const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
11026+ prefix: "t3-claude-v2-mcp-timeout-start-",
11027+ });
11028+ const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
11029+ instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
11030+ settings: DEFAULT_CLAUDE_SETTINGS,
11031+ environment: {},
11032+ attachmentsDir,
11033+ fileSystem,
11034+ path: yield* Path.Path,
11035+ crypto: yield* Crypto.Crypto,
11036+ idAllocator,
11037+ continuationRequests: { offer: () => Effect.void },
11038+ queryRunner: {
11039+ allocateSessionId: Effect.succeed(WAKE_NATIVE_SESSION),
11040+ open: () => Effect.fail(new ClaudeAdapterV2.ClaudeMcpRegistrationTimeoutError()),
11041+ forkSession: () => Effect.die("unused forkSession"),
11042+ subagentLaunchToolUseId: () => Effect.succeed(null),
11043+ assertComplete: Effect.void,
11044+ },
11045+ });
11046+ const threadId = ThreadId.make("thread-claude-mcp-timeout-start");
11047+ const runtime = yield* adapter.openSession({
11048+ threadId,
11049+ providerSessionId: ProviderSessionId.make("provider-session-claude-mcp-timeout-start"),
11050+ modelSelection: CLAUDE_TEST_MODEL_SELECTION,
11051+ runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
11052+ });
11053+ const providerThread = yield* runtime.ensureThread({
11054+ threadId,
11055+ modelSelection: CLAUDE_TEST_MODEL_SELECTION,
11056+ runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
11057+ });
11058+
11059+ // The turn service restores the unsent handoff marker by finding this tag in the cause chain.
11060+ const failure = yield* runtime
11061+ .startTurn(
11062+ makeClaudeTestTurnInput({
11063+ threadId,
11064+ providerThread,
11065+ now: yield* DateTime.now,
11066+ attemptId: RunAttemptId.make("attempt-claude-mcp-timeout-start"),
11067+ text: "Hello",
11068+ attachments: [],
11069+ }),
11070+ )
11071+ .pipe(Effect.flip);
11072+ assert.equal(failure._tag, "ProviderAdapterTurnStartError");
11073+ assert.instanceOf(failure.cause, ClaudeAdapterV2.ClaudeMcpRegistrationTimeoutError);
11074+ }).pipe(
11075+ Effect.provide(
11076+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
11077+ ),
11078+ ),
11079+ ),
11080+ );
11081+
1102011082 it.effect(
1102111083 "keeps the process and its roster when a model change meets a running background shell",
1102211084 () =>
0 commit comments