Repository navigation
feat(runtime): remove an agent's downloaded runtime only once nothing on the host can still run it - #29139
Conversation
3f15180 to
ecae7f8
Compare
2a71622 to
4e080e4
Compare
ecae7f8 to
de2e98f
Compare
4e080e4 to
73ad5b8
Compare
de2e98f to
2865676
Compare
73ad5b8 to
521d054
Compare
2865676 to
37d2337
Compare
521d054 to
149e553
Compare
37d2337 to
94b7101
Compare
149e553 to
3acde30
Compare
94b7101 to
3762271
Compare
3acde30 to
fd703ab
Compare
3762271 to
093a177
Compare
fd703ab to
8c704a6
Compare
093a177 to
330a3b4
Compare
8c704a6 to
b463864
Compare
330a3b4 to
830b802
Compare
b463864 to
38c6b05
Compare
830b802 to
0fbe608
Compare
38c6b05 to
b8a0d12
Compare
9f88aab to
995ffd8
Compare
b8a0d12 to
9162f4a
Compare
908624d to
6735c79
Compare
f920b4f to
198af95
Compare
6735c79 to
cf0744f
Compare
9b1535a to
de34102
Compare
a2f36d7 to
f474fb7
Compare
de34102 to
9316310
Compare
f474fb7 to
f5aa9ec
Compare
9316310 to
ef64556
Compare
f5aa9ec to
df66910
Compare
ef64556 to
0f84153
Compare
df66910 to
813ee66
Compare
0f84153 to
0584cc0
Compare
813ee66 to
f3499af
Compare
38152d9 to
b045b47
Compare
f3499af to
a0f4aba
Compare
a0f4aba to
be0dea3
Compare
… 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.
b045b47 to
c2265b1
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/runtime/rpc/methods/managed-runtime-install.test.ts: 1
100-150: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover 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
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 10
src/main/acp/acp-launch-specs.tssrc/main/antigravity/antigravity-chat-account.tssrc/main/node-runtime/managed-runtime-installation.test.tssrc/main/node-runtime/managed-runtime-installation.tssrc/main/runtime/rpc/methods/antigravity-accounts.tssrc/main/runtime/rpc/methods/managed-runtime-install.test.tssrc/main/runtime/rpc/methods/managed-runtime-install.tssrc/main/runtime/structured-agent-chat-stop.tssrc/shared/managed-runtime-install.tssrc/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.
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.
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: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.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.fenceto run the deletion inside and imports nothing specific to Antigravity. An agent without a launch gate can't be removed.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
Notes
canRemove.Differences from the common pattern
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)