fix(antigravity): bound silent post-settle background command holds #40858
MergedLokkuchakreshkumar(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/40858/headmerged by juliusmarminge View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -8835,3 +8840,16 @@88358840 yield* options.testHooks?.onDeferredFinalizeScheduled?.(debounce) ?? Effect.void;88368841 });883788428843+ /**8844+ * Bound a settled turn held only by an outliving tool that never reports back, so the8845+ * run cannot stay in Working forever with no visible background work.8846+ */8847+ const schedulePostSettleHoldExpiry = Effect.fn("AcpAdapterV2.schedulePostSettleHoldExpiry")(8848+ function* (context: ActiveAcpTurn) {8849+ const timeout = flavor.postSettleBackgroundHoldTimeout;8850+ if (timeout === undefined) return;8851+ if (!context.promptSettled || context.finalized) return;8852+ if (!hasDeferredBackgroundWork(context)) return;8853+ yield* Effect.gen(function* () {8854+ yield* Effect.sleep(timeout);8855+ if (context.finalized || !context.promptSettled) return;@@ -8837,0 +8844,21 @@8844+ * Bound a settled turn held only by an outliving tool that never reports back, so the8845+ * run cannot stay in Working forever with no visible background work.8846+ */8847+ const schedulePostSettleHoldExpiry = Effect.fn("AcpAdapterV2.schedulePostSettleHoldExpiry")(8848+ function* (context: ActiveAcpTurn) {8849+ const timeout = flavor.postSettleBackgroundHoldTimeout;8850+ if (timeout === undefined) return;8851+ if (!context.promptSettled || context.finalized) return;8852+ if (!hasDeferredBackgroundWork(context)) return;8853+ yield* Effect.gen(function* () {8854+ yield* Effect.sleep(timeout);8855+ if (context.finalized || !context.promptSettled) return;8856+ if (!hasDeferredBackgroundWork(context)) return;8857+ // Only an outliving tool gets bounded here. Queued wakes, hydration and detached8858+ // subagents still have their own settlement paths.8859+ const heldCommand = [...context.tools.values()].some(8860+ (tool) =>8861+ toolStatus(tool.status) === "running" &&8862+ flavor.toolOutlivesPrompt?.(tool) === true,8863+ );8864+ if (!heldCommand) return;
juliusmarminge added labelstakeover:in-progress
Pushed3cb62c3
- @@ -244,3 +244,6 @@244244 wakeOnDetachedRequest: true,245245 replyEndsWithUsageUpdate: true,246246 toolOutlivesPrompt: antigravityToolOutlivesPrompt,247+ // agy sometimes loses the terminal update or wake for a background command, which would248+ // hold the turn in Working forever. 30 minutes still leaves long commands room.249+ postSettleBackgroundHoldTimeout: "30 minutes",@@ -8835,3 +8840,9 @@88358840 yield* options.testHooks?.onDeferredFinalizeScheduled?.(debounce) ?? Effect.void;88368841 });883788428843+ const schedulePostSettleHoldExpiry = Effect.fn("AcpAdapterV2.schedulePostSettleHoldExpiry")(8844+ function* (context: ActiveAcpTurn) {8845+ const timeout = flavor.postSettleBackgroundHoldTimeout;8846+ if (timeout === undefined) return;8847+ if (!context.promptSettled || context.finalized) return;8848+ if (!hasDeferredBackgroundWork(context)) return;
Pushedc89375f
Pushed79fff87
- @@ -8837,0 +8865,21 @@8865+ // Armed even without a command yet: a pending reply can still start one.8866+ yield* Effect.gen(function* () {8867+ while (!context.finalized) {8868+ quietSince = Math.max(quietSince, context.lastProgressAt);8869+ const now = yield* Clock.currentTimeMillis;8870+ const remaining = quietSince + timeoutMillis - now;8871+ if (remaining > 0) {8872+ yield* Effect.sleep(Duration.millis(remaining));8873+ continue;8874+ }8875+ if (8876+ context.tools.values().some(isRunningCommand) &&8877+ !hasDeferredBackgroundWork(context, isRunningCommand)8878+ ) {8879+ yield* finalizeTurn(context, context.promptSettledStatus ?? "completed");8880+ return;8881+ }8882+ // Something else still holds the turn; count silence again once it clears.8883+ quietSince = now;8884+ }8885+ }).pipe(Effect.forkIn(sessionScope), Effect.asVoid);
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged this344de5f
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
The ACP adapter adds a configurable post-settle hold for selected running commands. Antigravity sets the hold to 30 minutes and classifies which commands qualify. Tests cover command progress, hold expiry, scheduled wakes, and unanswered permission requests.
Changes: Post-settle command hold
packages/provider-acp/src/server/adapter.tsapps/server/src/provider/acp/AntigravityProtocol.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
Suggested reviewers:
juliusmarminge,mkantautasMerge Risk:
Moderate · up to
79fffThis change bounds how long a settled Antigravity turn stays in Working when a background command never reports back. The main path is covered by tests. A few edge cases remain: a replacement prompt can be finalized by an earlier timer, a reply that stalls can be finalized, and a continuation turn may have no timer. Resolve or accept these before merging.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the fix and its scope: a silent post-settle background command hold on the Antigravity adapter is now bounded. It matches the main change in the summary (a 30-minute bound on the post-settle command hold, with the turn finalized as completed). It follows the conventional commit form the template asks for, and it is specific enough for a teammate scanning history.
Full details: Description check
Explanation
The description follows the template well. It has Problem, Change, Scope, and Verification sections, with clear content in each. The problem is stated with concrete mechanics: the stuck Working state, the empty pendingBackgroundTasks, and why the existing inactivity watchdog cannot break the hold. The change lists the new optional flavor property, the timer behavior, and the 30-minute opt-in. Scope links related PRs and states what is excluded. Verification names targeted adapter tests and a regression test. Two items are weaker. The Problem section is not an issue link, but the Scope section explains the linkage to
#39820. The Verification section does not report observed results or state what was not checked, which the template asks for. The description also lacks an explicit issue link for the bug itself, although it references#39820as the parent. These gaps are minor and do not make the description incomplete.Finishing Touches
Generate unit tests (beta)