Skip to content

Commit 4f8b6ee

Browse files
henrychu04claude
andauthored
fix(server): foreground Claude forks no longer show as finished the moment they start (#26459)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent b46a4ed commit 4f8b6ee

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12946,6 +12946,67 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1294612946
),
1294712947
);
1294812948

12949+
it.effect("keeps a foreground fork running past the placeholder result for its own launch", () =>
12950+
Effect.scoped(
12951+
Effect.gen(function* () {
12952+
const harness = yield* makeWakeHarness;
12953+
yield* harness.runtime.startTurn(
12954+
makeClaudeTestTurnInput({
12955+
threadId: harness.threadId,
12956+
providerThread: harness.providerThread,
12957+
now: yield* DateTime.now,
12958+
attemptId: RunAttemptId.make("attempt-claude-foreground-fork"),
12959+
text: "Fork this.",
12960+
attachments: [],
12961+
}),
12962+
);
12963+
yield* harness.offerAndWait(
12964+
makeSubagentTaskStartedFrame({
12965+
taskId: "agent-fork",
12966+
toolUseId: "toolu-fork",
12967+
uuid: "00000000-0000-4000-8000-000000000901",
12968+
}),
12969+
);
12970+
// Claude Code opens a foreground fork's own stream with a placeholder result for its launch.
12971+
yield* harness.offerAndWait(
12972+
claudeSdkFrame({
12973+
type: "user",
12974+
message: {
12975+
role: "user",
12976+
content: [
12977+
{
12978+
type: "tool_result",
12979+
tool_use_id: "toolu-fork",
12980+
content: "Fork started — that fork is you.",
12981+
},
12982+
],
12983+
},
12984+
parent_tool_use_id: "toolu-fork",
12985+
uuid: "00000000-0000-4000-8000-000000000902",
12986+
session_id: WAKE_NATIVE_SESSION,
12987+
}),
12988+
);
12989+
yield* harness.offerAndWait(
12990+
makeSubagentNotificationFrame({
12991+
taskId: "agent-fork",
12992+
toolUseId: "toolu-fork",
12993+
summary: "FORK-DONE",
12994+
uuid: "00000000-0000-4000-8000-000000000903",
12995+
}),
12996+
);
12997+
let settled = yield* Queue.take(harness.subagentReceipts);
12998+
while (settled.subagent.status === "running") {
12999+
settled = yield* Queue.take(harness.subagentReceipts);
13000+
}
13001+
assert.equal(settled.subagent.result, "FORK-DONE");
13002+
}).pipe(
13003+
Effect.provide(
13004+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
13005+
),
13006+
),
13007+
),
13008+
);
13009+
1294913010
it.effect("releases the idle pin when a post-settle subagent stops without completing", () =>
1295013011
Effect.scoped(
1295113012
Effect.gen(function* () {

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9094,6 +9094,8 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
90949094
}
90959095

90969096
for (const { toolResult, output } of claudeToolResultEntriesFromMessage(message)) {
9097+
// A foreground fork's stream opens with a placeholder result for its own launch call.
9098+
if (parentToolUseIdFromSdkMessage(message) === toolResult.tool_use_id) continue;
90979099
const subagent = yield* resolveSubagentByToolUseId(context, toolResult.tool_use_id);
90989100
const runHandles = parseClaudeWorkflowRunHandles(claudeNativeToolOutputValue(output));
90999101
if (subagent !== undefined && runHandles !== undefined) {

0 commit comments

Comments
 (0)