From 4b814405056b8861e2d8019dd6878798a8b54197 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 27 Oct 2026 18:41:54 +0000 Subject: [PATCH 1/4] test(server): reproduce #26082, killed Claude process hides its signal Adds a failing ClaudeAdapterV2 test: when the SDK message stream fails with the SDK's process-exit Error ("Claude Code process terminated by signal SIGABRT"), the failed turn reports only "Provider turn failed.". Co-Authored-By: Claude Opus 5.5 --- .../Adapters/ClaudeAdapterV2.test.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 8de0f78af88c0..f305330d778af 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -12559,6 +12559,119 @@ describe("ClaudeAdapterV2 background wake turns", () => { ), ); + // regression: #26082 a killed Claude process names its signal on the failed turn + it.effect("names the signal that killed the Claude process on the failed turn", () => + Effect.scoped( + Effect.gen(function* () { + const changes = yield* makeChangeSignal; + const fileSystem = yield* FileSystem.FileSystem; + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({ + prefix: "t3-claude-v2-process-signal-", + }); + const sdkMessages = yield* Queue.unbounded< + SDKMessage, + ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError + >(); + const events: Array = []; + const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({ + instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID, + settings: DEFAULT_CLAUDE_SETTINGS, + environment: {}, + attachmentsDir, + fileSystem, + path: yield* Path.Path, + crypto: yield* Crypto.Crypto, + idAllocator, + queryRunner: { + allocateSessionId: Effect.succeed(WAKE_NATIVE_SESSION), + open: () => + Effect.succeed({ + messages: Stream.fromQueue(sdkMessages), + offer: () => Effect.void, + setModel: () => Effect.void, + applyFlagSettings: () => Effect.void, + setPermissionMode: () => Effect.void, + backgroundTasks: () => Effect.succeed(false), + stopTask: () => Effect.void, + interrupt: Effect.void, + close: Queue.shutdown(sdkMessages), + }), + forkSession: () => Effect.die("unused forkSession"), + subagentLaunchToolUseId: () => Effect.succeed(null), + assertComplete: Effect.void, + }, + }); + const threadId = ThreadId.make("thread-claude-process-signal"); + const runtime = yield* adapter.openSession({ + threadId, + providerSessionId: ProviderSessionId.make("provider-session-claude-process-signal"), + modelSelection: CLAUDE_TEST_MODEL_SELECTION, + runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY, + }); + const providerThread = yield* runtime.ensureThread({ + threadId, + modelSelection: CLAUDE_TEST_MODEL_SELECTION, + runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY, + }); + yield* runtime.events.pipe( + Stream.runForEach((event) => + Effect.sync(() => { + events.push(event); + }).pipe(Effect.andThen(changes.notify)), + ), + Effect.forkScoped, + ); + yield* runtime.startTurn( + makeClaudeTestTurnInput({ + threadId, + providerThread, + now: yield* DateTime.now, + attemptId: RunAttemptId.make("attempt-claude-process-signal"), + text: "Write a long reply.", + attachments: [], + }), + ); + yield* Queue.offer( + sdkMessages, + makeAssistantTextFrame({ + uuid: "00000000-0000-4000-8000-000000026082", + text: "Here is the first part", + }), + ); + // Mirrors ProcessTransport.getProcessExitError in @anthropic-ai/claude-agent-sdk. + const processExit = Object.assign( + new Error("Claude Code process terminated by signal SIGABRT"), + { + telemetryMessage: "Claude Code process terminated by signal SIGABRT", + errorClass: "process_killed_by_signal", + signal: "SIGABRT", + }, + ); + yield* Queue.fail( + sdkMessages, + new ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError({ + method: "messages", + cause: processExit, + }), + ); + + yield* changes.until(() => events.some((event) => event.type === "turn.terminal")); + const terminal = events.find((event) => event.type === "turn.terminal"); + assert.equal(terminal?.status, "failed"); + if (terminal?.status !== "failed") return; + assert.include( + terminal.failure.message, + "Claude Code process terminated by signal SIGABRT", + ); + }).pipe( + Effect.provide( + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer), + ), + ), + ), + ); + const WORKFLOW_TASK_ID = "task-workflow-run"; const WORKFLOW_TOOL_USE_ID = "toolu-workflow-run"; const makeWorkflowHarnessWithOptions = ( From 8eb74992fba5f9f3cb27cd0fcfadcd36e47bbfcc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 27 Oct 2026 18:45:32 +0000 Subject: [PATCH 2/4] fix(server): a killed Claude process names its signal on the failed turn When the Claude Code process died mid-turn (a signal or nonzero exit), the failed turn said only "Provider turn failed.": the SDK's exit Error sits inside ClaudeAgentSdkQueryRunnerError, and the shared failure builder reads no raw provider text. The Claude adapter now recognises the SDK's process-exit error by its errorClass and uses its stderr-free telemetryMessage as the failure message and errorClass as the code. Fixes pingdotgg/t3code#26082 Co-Authored-By: Claude Opus 5.5 --- .../Adapters/ClaudeAdapterV2.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index b66e85e14d7c0..e2d1ba7380e71 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -626,6 +626,26 @@ function queryRunnerError(cause: unknown, method: string): ClaudeAgentSdkQueryRu : new ClaudeAgentSdkQueryRunnerError({ cause, method }); } +const CLAUDE_PROCESS_EXIT_ERROR_CLASSES: ReadonlySet = new Set([ + "process_killed_by_signal", + "process_exited_nonzero", +]); + +// The SDK's exit Error appends Claude's stderr tail to `message`; `telemetryMessage` omits it. +function claudeProcessExitFailure( + cause: Cause.Cause, +): { readonly message: string; readonly code: string } | undefined { + const error = Cause.squash(cause); + const sdkError = isClaudeAgentSdkQueryRunnerError(error) ? error.cause : error; + if (typeof sdkError !== "object" || sdkError === null) return undefined; + const { errorClass, telemetryMessage } = sdkError as Record; + return typeof errorClass === "string" && + CLAUDE_PROCESS_EXIT_ERROR_CLASSES.has(errorClass) && + typeof telemetryMessage === "string" + ? { message: `${telemetryMessage}.`, code: errorClass } + : undefined; +} + function closeClaudeQuery(queryRuntime: ClaudeQuery) { return Effect.try({ try: () => queryRuntime.close(), @@ -7394,6 +7414,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( : { failure: makeProviderFailure({ cause: cause === undefined ? undefined : Cause.squash(cause), + ...(cause === undefined ? {} : claudeProcessExitFailure(cause)), class: "transport_error", }), }), From 77bdd3a145936d8e0438065ba733cef081835425 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 27 Oct 2026 18:46:28 +0000 Subject: [PATCH 3/4] test(server): process-exit fixture carries the SDK's stderr tail Co-Authored-By: Claude Opus 5.5 --- .../src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index f305330d778af..a4e87850144fb 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -12641,7 +12641,9 @@ describe("ClaudeAdapterV2 background wake turns", () => { ); // Mirrors ProcessTransport.getProcessExitError in @anthropic-ai/claude-agent-sdk. const processExit = Object.assign( - new Error("Claude Code process terminated by signal SIGABRT"), + new Error( + "Claude Code process terminated by signal SIGABRT. stderr: fork failed: Resource temporarily unavailable", + ), { telemetryMessage: "Claude Code process terminated by signal SIGABRT", errorClass: "process_killed_by_signal", @@ -12664,6 +12666,7 @@ describe("ClaudeAdapterV2 background wake turns", () => { terminal.failure.message, "Claude Code process terminated by signal SIGABRT", ); + assert.notInclude(terminal.failure.message, "stderr"); }).pipe( Effect.provide( Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer), From 61f94246267afaf37ada3ffc953f6db76411db24 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 11 Nov 2026 00:43:11 +0000 Subject: [PATCH 4/4] test(server): process-signal test uses main's adapter inputs and checks the failure code AI-assisted; verified with the tests and tools listed above. --- .../Adapters/ClaudeAdapterV2.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 50c7056e00d87..a2f9490528066 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -17166,7 +17166,7 @@ describe("ClaudeAdapterV2 background wake turns", () => { attachmentsDir, fileSystem, path: yield* Path.Path, - crypto: yield* Crypto.Crypto, + random: yield* SecureRandom.SecureRandom, idAllocator, queryRunner: { allocateSessionId: Effect.succeed(WAKE_NATIVE_SESSION), @@ -17178,6 +17178,10 @@ describe("ClaudeAdapterV2 background wake turns", () => { applyFlagSettings: () => Effect.void, setPermissionMode: () => Effect.void, backgroundTasks: () => Effect.succeed(false), + mcpServerStatus: Effect.succeed([]), + readMcpResource: () => Effect.die("unexpected MCP resource read"), + callMcpTool: () => Effect.die("unexpected MCP tool call"), + listPermissionRules: Effect.die("unexpected permission rules read"), stopTask: () => Effect.void, interrupt: Effect.void, close: Queue.shutdown(sdkMessages), @@ -17252,9 +17256,15 @@ describe("ClaudeAdapterV2 background wake turns", () => { "Claude Code process terminated by signal SIGABRT", ); assert.notInclude(terminal.failure.message, "stderr"); + assert.equal(terminal.failure.code, "process_killed_by_signal"); }).pipe( Effect.provide( - Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer), + Layer.mergeAll( + IdAllocator.layer, + McpProviderSessions.layer, + NodeServices.layer, + NodeCrypto.layer, + ), ), ), ),