The best way to control Claude Code, Codex and more from any computer or phone
fix(claude): a killed Claude process names its signal on the failed turn (#26086)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 11:57 UTC
cdbfae86cd936160f803f659c01aa583c0981dce
2 files changed
+147
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+126
@@ -17475,6 +17475,132 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17475
),
17476
);
17477
17478
+ // regression: #26082 a killed Claude process names its signal on the failed turn
17479
+ it.effect("names the signal that killed the Claude process on the failed turn", () =>
17480
+ Effect.scoped(
17481
+ Effect.gen(function* () {
17482
+ const changes = yield* makeChangeSignal;
17483
+ const fileSystem = yield* FileSystem.FileSystem;
17484
+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
17485
+ const attachmentsDir = yield* fileSystem.makeTempDirectoryScoped({
17486
+ prefix: "t3-claude-v2-process-signal-",
17487
+ });
17488
+ const sdkMessages = yield* Queue.unbounded<
17489
+ SDKMessage,
17490
+ ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError
17491
+ >();
17492
+ const events: Array<ProviderAdapter.ProviderAdapterV2Event> = [];
17493
+ const adapter = yield* ClaudeAdapterV2.makeClaudeAdapterV2({
17494
+ instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
17495
+ settings: DEFAULT_CLAUDE_SETTINGS,
17496
+ environment: {},
17497
+ attachmentsDir,
17498
+ fileSystem,
17499
+ path: yield* Path.Path,
17500
+ random: yield* SecureRandom.SecureRandom,
17501
+ idAllocator,
17502
+ queryRunner: {
17503
+ allocateSessionId: Effect.succeed(WAKE_NATIVE_SESSION),
17504
+ open: () =>
17505
+ Effect.succeed({
17506
+ messages: Stream.fromQueue(sdkMessages),
17507
+ offer: () => Effect.void,
17508
+ setModel: () => Effect.void,
17509
+ applyFlagSettings: () => Effect.void,
17510
+ setPermissionMode: () => Effect.void,
17511
+ backgroundTasks: () => Effect.succeed(false),
17512
+ mcpServerStatus: Effect.succeed([]),
17513
+ readMcpResource: () => Effect.die("unexpected MCP resource read"),
17514
+ callMcpTool: () => Effect.die("unexpected MCP tool call"),
17515
+ listPermissionRules: Effect.die("unexpected permission rules read"),
17516
+ stopTask: () => Effect.void,
17517
+ interrupt: Effect.void,
17518
+ close: Queue.shutdown(sdkMessages),
17519
+ }),
17520
+ forkSession: () => Effect.die("unused forkSession"),
17521
+ subagentLaunchToolUseId: () => Effect.succeed(null),
17522
+ assertComplete: Effect.void,
17523
+ },
17524
+ });
17525
+ const threadId = ThreadId.make("thread-claude-process-signal");
17526
+ const runtime = yield* adapter.openSession({
17527
+ threadId,
17528
+ providerSessionId: ProviderSessionId.make("provider-session-claude-process-signal"),
17529
+ modelSelection: CLAUDE_TEST_MODEL_SELECTION,
17530
+ runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
17531
+ });
17532
+ const providerThread = yield* runtime.ensureThread({
17533
+ threadId,
17534
+ modelSelection: CLAUDE_TEST_MODEL_SELECTION,
17535
+ runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
17536
+ });
17537
+ yield* runtime.events.pipe(
17538
+ Stream.runForEach((event) =>
17539
+ Effect.sync(() => {
17540
+ events.push(event);
17541
+ }).pipe(Effect.andThen(changes.notify)),
17542
+ ),
17543
+ Effect.forkScoped,
17544
+ );
17545
+ yield* runtime.startTurn(
17546
+ makeClaudeTestTurnInput({
17547
+ threadId,
17548
+ providerThread,
17549
+ now: yield* DateTime.now,
17550
+ attemptId: RunAttemptId.make("attempt-claude-process-signal"),
17551
+ text: "Write a long reply.",
17552
+ attachments: [],
17553
+ }),
17554
+ );
17555
+ yield* Queue.offer(
17556
+ sdkMessages,
17557
+ makeAssistantTextFrame({
17558
+ uuid: "00000000-0000-4000-8000-000000026082",
17559
+ text: "Here is the first part",
17560
+ }),
17561
+ );
17562
+ // Mirrors ProcessTransport.getProcessExitError in @anthropic-ai/claude-agent-sdk.
17563
+ const processExit = Object.assign(
17564
+ new Error(
17565
+ "Claude Code process terminated by signal SIGABRT. stderr: fork failed: Resource temporarily unavailable",
17566
+ ),
17567
+ {
17568
+ telemetryMessage: "Claude Code process terminated by signal SIGABRT",
17569
+ errorClass: "process_killed_by_signal",
17570
+ signal: "SIGABRT",
17571
+ },
17572
+ );
17573
+ yield* Queue.fail(
17574
+ sdkMessages,
17575
+ new ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError({
17576
+ method: "messages",
17577
+ cause: processExit,
17578
+ }),
17579
+ );
17580
+
17581
+ yield* changes.until(() => events.some((event) => event.type === "turn.terminal"));
17582
+ const terminal = events.find((event) => event.type === "turn.terminal");
17583
+ assert.equal(terminal?.status, "failed");
17584
+ if (terminal?.status !== "failed") return;
17585
+ assert.include(
17586
+ terminal.failure.message,
17587
+ "Claude Code process terminated by signal SIGABRT",
17588
+ );
17589
+ assert.notInclude(terminal.failure.message, "stderr");
17590
+ assert.equal(terminal.failure.code, "process_killed_by_signal");
17591
+ }).pipe(
17592
+ Effect.provide(
17593
+ Layer.mergeAll(
17594
+ IdAllocator.layer,
17595
+ McpProviderSessions.layer,
17596
+ NodeServices.layer,
17597
+ NodeCrypto.layer,
17598
+ ),
17599
+ ),
17600
+ ),
17601
+ ),
17602
+ );
17603
+
17604
const WORKFLOW_TASK_ID = "task-workflow-run";
17605
const WORKFLOW_TOOL_USE_ID = "toolu-workflow-run";
17606
const makeWorkflowHarnessWithOptions = (
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+21
@@ -720,6 +720,26 @@ function queryRunnerError(cause: unknown, method: string): ClaudeAgentSdkQueryRu
720
: new ClaudeAgentSdkQueryRunnerError({ cause, method });
721
}
722
723
+const CLAUDE_PROCESS_EXIT_ERROR_CLASSES: ReadonlySet<unknown> = new Set([
724
+ "process_killed_by_signal",
725
+ "process_exited_nonzero",
726
+]);
727
+
728
+// The SDK's exit Error appends Claude's stderr tail to `message`; `telemetryMessage` omits it.
729
+function claudeProcessExitFailure(
730
+ cause: Cause.Cause<ClaudeAgentSdkQueryRunnerError>,
731
+): { readonly message: string; readonly code: string } | undefined {
732
+ const error = Cause.squash(cause);
733
+ const sdkError = isClaudeAgentSdkQueryRunnerError(error) ? error.cause : error;
734
+ if (typeof sdkError !== "object" || sdkError === null) return undefined;
735
+ const { errorClass, telemetryMessage } = sdkError as Record<string, unknown>;
736
+ return typeof errorClass === "string" &&
737
+ CLAUDE_PROCESS_EXIT_ERROR_CLASSES.has(errorClass) &&
738
+ typeof telemetryMessage === "string"
739
+ ? { message: `${telemetryMessage}.`, code: errorClass }
740
+ : undefined;
741
+}
742
+
743
function closeClaudeQuery(queryRuntime: ClaudeQuery) {
744
return Effect.try({
745
try: () => queryRuntime.close(),
@@ -8471,6 +8491,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8491
: {
8492
failure: makeProviderFailure({
8493
cause: cause === undefined ? undefined : Cause.squash(cause),
8494
+ ...(cause === undefined ? {} : claudeProcessExitFailure(cause)),
8495
class: "transport_error",
8496
}),
8497
}),