@@ -17475,6 +17475,132 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1747517475 ),
1747617476 );
1747717477
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+
1747817604 const WORKFLOW_TASK_ID = "task-workflow-run";
1747917605 const WORKFLOW_TOOL_USE_ID = "toolu-workflow-run";
1748017606 const makeWorkflowHarnessWithOptions = (
0 commit comments