The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a running Claude workflow member shows its answer so far (#20786)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 23:29 UTC
edc703b60a6b4b0800b64017004199f94de4219c
2 files changed
+122
-22
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+81
-1
@@ -12148,7 +12148,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
12148
);
12149
assert.deepEqual(
12150
threadMessages(harness.events, member?.childThreadId).map((event) => event.message.text),
12151
- ["Reply with exactly: A1"],
12151
+ ["Reply with exactly: A1", "A1 from the transcript"],
12152
);
12153
assert.isFalse(
12154
harness.events.some(
@@ -13735,6 +13735,86 @@ describe("ClaudeAdapterV2 background wake turns", () => {
13735
),
13736
);
13737
13738
+ it.effect("shows a running workflow member's answer so far from its transcript", () =>
13739
+ Effect.scoped(
13740
+ Effect.gen(function* () {
13741
+ const harness = yield* makeWorkflowHarness;
13742
+ const now = yield* DateTime.now;
13743
+ yield* harness.runtime.startTurn(
13744
+ makeClaudeTestTurnInput({
13745
+ threadId: harness.threadId,
13746
+ providerThread: harness.providerThread,
13747
+ now,
13748
+ attemptId: RunAttemptId.make("attempt-claude-workflow-live-answer"),
13749
+ text: "Run the alpha workflow.",
13750
+ attachments: [],
13751
+ }),
13752
+ );
13753
+ yield* launchWorkflow({ harness, snapshotUuid: "00000000-0000-4000-8000-000000001360" });
13754
+ const firstThreadId = workflowMemberEvents(harness.events, 1)[0]?.subagent.childThreadId;
13755
+ const assistantEvents = () =>
13756
+ threadMessages(harness.events, firstThreadId).filter(
13757
+ (event) => event.message.role === "assistant",
13758
+ );
13759
+ const transcriptPath = NodePath.join(harness.transcriptDir, "agent-a1.jsonl");
13760
+ const running = (uuid: string) => workflowSnapshot({ uuid, state: "start" });
13761
+
13762
+ yield* awaitUntil(
13763
+ () => assistantEvents().at(-1)?.message.text === "A1 from the transcript",
13764
+ "running workflow member answer so far",
13765
+ );
13766
+ assert.equal(workflowMemberEvents(harness.events, 1).at(-1)?.subagent.status, "running");
13767
+
13768
+ NodeFS.appendFileSync(
13769
+ transcriptPath,
13770
+ '{"type":"assistant","message":{"role":"assistant","id":"msg_a1_more","content":[{"type":"text","text":"A1 keeps going"}]}}\n',
13771
+ );
13772
+ yield* harness.offerAndWait(running("00000000-0000-4000-8000-000000001361"));
13773
+ assert.lengthOf(assistantEvents(), 1, "a frame inside the throttle window reads nothing");
13774
+
13775
+ yield* TestClock.adjust("10 seconds");
13776
+ yield* harness.offerAndWait(running("00000000-0000-4000-8000-000000001362"));
13777
+ assert.lengthOf(assistantEvents(), 2);
13778
+ assert.equal(
13779
+ assistantEvents().at(-1)?.message.text,
13780
+ "A1 from the transcript\n\nA1 keeps going",
13781
+ );
13782
+
13783
+ yield* TestClock.adjust("10 seconds");
13784
+ yield* harness.offerAndWait(running("00000000-0000-4000-8000-000000001363"));
13785
+ assert.lengthOf(assistantEvents(), 2, "an unchanged transcript emits nothing");
13786
+
13787
+ NodeFS.appendFileSync(
13788
+ transcriptPath,
13789
+ '{"type":"assistant","message":{"role":"assistant","id":"msg_a1_final","content":[{"type":"text","text":"A1 final"}]}}\n',
13790
+ );
13791
+ yield* harness.offerAndWait(
13792
+ workflowSnapshot({ uuid: "00000000-0000-4000-8000-000000001364", state: "done" }),
13793
+ );
13794
+ assert.equal(workflowMemberEvents(harness.events, 1).at(-1)?.subagent.status, "completed");
13795
+ assert.equal(
13796
+ assistantEvents().at(-1)?.message.text,
13797
+ "A1 from the transcript\n\nA1 keeps going\n\nA1 final",
13798
+ );
13799
+ assert.lengthOf(
13800
+ new Set(assistantEvents().map((event) => event.message.id)),
13801
+ 1,
13802
+ "the settled answer replaces the running one in place",
13803
+ );
13804
+
13805
+ yield* Queue.offer(
13806
+ harness.sdkMessages,
13807
+ makeResultFrame({ uuid: "00000000-0000-4000-8000-000000001365", result: "Done." }),
13808
+ );
13809
+ yield* Queue.take(harness.terminalReceipts);
13810
+ }).pipe(
13811
+ Effect.provide(
13812
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
13813
+ ),
13814
+ ),
13815
+ ),
13816
+ );
13817
+
13818
it.effect.each([
13819
{ backgrounding: "succeeds" },
13820
{ backgrounding: "fails" },
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+41
-21
@@ -3092,6 +3092,9 @@ function claudeSubagentModelSelection(
3092
3093
const PENDING_CLAUDE_SUBAGENT_CAP = 64;
3094
const PENDING_CLAUDE_SUBAGENT_FRAME_CAP = 256;
3095
+// Workflow progress frames arrive about every 12 seconds; a running member's
3096
+// transcript is re-read at most this often to show its answer so far.
3097
+const WORKFLOW_MEMBER_LIVE_TRANSCRIPT_READ_INTERVAL_MS = 10_000;
3098
3099
function rememberPendingClaudeSubagentLaunch(
3100
pending: Map<string, PendingClaudeSubagentLaunch>,
@@ -3422,6 +3425,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
3425
readonly attempt: number;
3426
readonly transcriptAnswerDigest: string | undefined;
3427
readonly transcriptReadAttempts: number;
3428
+ readonly liveTranscriptReadAt: DateTime.Utc | null;
3429
readonly finalTranscriptRead: boolean;
3430
readonly result: string | undefined;
3431
readonly label: string;
@@ -4525,7 +4529,19 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
4529
(input.coordinator.task.status === "running"
4530
? (restarted ? 0 : (previous?.transcriptReadAttempts ?? 0)) < 3
4531
: restarted || previous?.finalTranscriptRead !== true);
4528
- if (!changed && !readTranscript) continue;
4532
+ // A running member streams nothing, so its transcript is the only
4533
+ // way to show its answer so far. A restart shows "Retry in
4534
+ // progress." and starts a fresh throttle window before the next read.
4535
+ const liveTranscriptReadAt = previous?.liveTranscriptReadAt ?? null;
4536
+ const readLiveTranscript =
4537
+ status === "running" &&
4538
+ !restarted &&
4539
+ transcriptDir !== undefined &&
4540
+ agentId !== undefined &&
4541
+ (liveTranscriptReadAt === null ||
4542
+ DateTime.toEpochMillis(now) - DateTime.toEpochMillis(liveTranscriptReadAt) >=
4543
+ WORKFLOW_MEMBER_LIVE_TRANSCRIPT_READ_INTERVAL_MS);
4544
+ if (!changed && !readTranscript && !readLiveTranscript) continue;
4545
4546
const nodeId = idAllocator.derive.nodeFromProviderItem({
4547
driver: CLAUDE_PROVIDER,
@@ -4651,21 +4667,22 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
4667
4668
let transcriptAnswerDigest = restarted ? undefined : previous?.transcriptAnswerDigest;
4669
let transcript: ReadonlyArray<string> = [];
4654
- if (settled) {
4655
- transcript = readTranscript
4656
- ? yield* readWorkflowAgentAnswers({
4657
- transcriptDir,
4658
- agentId,
4659
- ...(adapterOptions.environment.CLAUDE_CONFIG_DIR === undefined
4660
- ? {}
4661
- : {
4662
- configDir: path.resolve(
4663
- session.cwd,
4664
- adapterOptions.environment.CLAUDE_CONFIG_DIR,
4665
- ),
4666
- }),
4667
- }).pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []))
4668
- : [];
4670
+ if (settled || readLiveTranscript) {
4671
+ transcript =
4672
+ readTranscript || readLiveTranscript
4673
+ ? yield* readWorkflowAgentAnswers({
4674
+ transcriptDir,
4675
+ agentId,
4676
+ ...(adapterOptions.environment.CLAUDE_CONFIG_DIR === undefined
4677
+ ? {}
4678
+ : {
4679
+ configDir: path.resolve(
4680
+ session.cwd,
4681
+ adapterOptions.environment.CLAUDE_CONFIG_DIR,
4682
+ ),
4683
+ }),
4684
+ }).pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []))
4685
+ : [];
4686
const transcriptAnswer = transcript.length > 0 ? transcript.join("\n\n") : undefined;
4687
const answerDigest =
4688
transcriptAnswer === undefined
@@ -4677,11 +4694,13 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
4694
if (answerDigest !== undefined) transcriptAnswerDigest = answerDigest;
4695
const answer =
4696
transcriptAnswer ??
4680
- (member.result !== undefined && changed && previousDigest === undefined
4681
- ? `Partial answer from workflow progress:\n\n${member.result}`
4682
- : attempt > 1 && changed && previousDigest === undefined
4683
- ? "No answer from this workflow attempt."
4684
- : undefined);
4697
+ (!settled
4698
+ ? undefined
4699
+ : member.result !== undefined && changed && previousDigest === undefined
4700
+ ? `Partial answer from workflow progress:\n\n${member.result}`
4701
+ : attempt > 1 && changed && previousDigest === undefined
4702
+ ? "No answer from this workflow attempt."
4703
+ : undefined);
4704
if (
4705
answer !== undefined &&
4706
(transcriptAnswer === undefined || restarted || answerDigest !== previousDigest)
@@ -4710,6 +4729,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
4729
transcriptReadAttempts:
4730
(restarted ? 0 : (previous?.transcriptReadAttempts ?? 0)) +
4731
(readTranscript ? 1 : 0),
4732
+ liveTranscriptReadAt: readLiveTranscript || restarted ? now : liveTranscriptReadAt,
4733
finalTranscriptRead:
4734
(!restarted && previous?.finalTranscriptRead === true) ||
4735
(readTranscript &&