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
3 changes: 3 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6938,6 +6938,9 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV
) {
context.promptSettled = true;
context.promptSettledStatus = status;
// The agent finished this prompt's reply. Background work
// holds the run open, not the text it already sent.
yield* closeTextStreams(context);
return;
}
yield* finalizeTurn(context, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ export function assertGrokBackgroundSubagentOutput(
assert.isAbove(rootCompletedAt, subagentCompletedAt, "run 1 completed before the subagent");
assert.include(runAssistantTexts(projection, rootRun?.id), "ROOT_DONE");

// Grok ends ROOT_DONE with its prompt; the subagent running on must not keep
// the reply streaming.
const rootDoneCompletedAt = result.domainEvents.findIndex(
(event) =>
event.type === "turn-item.updated" &&
event.payload.runId === rootRun?.id &&
event.payload.type === "assistant_message" &&
event.payload.text.trim() === "ROOT_DONE" &&
event.payload.status === "completed",
);
assert.isAtLeast(rootDoneCompletedAt, 0);
assert.isBelow(
rootDoneCompletedAt,
subagentCompletedAt,
"ROOT_DONE streamed until the subagent finished",
);

// The subagent's own reply stays in its child thread.
if (subagent?.childThreadId == null) {
throw new Error("The background subagent is missing its child thread.");
Expand Down
Loading