From ac3dc22a5e3eb204666513c721eedc7a9da8f5a0 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 12 Jul 2026 07:12:28 +0200 Subject: [PATCH] Flush throttled subagent text in ACP finalizeTurn After the turn ends the run fiber that routes child-thread events may be gone, so text left to the coalescer's timer flush could drop the tail of a subagent stream (cursor bugbot review finding on the coalescer). Co-Authored-By: Claude Fable 5 --- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts index 318f4cdc79..f67fa61a56 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts @@ -2054,6 +2054,14 @@ export function makeAcpAdapterV2(options: AcpAdapterV2Options): ProviderAdapterV if (context.finalized) return; context.finalized = true; yield* closeTextStreams(context); + // Persist any throttled subagent text now: after the turn ends the + // run fiber that routes child-thread events may be gone, so waiting + // for the coalescer's timer flush could drop the tail of a stream. + for (const subagent of context.subagents.values()) { + if (subagent.streamPendingText) { + yield* flushSubagentAssistant(subagent); + } + } const now = yield* DateTime.now; const turn = providerTurnPayload(context, status, now); yield* Ref.update(providerTurns, (current) => {