fix(orchestration-v2): address subagent observability review findings
- Treat pending/waiting workflow agents as active in the session-registry write guard and wake-buffer pre-open, so concurrent active transitions are not dropped and wake task_started cannot force a false resume. - Preserve the first-recorded activation completion time on duplicate terminal frames (Claude in-place update and ACP rebuilt emits). - Let a blocked/waiting first snapshot of a new attempt reopen a settled workflow agent entry instead of silently dropping its status and usage. - Settle still-active workflow members when their coordinator terminalizes, and expect the Implementer completed in claude_workflow. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
9c888b6b18
commit
bcbab62dc1
3 files changed
+52
-13
No files matched your search
@@ -2285,7 +2285,9 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
|
||||
status: taskStatus,
|
||||
usage: null,
|
||||
startedAt: subagent.task.startedAt,
|
||||
completedAt: settled ? now : null,
|
||||
// Keep the activation aligned with the subagent record instead
|
||||
// of re-stamping the completion time on rebuilt emits.
|
||||
completedAt: settled ? (subagent.task.completedAt ?? now) : null,
|
||||
updatedAt: now,
|
||||
} satisfies OrchestrationV2SubagentActivation,
|
||||
});
|
||||
|
||||
@@ -2550,7 +2550,9 @@ export function makeClaudeAdapterV2(
|
||||
...existingSubagent.activation,
|
||||
status: input.status,
|
||||
usage: mergeCumulativeSubagentUsage(existingSubagent.activation.usage, input.usage),
|
||||
completedAt: settled ? now : null,
|
||||
// A duplicate terminal frame must not re-stamp the completion
|
||||
// time the first terminal frame recorded.
|
||||
completedAt: settled ? (existingSubagent.activation.completedAt ?? now) : null,
|
||||
updatedAt: now,
|
||||
} satisfies OrchestrationV2SubagentActivation);
|
||||
task.currentActivationId = settled ? null : activation.id;
|
||||
@@ -2586,9 +2588,13 @@ export function makeClaudeAdapterV2(
|
||||
// re-open must not clobber its result.
|
||||
yield* Ref.update(sessionSubagentsByTaskId, (current) => {
|
||||
const registered = current.get(input.taskId);
|
||||
if (
|
||||
const registeredSettled =
|
||||
registered !== undefined &&
|
||||
registered.task.status !== "running" &&
|
||||
(registered.task.status === "completed" ||
|
||||
registered.task.status === "failed" ||
|
||||
registered.task.status === "cancelled");
|
||||
if (
|
||||
registeredSettled &&
|
||||
activeStart &&
|
||||
!(isReopen && registered === existingSubagent)
|
||||
) {
|
||||
@@ -3296,7 +3302,12 @@ export function makeClaudeAdapterV2(
|
||||
const now = yield* DateTime.now;
|
||||
yield* Ref.update(sessionSubagentsByTaskId, (current) => {
|
||||
const registered = current.get(message.task_id);
|
||||
if (registered === undefined || registered.task.status === "running") {
|
||||
if (
|
||||
registered === undefined ||
|
||||
registered.task.status === "running" ||
|
||||
registered.task.status === "pending" ||
|
||||
registered.task.status === "waiting"
|
||||
) {
|
||||
return current;
|
||||
}
|
||||
const { progress: _staleProgress, ...priorTask } = registered.task;
|
||||
@@ -3547,7 +3558,8 @@ export function makeClaudeAdapterV2(
|
||||
const existingWorker =
|
||||
context.subagentsByTaskId.get(workerTaskId) ??
|
||||
(yield* Ref.get(sessionSubagentsByTaskId)).get(workerTaskId);
|
||||
const activeWorker = status === "pending" || status === "running";
|
||||
const activeWorker =
|
||||
status === "pending" || status === "running" || status === "waiting";
|
||||
const reopen =
|
||||
activeWorker &&
|
||||
existingWorker !== undefined &&
|
||||
@@ -3587,19 +3599,44 @@ export function makeClaudeAdapterV2(
|
||||
const wasBackgroundTask = yield* clearPendingBackgroundTask(message.task_id);
|
||||
if (!wasBackgroundTask && !context.ignoredTaskIds.has(message.task_id)) {
|
||||
const usage = claudeSubagentUsage(message.usage);
|
||||
const terminalStatus =
|
||||
message.status === "completed"
|
||||
? ("completed" as const)
|
||||
: message.status === "stopped"
|
||||
? ("cancelled" as const)
|
||||
: ("failed" as const);
|
||||
yield* updateClaudeSubagentNode({
|
||||
context,
|
||||
taskId: message.task_id,
|
||||
...(message.tool_use_id === undefined ? {} : { toolUseId: message.tool_use_id }),
|
||||
result: message.summary,
|
||||
...(usage === undefined ? {} : { usage }),
|
||||
status:
|
||||
message.status === "completed"
|
||||
? "completed"
|
||||
: message.status === "stopped"
|
||||
? "cancelled"
|
||||
: "failed",
|
||||
status: terminalStatus,
|
||||
});
|
||||
// Workflow members only ever settle through workflow snapshots;
|
||||
// once the coordinator terminalizes, any member left active
|
||||
// would stay "running" forever, so settle it alongside.
|
||||
const workerPrefix = `${message.task_id}:workflow:`;
|
||||
const registeredWorkers = new Map([
|
||||
...(yield* Ref.get(sessionSubagentsByTaskId)),
|
||||
...context.subagentsByTaskId,
|
||||
]);
|
||||
for (const [workerTaskId, worker] of registeredWorkers) {
|
||||
if (!workerTaskId.startsWith(workerPrefix)) continue;
|
||||
const workerStatus = worker.task.status;
|
||||
if (
|
||||
workerStatus !== "pending" &&
|
||||
workerStatus !== "running" &&
|
||||
workerStatus !== "waiting"
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
yield* updateClaudeSubagentNode({
|
||||
context,
|
||||
taskId: workerTaskId,
|
||||
status: terminalStatus,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export function assertClaudeWorkflowOutput(
|
||||
]),
|
||||
[
|
||||
["Researcher", "completed", 0, "claude-sonnet-4-6", 400],
|
||||
["Implementer", "running", 1, "claude-opus-4-1", 500],
|
||||
["Implementer", "completed", 1, "claude-opus-4-1", 500],
|
||||
],
|
||||
);
|
||||
// Membership must point at the coordinator that actually reached the
|
||||
|
||||
Reference in new issue
Block a user