Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6185,6 +6185,12 @@ describe("CodexAdapterV2 post-settle continuation", () => {
);
assert.equal(childCommandUpdates.at(-1)?.turnItem.status, "interrupted");
assert.equal(harness.subagentUpdates().at(-1)?.subagent.status, "interrupted");
assert.isDefined(
harness
.subagentUpdates()
.find((event) => event.subagent.status === "running" && event.subagent.progress),
"a running native subagent reports its child's current command as progress",
);
assertChildProviderTerminalBeforeRoot(harness.events, harness.threadId);
assert.isFalse(yield* harness.hasPendingBackgroundWork);
}).pipe(
Expand Down
30 changes: 29 additions & 1 deletion apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2727,9 +2727,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
readonly completedAt?: DateTime.Utc | null;
readonly startedAt?: DateTime.Utc;
readonly reopen?: boolean;
readonly progress?: string;
}) {
const now = yield* DateTime.now;
const prior = input.subagent.task;
const prior = input.reopen
? (({ progress: _staleProgress, ...rest }) => rest)(input.subagent.task)
: input.subagent.task;
const settled = !isOrchestrationV2WorkActive(prior.status);
// Late snapshots must not reopen completed children; only new turns may.
if (settled && isOrchestrationV2WorkActive(input.status) && !input.reopen) return;
Expand All @@ -2747,6 +2750,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
}
: {}),
startedAt: input.startedAt ?? prior.startedAt,
...(input.progress === undefined ? {} : { progress: input.progress }),
result: input.result === undefined ? input.subagent.task.result : input.result,
completedAt,
updatedAt: now,
Expand Down Expand Up @@ -2784,11 +2788,28 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
providerInstanceId: task.providerInstanceId,
childThreadId: task.childThreadId,
prompt: task.prompt,
...(task.progress === undefined ? {} : { progress: task.progress }),
result: task.result,
},
});
});

// A native child's running item is the line its parent's subagent row shows.
const reportSubagentProgress =
/* Provider events include streaming deltas; avoid a span for each update. */
Effect.fnUntraced(function* (context: ActiveCodexTurnContext, progress: string | null) {
const subagent = context.subagent;
const line = progress?.trim();
if (subagent === null || !line) return;
if (!isOrchestrationV2WorkActive(subagent.task.status)) return;
if (subagent.task.progress === line) return;
yield* emitSubagentTaskUpdate({
subagent,
status: subagent.task.status,
progress: line,
});
});

const emitSubagentProviderTurnStarted =
/* Provider events include streaming deltas; avoid a span for each update. */
Effect.fnUntraced(function* (
Expand Down Expand Up @@ -5194,6 +5215,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
driver: CODEX_PROVIDER,
turnItem: artifacts.turnItem,
});
yield* reportSubagentProgress(context, payload.item.command);
return;
}

Expand All @@ -5212,6 +5234,12 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
driver: CODEX_PROVIDER,
turnItem: artifacts.turnItem,
});
if (artifacts.turnItem.type === "dynamic_tool") {
yield* reportSubagentProgress(
context,
artifacts.turnItem.title ?? artifacts.turnItem.toolName,
);
}
return;
}

Expand Down
Loading