fix(antigravity): subagent threads project thinking, tools, and replies into the normal timeline #43491
MergedLoxofy(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/43491/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
Loxofy(GitHub profile, opens in a new tab) linked this to fix #40550
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
juliusmarminge added labelstakeover:in-progress
- @@ -2437,0 +2512,21 @@2512+ {2513+ step_index: 3,2514+ type: "GENERIC",2515+ status: "DONE",2516+ content: "Updated README.md",2517+ },2518+ ]);2519+2520+ const { usage, send, startTurn, until, throughPromptSettled } =2521+ yield* openSessionWithRunningCommand({}, profile);2522+ yield* startTurn(1, false);2523+ const promptEvents = yield* throughPromptSettled;2524+2525+ const childThread = promptEvents.find((event) => event.type === "app_thread.created");2526+ assert.isDefined(childThread);2527+ const childThreadId =2528+ childThread?.type === "app_thread.created" ? childThread.appThread.id : undefined;2529+ assert.isDefined(childThreadId);2530+2531+ // Give the live transcript follower a poll tick while the subagent is still running.2532+ yield* TestClock.adjust("1 second");@@ -369,0 +690,21 @@690+ title: toolSummary ?? name,691+ data: {692+ ...(sanitizedInput === undefined ? {} : { rawInput: sanitizedInput }),693+ ...(boundedOutput === undefined ? {} : { rawOutput: boundedOutput }),694+ ...(url === undefined ? {} : { locations: [{ path: url }] }),695+ },696+ },697+ };698+ }699+700+ const title = name.startsWith("mcp_") ? `Run ${name}` : (toolSummary ?? name);701+ return {702+ projectedStatus,703+ toolCall: {704+ toolCallId: input.toolCallId,705+ kind: "other",706+ status,707+ title,708+ data: {709+ ...(sanitizedInput === undefined ? {} : { rawInput: sanitizedInput }),710+ ...(boundedOutput === undefined ? {} : { rawOutput: boundedOutput }),@@ -484,0 +1004,21 @@1004+ profileRoot: string,1005+ input: {1006+ readonly rootSessionId: string;1007+ readonly nativeTaskId: string;1008+ readonly childSessionId?: string | null | undefined;1009+ readonly launch: BatchLaunch;1010+ readonly siblings: ReadonlyArray<BatchLaunch & { readonly nativeTaskId: string }>;1011+ },1012+): Promise<InvokeRecord | undefined> {1013+ const detached = await findDetachedInvokeRecord(1014+ profileRoot,1015+ input.rootSessionId,1016+ input.nativeTaskId,1017+ );1018+ if (detached !== undefined) return detached;1019+ if (input.childSessionId != null && NATIVE_ID.test(input.childSessionId)) {1020+ return {1021+ toolCallId: input.nativeTaskId,1022+ launches: [{ role: input.launch.title ?? "", prompt: input.launch.prompt }],1023+ children: [{ conversationId: input.childSessionId }],1024+ };@@ -484,0 +1079,21 @@1079+ finalize: input.finalize,1080+ });1081+ }),1082+ );1083+ const flattened = perChild.flat();1084+ if (!multiChild) return flattened;1085+ return flattened1086+ .map((entry, position) => ({ entry, position }))1087+ .sort((left, right) => {1088+ const leftMs =1089+ left.entry.createdAt === undefined1090+ ? undefined1091+ : DateTime.toEpochMillis(left.entry.createdAt);1092+ const rightMs =1093+ right.entry.createdAt === undefined1094+ ? undefined1095+ : DateTime.toEpochMillis(right.entry.createdAt);1096+ if (leftMs !== undefined && rightMs !== undefined && leftMs !== rightMs) {1097+ return leftMs - rightMs;1098+ }1099+ return left.position - right.position;@@ -3862,3 +4141,14 @@38624141 }38634142 });386441434144+ const projectSubagentTranscriptEntry = Effect.fnUntraced(function* (4145+ subagent: ActiveAcpSubagent,4146+ entry: AcpSubagentTranscriptEntry,4147+ ) {4148+ const fingerprint = acpSubagentTranscriptEntryFingerprint(entry);4149+ if (subagent.transcriptEntryFingerprints.get(entry.itemId) === fingerprint) {4150+ return false;4151+ }4152+ subagent.transcriptEntryFingerprints.set(entry.itemId, fingerprint);4153+ const nativeTaskId = subagent.task.nativeTaskRef?.nativeId ?? String(subagent.task.id);4154+ const nativeItemId = `${nativeTaskId}:transcript:${entry.itemId}`;@@ -3864,0 +4411,21 @@4411+ Effect.gen(function* () {4412+ const nativeTaskId =4413+ subagent.task.nativeTaskRef?.nativeId ?? String(subagent.task.id);4414+ const siblings = yield* subagentSiblings(subagent);4415+ const entries = yield* readTranscript({4416+ sessionId: subagent.rootSessionId,4417+ nativeTaskId,4418+ childSessionId: subagent.childSessionId,4419+ launch: { title: subagent.task.title, prompt: subagent.task.prompt },4420+ siblings,4421+ finalize,4422+ }).pipe(4423+ Effect.catchCause(() =>4424+ Effect.succeed([] as ReadonlyArray<AcpSubagentTranscriptEntry>),4425+ ),4426+ );4427+ let changed = false;4428+ const seenIds = new Set<string>();4429+ for (const entry of entries) {4430+ seenIds.add(entry.itemId);4431+ if (yield* projectSubagentTranscriptEntry(subagent, entry)) {@@ -3864,0 +4429,21 @@4429+ for (const entry of entries) {4430+ seenIds.add(entry.itemId);4431+ if (yield* projectSubagentTranscriptEntry(subagent, entry)) {4432+ changed = true;4433+ }4434+ }4435+ if (entries.length > 0) {4436+ subagent.lastTranscriptEntryKind = entries.at(-1)?.kind;4437+ }4438+ if (finalize && subagent.transcriptOpenEntries.size > 0) {4439+ // Settle open entries that scrolled out of the transcript tail cap before finishing.4440+ for (const [itemId, openEntry] of subagent.transcriptOpenEntries) {4441+ if (seenIds.has(itemId)) continue;4442+ const settled: AcpSubagentTranscriptEntry =4443+ openEntry.kind === "reasoning"4444+ ? { ...openEntry, status: "completed" }4445+ : openEntry.kind === "tool"4446+ ? {4447+ ...openEntry,4448+ toolCall: { ...openEntry.toolCall, status: "completed" },4449+ projectedStatus: undefined,@@ -3864,0 +4482,21 @@4482+ (subagent.task.status !== "idle" && subagent.task.status !== "completed") ||4483+ subagent.lastTranscriptEntryKind === "assistant_message"4484+ ) {4485+ return;4486+ }4487+ subagent.transcriptTrailingDrainStarted = true;4488+ const stop = yield* Deferred.make<void>();4489+ subagent.transcriptTrailingDrainStop = stop;4490+ yield* Effect.gen(function* () {4491+ for (const pollMs of ACP_SUBAGENT_TRAILING_DRAIN_POLL_MS) {4492+ const stopped = yield* Deferred.await(stop).pipe(4493+ Effect.as(true),4494+ Effect.timeoutOrElse({4495+ duration: Duration.millis(pollMs),4496+ orElse: () => Effect.succeed(false),4497+ }),4498+ );4499+ if (stopped) break;4500+ if (subagent.task.status !== "idle" && subagent.task.status !== "completed") break;4501+ const changed = yield* drainSubagentTranscript(subagent, true);4502+ if (changed && subagent.task.result === null && subagent.assistantText.length > 0) {@@ -4153,3 +4853,5 @@41534853 });41544854 if (acpSubagentStatusIsTerminal(taskStatus)) {41554855 subagent.terminalStatusProjected = true;4856+ yield* startSubagentTrailingTranscriptDrain(subagent);4857+ } else {
Pushed3862bb8
Pushedfecacb9
- @@ -484,0 +1057,21 @@1057+ const read = async (): Promise<ReadonlyArray<AcpSubagentTranscriptEntry>> => {1058+ const profileRoot = await antigravityProfileRoot(input.profileDirectory);1059+ if (profileRoot === undefined) return [];1060+ const record = await resolveAntigravityInvokeRecord(profileRoot, input);1061+ if (record === undefined) return [];1062+ const { launches, children } = record;1063+ const byteCap = Math.min(1064+ TRANSCRIPT_BYTE_CAP,1065+ Math.floor(BATCH_TRANSCRIPT_BYTES / Math.max(1, children.length)),1066+ );1067+ const multiChild = children.length > 1;1068+ const perChild = await Promise.all(1069+ children.map(async (child, index) => {1070+ const raw = await readChildTranscriptRaw(profileRoot, child, byteCap).catch(1071+ () => undefined,1072+ );1073+ if (raw === undefined || raw.contents.length === 0) return [];1074+ const launch = launches[index];1075+ return transcriptToSubagentEntries(raw.contents, {1076+ prompt: launch?.prompt ?? input.launch.prompt,1077+ childPrefix: multiChild ? `${child.conversationId}:` : "",@@ -3864,0 +4463,21 @@4463+ const stopSubagentTranscriptFollower = Effect.fnUntraced(function* (4464+ subagent: ActiveAcpSubagent,4465+ ) {4466+ const stop = subagent.transcriptFollowerStop;4467+ if (stop !== undefined) {4468+ yield* Deferred.succeed(stop, undefined).pipe(Effect.ignore);4469+ }4470+ const trailingStop = subagent.transcriptTrailingDrainStop;4471+ if (trailingStop !== undefined) {4472+ yield* Deferred.succeed(trailingStop, undefined).pipe(Effect.ignore);4473+ }4474+ });4475+4476+ const startSubagentTrailingTranscriptDrain = Effect.fnUntraced(function* (4477+ subagent: ActiveAcpSubagent,4478+ ) {4479+ if (4480+ flavor.readSubagentTranscript === undefined ||4481+ subagent.transcriptTrailingDrainStarted ||4482+ (subagent.task.status !== "idle" && subagent.task.status !== "completed") ||4483+ subagent.lastTranscriptEntryKind === "assistant_message"
Pusheda0325c7
Pushed1bac430
- @@ -3864,0 +4472,21 @@4472+ const trailingStop = subagent.transcriptTrailingDrainStop;4473+ if (trailingStop !== undefined) {4474+ yield* Deferred.succeed(trailingStop, undefined).pipe(Effect.ignore);4475+ }4476+ });4477+4478+ // Starts before the terminal status is emitted, so the run never sees it without this drain pending.4479+ const startSubagentTrailingTranscriptDrain = Effect.fnUntraced(function* (4480+ subagent: ActiveAcpSubagent,4481+ status: OrchestrationV2Subagent["status"],4482+ ) {4483+ if (4484+ flavor.readSubagentTranscript === undefined ||4485+ subagent.transcriptTrailingDrainStarted ||4486+ (status !== "idle" && status !== "completed") ||4487+ subagent.lastTranscriptEntryKind === "assistant_message"4488+ ) {4489+ return;4490+ }4491+ subagent.transcriptTrailingDrainStarted = true;4492+ trailingTranscriptDrains.add(subagent);@@ -10431,3 +11023,5 @@1043111023 const canReportBackgroundWork =1043211024 continuationRequests !== undefined &&1043311025 (flavor.followAgentWorkState === true || Boolean(flavor.enablePostSettleContinuation));11026+ const sessionHasPendingBackgroundWork = Effect.gen(function* () {11027+ if (!postSettleContinuationEnabled && !followsAgentWorkState) return false;
- @@ -3864,0 +4535,21 @@4535+ Effect.ignoreCause,4536+ // Re-emitting the settled subagent makes the run re-check its pending work.4537+ Effect.ensuring(4538+ Effect.suspend(() => {4539+ trailingTranscriptDrains.delete(subagent);4540+ return emitProviderEvent({4541+ type: "subagent.updated",4542+ driver,4543+ subagent: subagent.task,4544+ });4545+ }).pipe(Effect.ignoreCause),4546+ ),4547+ Effect.forkIn(sessionScope),4548+ );4549+ });4550+4551+ const startSubagentTranscriptFollower = Effect.fnUntraced(function* (4552+ subagent: ActiveAcpSubagent,4553+ ) {4554+ if (flavor.readSubagentTranscript === undefined || subagent.transcriptFollowerStarted) {4555+ return;
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged this8bf40d6
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.




Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
Walkthrough
Antigravity child transcripts are decoded into ACP entries and projected into child-thread events. The adapter polls active subagents, drains transcripts at terminal states, and can capture a late assistant reply.
Changes: Antigravity subagent transcript projection
packages/provider-acp/src/server/adapter.tsapps/server/src/provider/acp/AntigravityChildWork.ts,apps/server/src/provider/acp/AntigravityChildWork.test.tsapps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts,packages/provider-acp/src/server/adapter.tsEstimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Possibly related PRs
AntigravityChildWorkand use child identity and lifecycle information.Suggested labels:
bugfixSuggested reviewers:
juliusmarminge,yash-singh1,helmipraditaMerge Risk:
Moderate · up to
1bac4Antigravity subagent threads should now show live work and the closing reply. In some cases, such as late replies after the root run settles, batch children with delayed replies, or children that run again, the timeline can miss late items or stop updating live. The fixes are localized, but the open items should be resolved or explicitly accepted before merge.
Pre-merge checks:
4
#40550is the only active directly linked issue. Its coding requirements are: (1) live expandable thinking, tool calls, and replies in the child timeline while running; (2) persisted work histor…#40550. The changes cover the adapter hook, transcript follower, post-Idle drain, and background-work accounting in packages/provider-acp. They also cover the transcript re…Full details: Title check
Explanation
The title "fix(antigravity): subagent threads project thinking, tools, and replies into the normal timeline" matches the main change. The changeset adds transcript-following for Antigravity subagents that projects thinking, tool calls, and assistant replies into the child thread's standard timeline, and it persists completed items on Idle. The title is specific and follows the conventional commit format. It is 96 characters, which is slightly long but acceptable.
Full details: Description check
Explanation
The description follows the repository template's sections: Problem, Change, Scope, and Verification. The Problem section states the expected behavior and the observed blank-thread failure. The Change section explains the hook, the live follower, the post-idle drain, and the transcript readers. The Scope section links issue
#40550. The Verification section lists commands, focused tests, live Windows verification, and what was not checked. Two gaps remain. The description says the post-idle drain exits once the closing assistant_message lands, but the PR objectives report a later commit that changes this rule to continue until each child's transcript ends in a reply, so the description is out of date. The description also does not state whether the 'Authored by' attribution line matches the template's model-and-harness request, though it does name the model and harness.Resolution
Update the description so the post-idle drain stopping rule matches the final behavior, which continues until each child's transcript ends in a reply.
Full details: Linked Issues check
Explanation
Issue
#40550is the only active directly linked issue. Its coding requirements are: (1) live expandable thinking, tool calls, and replies in the child timeline while running; (2) persisted work history and final reply in the main thread after Idle. The transcript hook and follower in packages/provider-acp/src/server/adapter.ts project thinking, tool, and assistant_message entries into the child timeline while the subagent runs. The reader in apps/server/src/provider/acp/AntigravityChildWork.ts and the wiring in AntigravityAdapterV2.ts supply the transcript. A post-Idle drain persists completed items and captures the closing reply. The changes since the previous review extend the drain stop rule to continue until each child transcript ends in a reply. This keeps the final-reply requirement and does not weaken it. The new AntigravityAdapterV2.test.ts case covers a later closing reply after Idle, but no test covers multiple children with differing reply timing. This is an edge beyond the single-subagent scope of#40550. Live verification was reported on Windows only.Full details: Out of Scope Changes check
Explanation
Each changed area traces to
#40550. The changes cover the adapter hook, transcript follower, post-Idle drain, and background-work accounting in packages/provider-acp. They also cover the transcript reader, record resolver, and linear-time parsing hardening in apps/server AntigravityChildWork.ts, the wiring in AntigravityAdapterV2.ts, and the associated tests. The shared standard tool-call helper is reused for transcript tools, and the summaries report no root-turn behavior change. No unrelated feature, dependency, or workflow change appears in the summaries. This conclusion rests on whole-PR and per-file summaries. No file-level diff was read in this review.Finishing Touches
Generate unit tests (beta)