Skip to content

Commit 32e45fc

Browse files
committed
fix(server): enable Antigravity subagent continuation and idle paragraph streaming
1 parent cefb544 commit 32e45fc

6 files changed

Lines changed: 919 additions & 114 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ export function makeAntigravityAcpAdapterFlavor(
276276
// 1.4.5 returns the root trajectory's Gemini usageMetadata delta; 1.4.1 returns none.
277277
reportsPerTurnPromptUsage: true,
278278
geminiPromptUsage: true,
279+
deferFinalizeForBackgroundWork: true,
280+
enablePostSettleContinuation: true,
279281
...(profileDirectory === undefined
280282
? {}
281283
: {

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
26242624
readonly disposition: "stopped" | "disposed";
26252625
readonly now: DateTime.Utc;
26262626
readonly cancelQueuedDelivery?: boolean;
2627+
// An interrupted wake disposes only the results it carried. The cohort stays open, and its
2628+
// delivery stays the wake's, so the wake's terminal reserves any sibling's result.
2629+
readonly interruptedWakeTaskIds?: ReadonlyArray<NodeId>;
26272630
}) {
26282631
const parentRun = input.projection.runs.find((candidate) => candidate.id === input.parentRunId);
26292632
if (parentRun === undefined) {
@@ -2637,12 +2640,28 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
26372640
return;
26382641
}
26392642
const emitEvent = emit(input.events, input.command);
2640-
const nextDisposition = cohort?.disposition === "disposed" ? "disposed" : input.disposition;
2641-
const nextCohort = {
2642-
disposition: nextDisposition,
2643-
nextGeneration: cohort?.nextGeneration ?? 1,
2644-
delivery: null,
2645-
} as const;
2643+
const wakeTaskIds = input.interruptedWakeTaskIds;
2644+
const keptTaskIds = new Set(
2645+
wakeTaskIds !== undefined && cohort?.disposition === "open"
2646+
? tasks
2647+
.filter(
2648+
(task) =>
2649+
!wakeTaskIds.includes(task.id) &&
2650+
task.completionDelivery?.state !== "acknowledged" &&
2651+
task.completionDelivery?.state !== "delivered" &&
2652+
task.completionDelivery?.state !== "disposed",
2653+
)
2654+
.map((task) => task.id)
2655+
: [],
2656+
);
2657+
const nextCohort =
2658+
keptTaskIds.size > 0
2659+
? cohort!
2660+
: ({
2661+
disposition: cohort?.disposition === "disposed" ? "disposed" : input.disposition,
2662+
nextGeneration: cohort?.nextGeneration ?? 1,
2663+
delivery: null,
2664+
} as const);
26462665
yield* emitEvent({
26472666
type: "run.updated",
26482667
threadId: parentRun.threadId,
@@ -2657,6 +2676,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
26572676
});
26582677
for (const task of tasks) {
26592678
if (
2679+
keptTaskIds.has(task.id) ||
26602680
task.completionDelivery?.state === "acknowledged" ||
26612681
task.completionDelivery?.state === "delivered" ||
26622682
task.completionDelivery?.state === "disposed"
@@ -2682,7 +2702,11 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
26822702
});
26832703
}
26842704
const deliveryRun = completionDeliveryRun(input.projection, cohort?.delivery ?? null);
2685-
if (input.cancelQueuedDelivery !== false && deliveryRun?.status === "queued") {
2705+
if (
2706+
keptTaskIds.size === 0 &&
2707+
input.cancelQueuedDelivery !== false &&
2708+
deliveryRun?.status === "queued"
2709+
) {
26862710
yield* emitQueuedRunCancellation({
26872711
command: input.command,
26882712
events: input.events,
@@ -11324,6 +11348,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
1132411348
parentRunId,
1132511349
disposition: "stopped",
1132611350
now,
11351+
...(parentRunId !== run.id && completionMessage?.delegatedCompletion !== undefined
11352+
? { interruptedWakeTaskIds: completionMessage.delegatedCompletion.taskIds }
11353+
: {}),
1132711354
});
1132811355
}
1132911356
});

0 commit comments

Comments
 (0)