The best way to control Claude Code, Codex and more from any computer or phone
fix(server): keep queued Claude workflow members pending (#25325)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 12:01 UTC
3cfbc3607b81035fa0873ec3c8ea5c3c8d659c48
3 files changed
+42
-8
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+7
-1
@@ -18217,7 +18217,10 @@ describe("ClaudeAdapterV2 background wake turns", () => {
18217
phaseTitle: "Alpha",
18218
model: input.model ?? "claude-opus-5[1m]",
18219
promptPreview: input.prompt ?? "Reply with exactly: A1",
18220
- ...(input.startedAt === undefined ? {} : { startedAt: input.startedAt }),
18220
+ // Claude reports a scheduled member as `start` and only sets startedAt once it runs.
18221
+ ...(input.startedAt === undefined && input.state !== "start"
18222
+ ? {}
18223
+ : { startedAt: input.startedAt ?? 0 }),
18224
...(input.lastProgressAt === undefined ? {} : { lastProgressAt: input.lastProgressAt }),
18225
...(input.durationMs === undefined ? {} : { durationMs: input.durationMs }),
18226
...(input.attempt === undefined ? {} : { attempt: input.attempt }),
@@ -18234,6 +18237,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
18237
phaseIndex: 1,
18238
phaseTitle: "Alpha",
18239
promptPreview: "Reply with exactly: A2",
18240
+ ...((input.secondState ?? input.state) === "start" ? { startedAt: 0 } : {}),
18241
...(input.state === "done" ? { resultPreview: "A2 excerpt" } : {}),
18242
},
18243
],
@@ -18727,6 +18731,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
18731
uuid: "00000000-0000-4000-8000-000000001005",
18732
state: "start",
18733
secondState: "queued",
18734
+ startedAt: DateTime.toEpochMillis(memberStartedAt),
18735
}),
18736
);
18737
yield* harness.until(() => coordinatorTurnItems().length > turnItemsBeforeRepeat);
@@ -18750,6 +18755,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
18755
uuid: "00000000-0000-4000-8000-000000001017",
18756
state: "start",
18757
secondState: "queued",
18758
+ startedAt: DateTime.toEpochMillis(memberStartedAt),
18759
label: "alpha:review",
18760
prompt: "Review the change",
18761
model: "claude-sonnet-4-6",
apps/server/src/orchestration-v2/Adapters/claudeWorkflowProgress.test.ts
+26
-3
@@ -74,6 +74,19 @@ describe("mergeClaudeWorkflowProgress", () => {
74
expect(workflow?.agents[2]).not.toHaveProperty("completedAt");
75
});
76
77
+ it("keeps a started member queued until the provider reports its startedAt", () => {
78
+ const scheduled = mergeClaudeWorkflowProgress({
79
+ previous: undefined,
80
+ message: snapshotFrame([agent({ state: "start", queuedAt: 1000 })]),
81
+ });
82
+ expect(scheduled?.agents[0]?.state).toBe("queued");
83
+ const started = mergeClaudeWorkflowProgress({
84
+ previous: scheduled,
85
+ message: snapshotFrame([agent({ state: "start", queuedAt: 1000, startedAt: 21_000 })]),
86
+ });
87
+ expect(started?.agents[0]).toMatchObject({ state: "running", startedAt: 21_000 });
88
+ });
89
+
90
it.each(["something-new", "toString", "constructor", "__proto__"])(
91
"treats unrecognised state %s as still running rather than settled",
92
(state) => {
@@ -133,7 +146,14 @@ describe("mergeClaudeWorkflowProgress", () => {
146
agents: first.agents.map((member) => ({ ...member, effort: "max", speed: "standard" })),
147
},
148
message: snapshotFrame([
136
- { type: "workflow_agent", index: 1, label: "alpha:one", state: "start", attempt: 2 },
149
+ {
150
+ type: "workflow_agent",
151
+ index: 1,
152
+ label: "alpha:one",
153
+ state: "start",
154
+ attempt: 2,
155
+ startedAt: 3000,
156
+ },
157
]),
158
});
159
expect(second?.agents).toEqual([
@@ -142,6 +162,7 @@ describe("mergeClaudeWorkflowProgress", () => {
162
label: "alpha:one",
163
state: "running",
164
attempt: 2,
165
+ startedAt: 3000,
166
phaseIndex: 1,
167
phaseTitle: "Alpha",
168
},
@@ -171,12 +192,14 @@ describe("mergeClaudeWorkflowProgress", () => {
192
])("keeps member state when the same attempt regresses from %s to %s", (state, staleState) => {
193
const first = mergeClaudeWorkflowProgress({
194
previous: undefined,
174
- message: snapshotFrame([agent({ state, attempt: 2, resultPreview: "Current result" })]),
195
+ message: snapshotFrame([
196
+ agent({ state, attempt: 2, startedAt: 1010, resultPreview: "Current result" }),
197
+ ]),
198
});
199
const second = mergeClaudeWorkflowProgress({
200
previous: first,
201
message: snapshotFrame([
179
- agent({ state: staleState, attempt: 2, resultPreview: "Old result" }),
202
+ agent({ state: staleState, attempt: 2, startedAt: 1010, resultPreview: "Old result" }),
203
]),
204
});
205
expect(second?.agents).toEqual(first?.agents);
apps/server/src/orchestration-v2/Adapters/claudeWorkflowProgress.ts
+9
-4
@@ -53,9 +53,14 @@ function parseAgent(entry: unknown): OrchestrationV2WorkflowAgent | null {
53
const label = text(field(entry, "label"));
54
if (index === undefined || label === undefined) return null;
55
const reportedState = text(field(entry, "state")) ?? "";
56
- const state = Object.hasOwn(AGENT_STATES, reportedState)
57
- ? (AGENT_STATES[reportedState] ?? "running")
58
- : "running";
56
+ const startedAt = timestamp(field(entry, "startedAt"));
57
+ // Claude marks members `start` when scheduled; they only run once a concurrency slot sets startedAt.
58
+ const state =
59
+ reportedState === "start" && startedAt === undefined
60
+ ? "queued"
61
+ : Object.hasOwn(AGENT_STATES, reportedState)
62
+ ? (AGENT_STATES[reportedState] ?? "running")
63
+ : "running";
64
return {
65
index,
66
label,
@@ -69,7 +74,7 @@ function parseAgent(entry: unknown): OrchestrationV2WorkflowAgent | null {
74
...optional("toolCalls", count(field(entry, "toolCalls"))),
75
...optional("durationMs", count(field(entry, "durationMs"))),
76
...optional("queuedAt", timestamp(field(entry, "queuedAt"))),
72
- ...optional("startedAt", timestamp(field(entry, "startedAt"))),
77
+ ...optional("startedAt", startedAt),
78
// Execution duration excludes startup waits; terminal progress carries the end instant.
79
...optional(
80
"completedAt",