Skip to content

Retire the cloud Agent VM: tombstone the broker endpoints, delete the control plane - #11795

Merged
Git-on-my-level merged 9 commits into
mainfrom
chore/agent-vm-retire-and-delete
Aug 18, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
chore/agent-vm-retire-and-delete

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Retire the cloud Agent VM: tombstone the broker endpoints and delete the control plane

Analysis of record: SCA-339 (passive agent surface), SCA-340 (migration mechanics), SCA-341 (constraints/entitlements/privacy). Operator authorization 2026-08-17: "have the same omp agent open a PR for the deletion and retirement." Follows merged #11761 (minimum-spend freeze: opt-in provisioning, read-only status, reconciler deletes undemanded VMs).

The measured case

  • 1,179 → 48 GCE instances (1,131 deleted 2026-08-17; the 48 stopped survivors are deliberately kept pending an export-window decision).
  • ~$5,800/mo reclaimed at the July peak (~$240/mo remains while the 48 stopped instances are held).
  • 2,773 lifetime sessions across 106 users; zero successful sessions since 2026-08-13; ~0.1% utilization at the July peak (41 distinct users/30d).

Why this is route-and-delete, not a rewrite

The VM never defined its own integration tools: agent_vm/main.py fetched tool definitions from GET /v1/agent/tools and executed them via POST /v1/agent/execute-tool — the same endpoints the managed omi:auto:chat-agent path uses. Those two endpoints stay. Mobile chat never used a VM (the only mobile door was the default-off claudeAgentEnabled dev flag, removed here); desktop chat runs through /v2/chat/completions + the local agent runtime. Only the per-user GCE capacity and its control plane die.

What is lost with no equivalent

  • Cloud browser automation (Playwright on the VM).
  • Cloud-resident general compute (Bash/workspace on a server filesystem) for users without the desktop app.
  • Ad-hoc cross-table read-only SQL over synced desktop data (per-domain tools remain).
  • Phone access to desktop-synced screen data (screenshot semantic search, daily recaps from the phone).

Demand for all four was the long tail (peak 41 users/30d, zero sessions since 2026-08-13).

Security improvement

The VM path uploaded a plaintext SQLite replica of desktop data to a per-user GCE disk, and the proxy forwarded the user's Firebase token over plaintext HTTP (ws://<ip>:8080/ws?token=…) to a box running the Claude Agent SDK with permission_mode="bypassPermissions" and Bash. Deleting the fleet removes that entire exposure class; managed inference already runs in the encrypted-at-rest Firestore trust domain every other Omi feature uses.

The client contract (the only change that hits every old client at once)

Old desktop clients (Stable 0.12.144 / Beta 0.12.186) keep calling the broker until they update, so the two desktop endpoints become permanent tombstones, pinned by contract tests (backend/tests/unit/test_desktop_agent_vm.py):

  • POST /v2/agent/provision → 410. Never 401 — APIClient has signOutOn401: true and a retirement must not force sign-outs.
  • GET /v2/agent/status → 200 with a null body. Never 200 + status:"provisioning" without an IP — old clients would poll 75×5s (~6.25 min).
  • POST /v2/agent/vm/stop-self → 410 (only the deleted guest image ever called it).
  • GET/POST /v1/agent/vm-status|vm-ensure|keepalive → removed outright (zero desktop callers; generated Swift only; mobile callers removed in this same PR). Recorded in DELIBERATELY_REMOVED_ENDPOINTS in check_app_client_openapi_compatibility.py so the app-client compatibility gate still rejects every accidental removal.

Mobile ordering question, resolved: deleting the code is not tearing down the running service. The GKE agent-proxy keeps serving its last image until the operator decommissions it (runbook below), so builds with claudeAgentEnabled=true are no worse off than today — they are already broken against a fleet with zero running VMs. Removing the toggle starts the clock on aging them out.

INV-DATA-1 (named because this touches app/lib/env/env.dart)

The invariant's routing table pinned wss://agent.omi.me/v1/agent/ws as canonical Flutter agent routing, env.dart threw at startup if prod didn't match, and env_test.dart:121,126 asserted it. This PR removes the retired surface from the routing table, the startup guard, and the guard tests in the same change — routing authority now covers only the surfaces that still exist. No other INV-DATA-1 row changes.

What is deleted

backend/agent-proxy/ (the GKE WS bridge), backend/agent_vm/ (guest image), backend/jobs/agent_vm_reconciler.py, backend/services/agent_vm_{lifecycle,migration_control,read}.py, backend/routers/desktop_agent_vm.py's 900-line broker (replaced by the ~50-line tombstone module), the 15 backend/scripts/ agent-vm scripts, the agent-proxy / agent-vm-firewall / agent-vm-reaper charts, both gcp_backend_agent_proxy*.yml workflows, the Agent VM image build + reconciler deploy + release-pointer promotion steps in desktop_backend_{prod,auto_dev}.yml (plus their AGENT_VM_*/GCE_* service env vars, now explicitly --remove-env-vars'd), ~20 dead test files, the 6 agent-vm failure-class JSONs, and the docs/runbooks that died with it.

Deliberately kept: /v1/agent/tools + /v1/agent/execute-tool (passive agent tool surface), agent_vm_account_cleanup.py and the account-deletion purge path (48 VMs still hold plaintext user data — deleting them is a live privacy obligation until the fleet is gone), and the entire desktop-local agent runtime (INV-AGENT-*, INV-CHAT-1 — the surface that actually delivers Architect's sold "Automations and vibe coding"; Windows sells Architect with no cloud VM ever).

Operator runbook (out of scope for this PR — gcloud work, in order)

  1. Cloud Scheduler: pause then delete job agent-vm-reconciler-5m (both projects if dev runs one).
  2. Cloud Run: delete job agent-vm-reconciler (it rides the desktop-backend image; nothing in this PR deploys it anymore).
  3. GKE: delete the agent-proxy Deployment/Service/Ingress/Helm release and the reaper CronJob prod-agent-vm-reaper (namespace prod-omi-backend), then remove the agent.omi.me DNS record.
  4. Firewall: delete rules omi-agent-vm-allow-private-8080 and omi-agent-vm-deny-public-8080 (target tag omi-agent-vm).
  5. IAM: delete custom roles omiAgentVmReconciler, omiAgentVmReconcilerOperations, omiAgentVmReconcilerSubnetwork, omiAgentVmSelfStop; delete service accounts agent-vm-reconciler@, omi-agent-vm-bootstrap@, agent-vm-reaper@ and their bindings (incl. KSA prod-agent-vm-reaper-sa Workload Identity binding).
  6. GCS: delete gs://$AGENT_GCS_BUCKET/agent-vm/releases/** (release pointers/startup manifests).
  7. Compute image family: delete the omi-agent image family.
  8. The 48 stopped instances (omi-agent-*, ~2,400 GB disks): irreversible — decide the export window first. Their workspace files have no download endpoint; the only export paths are (a) restart an instance on request and drive a live session, or (b) snapshot the disk to GCS and hand over a link. Holding them stopped costs ~$240/mo.
  9. Later, scripted (tracked as a follow-up issue): Firestore sweep of users.agentVm.*, users/{uid}/agentVmMigrations, account_deletions.late_agent_vm_cleanup, and the agent_vm_reconciler_leases collection — only after the fleet is empty; then retire agent_vm_account_cleanup.py.

Rollback for steps 1–3 is the prior Cloud Run revision / re-applying the charts from git history (minutes). The tombstone endpoints themselves need no rollback — they are additive responses on paths old clients already tolerate.

Rollback for this PR

Prior Cloud Run revision of desktop-backend, minutes (env flips are per-revision). The PR itself reverts cleanly: the deleted surfaces have no remaining callers.

Out of scope (tracked as stage-3 issues under the parent)

Desktop client removal of AgentVMService/AgentSyncService (~1.76k LOC, rides the desktop release train); the Firestore sweep; the account-cleanup retirement; the infra teardown above.

Review in cubic

Git-on-my-level and others added 6 commits August 17, 2026 21:12
The cloud Agent VM (one GCE e2-small per user running a Claude coding
agent) is retired: 2,773 lifetime sessions across 106 users, zero since
2026-08-13, ~0.1% peak utilization. Its integration toolset was fetched
from /v1/agent/tools + /v1/agent/execute-tool, which the managed
omi:auto:chat-agent path already serves - those endpoints stay.

Server contract for old desktop clients (pinned by contract tests):
- POST /v2/agent/provision -> 410 (never 401: APIClient signOutOn401
  force-signs-out)
- GET /v2/agent/status -> 200 null body (never provisioning-without-IP:
  6.25-min poll loops)
- /v1/agent/{vm-status,vm-ensure,keepalive} removed (zero desktop
  callers; recorded in DELIBERATELY_REMOVED_ENDPOINTS so the app-client
  compatibility gate still rejects accidental removals)

Deleted: agent-proxy WS bridge, agent_vm guest image, reconciler job,
agent_vm_{lifecycle,migration_control,read} services, 15 scripts, 3
charts, both gcp_backend_agent_proxy workflows, agent-vm release +
reconciler deploy steps and env in desktop_backend_{prod,auto_dev},
~20 dead test files, 6 failure classes, mobile claudeAgentEnabled door
(WS client, env constant, Dart agent codegen group), INV-DATA-1
routing row + env startup guard + guard tests, dead docs/runbooks.

Kept: /v1/agent/{tools,execute-tool}, agent_vm_account_cleanup (48
stopped VMs still hold plaintext user data - live privacy obligation),
desktop-local agent runtime (INV-AGENT-*), desktop-backend image smoke
now explicit in both deploy workflows.

Analysis of record: SCA-339/340/341. Follows merged #11761.

Co-authored-by: multica-agent <[email protected]>
…thon 3.14

- argparse help: escape the literal % (python 3.14 applies %-formatting to
  help strings and rejects a bare '% t')
- _git_is_ancestor + fixtures: strip GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE/
  GIT_OBJECT_DIRECTORY/GIT_NAMESPACE so the probes and scratch repos target
  the current directory's repository even when run from a pre-push hook

Co-authored-by: multica-agent <[email protected]>
…U time

Same shape as its already-allowlisted pusher twin: parses runtime_images.json
and walks the source closure; trips the 0.12s fail limit on loaded runners.

Co-authored-by: multica-agent <[email protected]>
…time

Fails the 0.12s fast-unit guard identically at HEAD on this runner; the test
maps every workflow-contract source to its selected tests.

Co-authored-by: multica-agent <[email protected]>
@mintlify

mintlify Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Aug 18, 2026, 6:07 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@Git-on-my-level Git-on-my-level added the no-changelog-needed Skip desktop changelog enforcement for internal-only changes label Aug 18, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member Author

@cursor address merge conflict

@cursor

cursor Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

I merged origin/main into chore/agent-vm-retire-and-delete and resolved the only conflict, in .github/scripts/check-deployment-concurrency.py. The PR is MERGEABLE again (mergeStateStatus: BLOCKED is reviews/checks, not a dirty tree).

The resolution keeps main’s isolated firestore-schema-* lock for gcp_firestore_indexes.yml (so index repair is not queued behind a waiting backend deploy) and drops the retired agent-proxy workflow contracts, since those workflows were deleted in this PR. Auto-merged files kept the same split: knowledge_graph fallback telemetry from main, no agent_vm_reconciler component.

Verified with python3 .github/scripts/check-deployment-concurrency.py --self-test and the full-repo check (OK, 22 persistent writers), plus focused backend/test.sh coverage of the tombstone, account-cleanup, fallback, knowledge-graph, and desktop-proxy suites — all passed.

Deployment concurrency policy self-test and repository check output

Open in Web Open in Cursor 

cursoragent and others added 3 commits August 18, 2026 06:51
Resolve the lock-policy conflict by keeping main's isolated
firestore-schema concurrency group and omitting the retired
agent-proxy workflow contracts.

Co-authored-by: David Zhang <[email protected]>
`pr-body.md` was the `gh pr create --body-file` input; it is not a repo
artifact and nothing reads it from the tree.

Co-Authored-By: Claude Opus 5 <[email protected]>
…re group

The retirement removed the `agent` group from `generate_dart_models.py`
and deleted `app/lib/backend/schema/gen/agent_wire.g.dart`, but left
`test_agent_wire_dart_is_generated_from_app_client_openapi` asserting the
group still generates. It failed closed in CI with
`ValueError: unknown Dart generation group: agent`.

No production behavior changed: the test asserted a generator group this
PR deletes, so the guard died with the code it guarded.

Verified: backend/.venv/bin/python -m pytest
tests/unit/test_app_client_dart_generator.py -q -> 27 passed.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit c841857 into main Aug 18, 2026
39 checks passed
@Git-on-my-level
Git-on-my-level deleted the chore/agent-vm-retire-and-delete branch August 18, 2026 08:40
Git-on-my-level added a commit that referenced this pull request Aug 19, 2026
## Summary

- add the operator runbook for retiring the residual production Cloud
Agent VM infrastructure left live after #11795
- separate the immediate reversible kill switch (pause Scheduler, remove
the HPA, scale proxy to zero, stop VMs) from irreversible data and
infrastructure deletion
- correct stale docs that still prescribed the deleted reconciler and
listed the deleted proxy deploy workflow as operational

## Measured case

The 2026-08-19 incident inventory found 52 surviving `omi-agent-*`
instances and 56 disks (2,800 GB). RUNNING grew from 7 to 20 over
approximately 18 hours. In the preceding 24 hours, Cloud Audit Logs
showed 24 starts and 82 resets, but no insert, stop, or delete. The old
GKE proxy was still installed with two ready replicas, a public Ingress,
and image `gcr.io/based-hardware/agent-proxy:874d796`; all observed
mutations used its mounted JSON-key principal and `python-httpx/0.28.0`.

The repository evidence supports the mechanism: revision `874d796552`
posts directly to the GCE start/reset endpoints, while current `main`
has no fleet start/reset implementation. The retained account-deletion
path performs fenced deletes only. The deleted release bucket also makes
failed boot health likely: the retired provisioner installed a startup
wrapper that exits when it cannot download its pinned GCS startup
artifact.

Two claims remain intentionally bounded rather than overstated:

- sole-source attribution is highly likely but not proved until scaling
the proxy to zero produces an audit-log quiet period; a copied key could
look identical
- Cloud Scheduler remains unverified because the available read identity
received `PERMISSION_DENIED`, which is not evidence of absence

## Retirement design

The runbook removes the HPA before scaling the Deployment so the HPA's
two-replica minimum cannot restart the proxy. Scaling closes in-flight
WebSockets; old clients retry against an unavailable backend and later
receive no DNS answer. The operator then stops every RUNNING survivor
because no remaining fleet-wide automation will do it.

The Ingress/Helm release is removed before DNS. DNS is not a kill switch
because cached answers survive, and deleting it first would make
rollback TTL-bound while leaving the live mutation source reachable.
Once the workload and Ingress are gone, deleting DNS retires the public
name without extending the outage rollback path.

Fleet and disk deletion is a separate, explicitly irreversible phase
after the data owner chooses an export/retention policy. The retained
account-deletion cleanup stays until the fleet and migration records are
empty.

## Verification

- `git diff --check`
- `bash -n` over every shell fence in the runbook
- repository-wide search of current `main` for GCE `start`/`reset`
implementations
- historical inspection of `874d796552` and the pre-#11795
startup-wrapper/release contract

The human committing this change must rerun `scripts/pr-preflight
--pr-body-file .tmp/pr-body.md` and `make preflight`. This sandbox
mounted the linked worktree's shared Git metadata read-only, so the
attempted local commit could not create the Git index lock; preflight
before that point saw zero committed files and is not presented as
diff-scoped evidence.

Live GCP/GKE state was not re-read from this sandbox: the installed
read-only GCP profile was absent, and the existing OAuth/kube credential
helper could not refresh because its config directory is outside the
writable sandbox. The production counts above are the operator-supplied
incident measurements; the PR makes no production mutation.

## Operator action

Follow `docs/runbooks/cloud-agent-vm-infrastructure-retirement.md`.
Phase 1 stops the active cost leak with reversible actions. Phases 2 and
3 retire serving, credentials, data-bearing capacity, and residual IAM
only after their stated gates.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11847?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
katipally pushed a commit to katipally/omi that referenced this pull request Aug 19, 2026
PR BasedHardware#11795 deleted the Cloud Agent VM control-plane source but not the running
infrastructure. The previously installed GKE release kept serving its old image
(gcr.io/based-hardware/agent-proxy:874d796), which posts directly to the GCE
start and reset endpoints. Over 24h that produced 24 starts and 82 resets with
no stops or deletes, walking RUNNING from 7 to 20 and costing ~$505/mo against
a ~$260/mo all-stopped baseline.

Adds an operator runbook that separates the reversible kill switch (pause
Scheduler, delete the HPA, scale the proxy to zero, stop survivors) from the
irreversible fleet and disk deletion, which is gated on an explicit
plaintext-data retention decision.

Deleting the HPA before scaling is load-bearing: it is configured with
minReplicas=2 and would otherwise restore the Deployment.

Also corrects two stale docs -- desktop-updates.mdx still listed the deleted
gcp_backend_agent_proxy.yml as an operational path, and the minimum-spend spec
still prescribed the deleted reconciler.

Merging this document does not change production.

Co-Authored-By: Claude Opus 5 <[email protected]>
kodjima33 pushed a commit that referenced this pull request Sep 13, 2026
…13686)

* fix(ci): shell-comparable JSON boolean for Agent VM SHA reuse guard

Failure-Class: none

Re-verify #11758: no open PR; broken print(True) vs "true" reuse extract is
absent on current main because cloud Agent VM deploy steps were removed in
#11795. Restore resolve_agent_vm_sha_release.py for the regression suite and
add a behavioral shell-contract test that runs the workflow one-liners against
resolver output (broken path skips reuse branch; json.dumps and
workflow_json_field_for_shell.py take it). Ratchet desktop-backend release
policy against the Python-repr anti-pattern.

Verification:
  backend/.venv/bin/python -m pytest tests/unit/test_resolve_agent_vm_sha_release.py -v
  python3 .github/scripts/check-desktop-backend-release-policy.py
  python3 .github/scripts/test_check_desktop_backend_release_policy.py

Co-authored-by: Apoorv Darshan <[email protected]>

* fix(ci): address cubic review on Agent VM SHA reuse guard

Failure-Class: none

- Fail closed when GCS describe errors are not object-not-found.
- Scope reuse-extract policy to resolver step blocks; match ${reuse} compares.
- Harden workflow_json_field_for_shell (with-open, scalar-only values).
- shlex.quote plan paths in shell contract test; add policy positive paths.

Verification:
  PYTHONPATH=backend python3 -m pytest backend/tests/unit/test_resolve_agent_vm_sha_release.py -v
  python3 .github/scripts/check-desktop-backend-release-policy.py
  python3 .github/scripts/test_check_desktop_backend_release_policy.py

Co-authored-by: Apoorv Darshan <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
kodjima33 pushed a commit that referenced this pull request Sep 15, 2026
…ren (#13850)

Git exports GIT_DIR to hooks; from a linked worktree it is the absolute path
of .git/worktrees/<name>. scripts/pre-push passed it to every check it ran, so
agents-md-lean's self-test `git init <fixture>` reinitialized the real
repository instead: git guessed it bare and wrote core.bare=true into the
config every worktree shares. With extensions.worktreeConfig on, that shared
value also applies to linked worktrees, so the fixture's ls-files failed and
the push of #11183 was refused with "ignored worktree copies must not be
discovered".

Four earlier fixes scrubbed the variable one caller at a time (#11413, #11709,
#11795, #12564). Clear it once at the top of the gate, after it changes to the
work tree root, and drop the two Flutter-phase copies it makes redundant.

test-pre-push-worktree-fallback.sh ran the gate with a bogus bare GIT_DIR and
relied on the gate still using it to fail at the base-ref lookup. The gate now
uses the work tree, which has origin/main, so the harness names a base branch
no repository has to keep failing fast at the same step.

Verification:
- Real `git push` from a disposable linked worktree, real pre-push hook, the
  checker from origin/main: hook env GIT_DIR=<sbx>/main/.git/worktrees/wt;
  shared core.bare false -> true; with extensions.worktreeConfig=true the
  exact #11183 AssertionError. A push from the main worktree exports no
  GIT_DIR and is unaffected.
- scripts/test-pre-push-git-env.sh passes with the fix and fails with the gate
  from origin/main and with only the new unset removed (core.bare=false ->
  core.bare=true in the fixture's shared config).
- All 13 manifest checks triggered by scripts/pre-push pass through
  run_checks.py --lane local; pre-push-worktree-fallback is Windows-only in
  the manifest and passes when run directly on macOS.

Failure-Class: new

Co-authored-by: Claude Opus 5 <[email protected]>
Git-on-my-level pushed a commit that referenced this pull request Nov 14, 2026
…tion

The M8 collection-budget guard is diff-scoped, so the sweep script's
agent_vm_reconciler_leases name arrives as a new work-state collection even
though PR #11795 removed its writer and reader. Record the review instead of
inventing a read budget for state nothing polls; the exemption retires with
the collection.

Refs SCA-345
Git-on-my-level added a commit that referenced this pull request Nov 18, 2026
…25050)

* chore(desktop): remove the retired Agent VM client surface

The cloud Agent VM was retired in #11795: the broker endpoints are now
tombstones (410 /v2/agent/provision, 200-null /v2/agent/status) and the
control plane is gone. The desktop client kept provisioning, polling,
gzip-uploading omi.db, and running a 3s sync loop against a VM that no
longer exists.

Delete AgentVMService and AgentSyncService plus every call site:

- Onboarding completion and Home launch warmup no longer start a VM
  pipeline; the StartupWarmupTaskID.agentVMProvisioning warmup and its
  delay are gone.
- Owner-transition fences in RuntimeOwnerIdentity and AuthService drop
  their VM/sync drains.
- ResourceMonitor no longer pauses/resumes AgentSync under memory
  pressure, and sleep no longer flushes a final sync.
- APIClient loses the v2/agent provision/status wrappers and DTOs.

Tests: the four AgentVM/AgentSync suites are deleted. The RewindDatabase
pool-rotation test now drives RewindDatabase.reportQueryError directly
(the production API AgentSync used to forward to), and the context-bucket
egress test drops its AgentSync table-disjointness assertion.

Server tombstones and backend/tests/unit/test_desktop_agent_vm.py stay
untouched: they exist to cover pre-cutover clients.

Refs SCA-344

Co-authored-by: multica-agent <[email protected]>

* fix(desktop): retain successful-query recovery signals after VM retirement

---------

Co-authored-by: multica-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Skip desktop changelog enforcement for internal-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants