fix(server): reconcile canceled Antigravity background commands at turn settlement #39450
Openal0x99(GitHub profile, opens in a new tab)wants to merge 8 commits into
main fromrefs/pull/39450/headopened View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -0,0 +185,21 @@185+ )186+ .all(MAX_PAYLOAD_BYTES, RUN_COMMAND_STEP_TYPE, MAX_ACTIVE_COMMANDS + 1);187+ if (rows.length > MAX_ACTIVE_COMMANDS) return undefined;188+ if (rows.length === 0) {189+ const hasAnyCommand =190+ database191+ .prepare("SELECT 1 FROM steps WHERE step_type = ? LIMIT 1")192+ .get(RUN_COMMAND_STEP_TYPE) !== undefined;193+ return hasAnyCommand ? [] : undefined;194+ }195+ const active: Array<ActiveNativeCommand> = [];196+ for (const row of rows) {197+ const metadata =198+ row.metadata instanceof Uint8Array199+ ? row.metadata.subarray(0, MAX_METADATA_BYTES)200+ : null;201+ const payload = row.payload instanceof Uint8Array ? row.payload : null;202+ const decoded = decodeActiveCommand(metadata, payload);203+ if (decoded === undefined) return undefined;204+ if (decoded.isDaemon) continue;205+ if (decoded.callId === undefined && decoded.command === undefined) return undefined;@@ -0,0 +203,21 @@203+ if (decoded === undefined) return undefined;204+ if (decoded.isDaemon) continue;205+ if (decoded.callId === undefined && decoded.command === undefined) return undefined;206+ active.push(decoded);207+ }208+ if (active.length === 0) return [];209+ const available = [...active];210+ const stillRunning: Array<string> = [];211+ // Match newest-first so a retried identical command consumes its live row first.212+ for (let index = input.tools.length - 1; index >= 0; index -= 1) {213+ const tool = input.tools[index]!;214+ const identity = toolCommandIdentity(tool);215+ let matchIndex = available.findIndex((entry) => entry.callId === tool.toolCallId);216+ if (matchIndex === -1 && identity.command !== undefined) {217+ matchIndex = available.findIndex(218+ (entry) =>219+ entry.command === identity.command &&220+ (identity.cwd === undefined ||221+ entry.cwd === undefined ||222+ entry.cwd === identity.cwd),223+ );
Pushedfa1daf1
Pushed50466fa
- @@ -0,0 +166,21 @@166+ if (!NATIVE_SESSION_ID.test(input.sessionId)) return undefined;167+ const read = async (): Promise<ReadonlyArray<string> | undefined> => {168+ const profileRoot = await antigravityProfileRoot(input.profileDirectory);169+ if (profileRoot === undefined) return undefined;170+ const databaseFile = await antigravityManagedPath(171+ profileRoot,172+ [...CONVERSATION_SEGMENTS, `${input.sessionId}.db`],173+ "file",174+ );175+ if (databaseFile === undefined) return undefined;176+ const database = new NodeSqlite.DatabaseSync(databaseFile.path, { readOnly: true });177+ try {178+ database.exec("PRAGMA busy_timeout = 100");179+ const hasSteps =180+ database181+ .prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'steps'")182+ .get() !== undefined;183+ if (!hasSteps) return undefined;184+ const rows = database185+ .prepare(186+ `SELECT metadata, substr(step_payload, 1, ?) AS payload
Pushedec66935
Pushedf9281b5
- @@ -0,0 +521,21 @@521+ }),522+ scheduleTool,523+ ],524+ });525+ assert.deepEqual(result, [scheduleTool.toolCallId]);526+ }).pipe(Effect.provide(NodeServices.layer)),527+ );528+529+ it.effect("returns undefined when an active row has oversized metadata", () =>530+ Effect.gen(function* () {531+ const fs = yield* FileSystem.FileSystem;532+ const profileDirectory = yield* fs.makeTempDirectoryScoped();533+ yield* writeSessionDb({534+ profileDirectory,535+ rows: [536+ {537+ idx: 14,538+ stepType: RUN_COMMAND_STEP_TYPE,539+ status: STATUS_RUNNING,540+ metadata: new Uint8Array(256 * 1024 + 1),541+ payload: null,
Pushed89fe94a
Pushed2f691ec
Pushed902703d
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
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:
No actionable comments were generated in the recent review.
Walkthrough
The ACP adapter now reconciles running tools after prompt settlement through an optional callback. The Antigravity adapter uses a bounded, read-only session database reader to identify active command tools. Tests cover command matching and turn behavior.
Changes: Outliving command reconciliation
apps/server/src/provider/acp/AntigravityBackgroundCommands.ts,apps/server/src/provider/acp/AntigravityBackgroundCommands.test.tsrun_commandsteps and matches them to ACP tools by call ID or command and compatible working directory. Tests cover canceled and completed steps, duplicate commands, daemon exclusion, non-execute tools, and inconclusive database reads.packages/provider-acp/src/server/adapter.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.tsEstimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Sequence Diagram(s)#
Possibly related issues
Possibly related PRs
Suggested labels:
bugfixSuggested reviewers:
macroscopeapp,juliusmarmingeMerge Risk:
Minimal · previous review
89fe9This change reconciles canceled Antigravity background commands so turns no longer stay running indefinitely. The reconciliation errs on the side of leaving tools open when state is uncertain, and tests cover the main cases. No merge-blocking risk remains.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: reconciling canceled Antigravity background commands at turn settlement. It follows the conventional commit format and matches the PR objectives and the file changes, which add tools-outliving-prompt reconciliation and a read-only conversation database check.
Full details: Description check
Explanation
The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section gives specific content. The Problem section states the expected and observed behavior and the trigger. The Change section lists the files and functions touched. The Scope section explains why no separate issue is linked and cites the originating PR
#38916. The Verification section gives commands, test counts, and what was not checked. It does not name the agent model in the required trailer format, but it ends with 'Gemini 4 Neon via Antigravity in T3 Code', which covers the agent attribution line. The Scope section also does not link an issue that shows the bug. That is a minor gap, since the author gives a reason for omitting one.Finishing Touches
Generate unit tests (beta)
22f016b6-d0e4-4db9-bca7-1b13e283b669Reviewing files that changed from the base of the PR and between f9281b5b88acf6f4de1894d31816d488a4c8185f and 89fe94a474d964630bc66bbb1ed711003d7aa213.
apps/server/src/provider/acp/AntigravityBackgroundCommands.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.