Skip to content

feat(runtime): remove an agent's downloaded runtime only once nothing on the host can still run it - #29139

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/agy-chat-R-runtime-remove
Oct 18, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/agy-chat-R-runtime-remove

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110 $\color{#cf222e}{\Huge{\mathbf{−}}}$​27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83

ELI5

Antigravity chats need Google's separate Antigravity chat server. An earlier version of this stack downloaded it silently the first time a chat started: about 18 seconds of "Working for Ns" with no progress and no Cancel, and every extra chat opened started another download. Now nothing downloads until the person clicks Install, which shows the size, progress and Cancel in Settings and in the new chat.

This PR adds the other half on the machine that runs the chats: deleting that download again. Deleting files a running program still uses can break it or leave it half-alive. So Orca first stops everything on that machine that might be running those files and checks that each one actually exited. Only then does it delete. If it can't confirm that, it deletes nothing and says why. The Settings button for it is #29140.

What Changed

This revision: two fixes that used to live here moved down the stack so each PR is safe alone: conversation copies entering the gate are now in #28649, and waiting for every chat stop to settle is now in #28650. This PR no longer changes either behavior; it moves the chat stop into a shared helper and adds Remove. Install status reaches clients by subscription now (#29024), so a Remove shows on every subscribed client without polling.

  • Before: once Orca installed the Antigravity server there was no way to remove it from Orca. You had to find and delete the folder yourself, even while chats were using it.
  • After (no button yet): the host answers a new call, managedRuntime.remove {agent}. It needs host-admin permission, like Install, and is advertised by a new capability, managed-runtime.remove.v1, so a newer Orca never asks an older host. On that host:
    • It deletes every release Orca installed for that agent, and the status every client sees goes back to not installed (or to the copy on PATH, if there is one).
    • Before deleting, it runs inside the same launch gate sign-in uses (feat(acp): pause an agent's chat starts while its shared sign-in changes #28649), which chat starts and conversation copies enter. Chat starts under way are aborted. The agent's running chats on this host are stopped; the chats and their history stay, and the next message starts the agent again (or shows the Install card if nothing is installed). Every leftover process a failed start or sign-in could not close is closed again and must prove it exited; a sign-in process that couldn't be proven stopped is now handed to the gate too, so Remove sees it.
    • Every stop is awaited and checked, even when one fails. If any chat or process can't be proven gone, Remove fails, the files stay, and the reason is "Not every Antigravity chat on this host could be stopped. Try again." or "Antigravity could not be stopped on this host. Try again."
    • Install and Remove never overlap. Install during a removal is refused with "Antigravity is being removed. Try again after it finishes." Remove during an install, or during its cleanup, is refused with "Antigravity is installing. Try again after it finishes." A second Remove joins the running one. A removal can't be cancelled ("Removing Antigravity cannot be cancelled."). A new chat start during Remove is refused with "Antigravity's setup is changing on this host. Try again after it finishes."
    • The install status gains an optional canRemove, true whenever Orca's copy is there, whole or damaged, so Settings can offer Remove for a damaged copy too. A status read that can't inspect the folder fails instead (feat(acp): a managed runtime installs only when asked, with progress and cancel #29023), so clients keep their last answer rather than guess.
  • Stopping all chats of one agent on this host is now one shared helper, stopStructuredAgentChats, which waits for every stop to settle before deciding. Sign-in (feat(antigravity): sign Antigravity chats in with the server's own Google sign-in #28650) uses it too, instead of its Antigravity-only copy, with the same behavior.
  • The installer stays generic. It is handed a fence to run the deletion inside and imports nothing specific to Antigravity. An agent without a launch gate can't be removed.
  • Merge note: this PR no longer needs to merge together with feat(antigravity): sign Antigravity chats in with the server's own Google sign-in #28650; each lands safely on its own in stack order.

Why

Deleting a release while something still runs it is the bug this has to rule out. The fence already exists for sign-in, where it keeps chats from starting while the shared account changes, so Remove reuses it instead of adding a second lock. Processes whose close was never proven outlive the start or sign-in that made them, so the fence keeps track of them too and proves them gone before any deletion runs.

Known limit: an agent whose model list is read by starting its server outside a chat would need that reader inside the same fence. Antigravity has no such reader today; its models are only listed in a signed-in chat.

Linked Issue

N/A (maintainer; part of the Antigravity Chat UI stack).

Visual Proof

N/A: host only. The Settings button and the end-to-end QA screenshots are on #29140.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • One host test through the real call, gate and chat-stop helper: with a running chat and a leftover sign-in process that won't prove it exited, Remove stops the chat, fails and keeps the installed release. Once that process exits, Remove stops the next running chat, deletes the files, and status reads not installed.

  • The installer's damaged-copy test also checks that a damaged copy reports canRemove.

  • Lint, typecheck and the full test suite run in this PR's CI.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH and remote hosts: the call runs on the host that runs the chats, whichever client asks.
  • Folder workspaces: no workspace is needed.
  • Mixed versions: an older host lacks the capability, so a newer client offers no Remove there. An older client ignores canRemove.
  • Windows: Antigravity is not offered there (Orca pins no Windows build yet), so there is nothing to remove.
  • PR author: @BrennanKB5

Differences from the common pattern

  • Intended: Remove stops the agent's running chats (the chats and their history stay, and the next message starts the agent again) instead of refusing until the person stops them, because a person's chats can be open on several paired devices; the common pattern's own sign-in already stops chats the same way. A Remove while a sign-in runs is refused, not queued: "Antigravity's setup is changing on this host. Try again after it finishes." (feat(settings): sign Antigravity chats in from Accounts #28705 disables Remove while a sign-in runs.)
  • Intended: "nothing is using these files" is established by the same fence sign-in uses (starts in progress, running chats, conversation copies, sign-in processes, and processes whose stop was not proven) rather than a separate per-release count of uses; if any process cannot be proven stopped, Remove fails and keeps the files. Because the fence is per agent, Remove also stops chats running a copy found on PATH, which is reachable only when Orca's own copy is damaged and such a copy runs.
  • Intended: Remove has its own host capability, so a client offers it only on hosts that support it; a host can support Install without Remove.
  • Intended: there is no check for a custom program path inside the downloaded folder, because this agent ignores the Command setting; an agent that honours it would need one.
  • Intended: after Remove, the installed state is re-read from disk rather than reset in memory, so it can't disagree with what is on disk.
  • Intended: Remove runs as an operation the host reports ("removing", then the outcome) rather than one call that returns when done, because stopping every chat can outlast a remote call's time limit and every client should see that a removal is under way.
  • Intended: Install during a removal is refused with "Antigravity is being removed. Try again after it finishes." instead of waiting for it; the Settings row disables Install while "Removing…" shows, and queuing would need a second pending operation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch 2 times, most recently from 3f15180 to ecae7f8 Compare October 15, 2026 11:23
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 2a71622 to 4e080e4 Compare October 15, 2026 13:34
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from ecae7f8 to de2e98f Compare October 15, 2026 13:34
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 4e080e4 to 73ad5b8 Compare October 15, 2026 13:40
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from de2e98f to 2865676 Compare October 15, 2026 13:40
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 73ad5b8 to 521d054 Compare October 15, 2026 13:57
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 2865676 to 37d2337 Compare October 15, 2026 13:58
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 521d054 to 149e553 Compare October 15, 2026 14:25
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 37d2337 to 94b7101 Compare October 15, 2026 14:25
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 149e553 to 3acde30 Compare October 15, 2026 14:49
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 94b7101 to 3762271 Compare October 15, 2026 14:49
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 3acde30 to fd703ab Compare October 15, 2026 14:51
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 3762271 to 093a177 Compare October 15, 2026 14:51
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from fd703ab to 8c704a6 Compare October 15, 2026 15:08
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 093a177 to 330a3b4 Compare October 15, 2026 15:08
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 8c704a6 to b463864 Compare October 15, 2026 16:03
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 330a3b4 to 830b802 Compare October 15, 2026 16:03
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from b463864 to 38c6b05 Compare October 15, 2026 16:30
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 830b802 to 0fbe608 Compare October 15, 2026 16:30
@brennanb2025
brennanb2025 marked this pull request as ready for review October 15, 2026 17:09
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 38c6b05 to b8a0d12 Compare October 15, 2026 19:57
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch 2 times, most recently from 9f88aab to 995ffd8 Compare October 15, 2026 21:20
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from b8a0d12 to 9162f4a Compare October 15, 2026 21:20
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 908624d to 6735c79 Compare October 16, 2026 03:25
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from f920b4f to 198af95 Compare October 16, 2026 03:25
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 6735c79 to cf0744f Compare October 16, 2026 03:27
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch 2 times, most recently from 9b1535a to de34102 Compare October 16, 2026 19:43
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch 2 times, most recently from a2f36d7 to f474fb7 Compare October 16, 2026 20:09
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from de34102 to 9316310 Compare October 16, 2026 20:10
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from f474fb7 to f5aa9ec Compare October 16, 2026 21:55
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 9316310 to ef64556 Compare October 16, 2026 21:55
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from f5aa9ec to df66910 Compare October 16, 2026 22:11
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from ef64556 to 0f84153 Compare October 16, 2026 22:11
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from df66910 to 813ee66 Compare October 16, 2026 22:23
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from 0f84153 to 0584cc0 Compare October 16, 2026 22:23
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from 813ee66 to f3499af Compare October 17, 2026 00:43
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch 2 times, most recently from 38152d9 to b045b47 Compare October 17, 2026 01:07
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from f3499af to a0f4aba Compare October 17, 2026 01:07
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-5b1b-signin-service branch from a0f4aba to be0dea3 Compare October 17, 2026 20:19
… on the host can still run it

managedRuntime.remove {agent} (host-admin, capability managed-runtime.remove.v1)
deletes the agent's releases inside the launch gate. Before anything is deleted the
gate aborts starts under way (chat starts and conversation copies), stops the
agent's loaded chats on this host, and proves every retained child gone: failed
chat starts and sign-in children whose close was never proven. Every close settles
before the gate releases; if any owner stays unproven, Remove fails and keeps the
files. Stopping chats by agent is now one generic host helper that sign-in shares.
Install refuses while a removal runs, Remove refuses while an install runs, and a
removal cannot be cancelled.
…copies included

canRemove is set whenever Orca's copy is present, whole or damaged, so Settings offers Remove for a
damaged copy too. The failed-start retain is dropped: the launch gate already holds every child it
admitted until it exits.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-R-runtime-remove branch from b045b47 to c2265b1 Compare October 18, 2026 07:47
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/agy-chat-5b1b-signin-service to main October 18, 2026 07:47
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds managed runtime removal through a host-admin RPC. Removal stops loaded structured chats and runs inside a launch-gate fence. The installation reports whether removal is available and publishes removal operation status. The shared runtime capabilities include the removal capability. Antigravity now uses a shared launch gate that retains a connection if sign-in owner closure fails while the connection remains active. Tests cover removal failures and successful cleanup.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to c2265

Removal has no established production failure, but its test does not cover a chat that fails to stop. Add that safety case before relying on the test for this guarantee.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: safe removal of an agent's downloaded runtime after confirming that no host process can still use it.
Description check Passed The description follows the required template and explains the user impact, implementation, rationale, linked-issue exception, visual proof, testing, compatibility considerations, and checklist status…
Full details: Description check

Explanation

The description follows the required template and explains the user impact, implementation, rationale, linked-issue exception, visual proof, testing, compatibility considerations, and checklist status. It provides sufficient detail for review.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/runtime/rpc/methods/managed-runtime-install.test.ts: 1

100-150: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Cover a chat that remains loaded after close.

The fixture always removes the chat from chats.loaded, so the current failed removal tests only the retained child. Add one failure case where the chat remains loaded and assert that removal retains the files.

Suggested fix
-const chats = vi.hoisted((): { loaded: string[]; closed: string[] } => ({ loaded: [], closed: [] }))
+const chats = vi.hoisted((): {
+  loaded: string[]
+  closed: string[]
+  retainLoaded: boolean
+} => ({ loaded: [], closed: [], retainLoaded: false }))
...
-        chats.loaded = chats.loaded.filter((loaded) => loaded !== id)
+        if (!chats.retainLoaded) {
+          chats.loaded = chats.loaded.filter((loaded) => loaded !== id)
+        }
...
-  const child = { close: vi.fn(async () => false), onExit: () => {} }
+  const child = { close: vi.fn(async () => true), onExit: () => {} }
   spec.launchGate.retain(child)
   chats.loaded = ['chat-1']
+  chats.retainLoaded = true
   expect(await removed()).toMatchObject({
     installedVersion: pin.version,
     operation: { kind: 'remove', phase: 'failed', error: expect.stringContaining('stopped') }
   })
 
-  child.close.mockResolvedValue(true)
+  chats.retainLoaded = false
+  child.close.mockResolvedValue(false)
   chats.loaded = ['chat-2']
+  expect(await removed()).toMatchObject({
+    installedVersion: pin.version,
+    operation: { kind: 'remove', phase: 'failed', error: expect.stringContaining('stopped') }
+  })
+
+  child.close.mockResolvedValue(true)
+  chats.loaded = ['chat-3']
   expect(await removed()).toMatchObject({
     installedVersion: null,
     source: null,
     operation: { kind: 'remove', phase: 'succeeded' }
   })
-  expect(chats.closed).toEqual(['chat-1', 'chat-2'])
+  expect(chats.closed).toEqual(['chat-1', 'chat-2', 'chat-3'])

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ef4e243-808b-40be-aec3-53ebf446f3e6
📥 Commits

Reviewing files that changed from the base of the PR and between 29a43a7 and c2265b1.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 10
  • src/main/acp/acp-launch-specs.ts
  • src/main/antigravity/antigravity-chat-account.ts
  • src/main/node-runtime/managed-runtime-installation.test.ts
  • src/main/node-runtime/managed-runtime-installation.ts
  • src/main/runtime/rpc/methods/antigravity-accounts.ts
  • src/main/runtime/rpc/methods/managed-runtime-install.test.ts
  • src/main/runtime/rpc/methods/managed-runtime-install.ts
  • src/main/runtime/structured-agent-chat-stop.ts
  • src/shared/managed-runtime-install.ts
  • src/shared/protocol-version.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@brennanb2025
brennanb2025 merged commit 6fd2172 into main Oct 18, 2026
66 of 97 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/agy-chat-R-runtime-remove branch October 19, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant