Skip to content

SCA-324: stop idle RUNNING omi-agent VMs in the reconciler - #11755

Merged
Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-cursor-grok-4-6/fdce6704
Aug 17, 2026
Merged

Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-cursor-grok-4-6/fdce6704

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Line-Count-Exception: backend/jobs/agent_vm_reconciler.py | 1814 -> 1912 | idle-stop predicate and no-drift RUNNING path stay next to the existing stop/preserve CAS; splitting would hide the stop-vs-restart invariant

What changed and why

Idle RUNNING omi-agent-* VMs had no server-side stop path: guest idle-stop is fail-silent, the reconciler only stopped on drift (then restarted), and the reaper deletes TERMINATED only. The reconciler now records idleSince on a healthy no-session RUNNING VM and stops it after AGENT_VM_IDLE_STOP_SECONDS (default 1h). The existing TERMINATED reaper remains the delete backstop.

Closes SCA-324
Closes #6611

#7326's public-IP residual is out of scope (firewall still applyEnabled: false). This PR covers the cost half only.

Product invariants affected

none

How it was verified

Ran the agent-vm unit files after make setup:

BACKEND_UNIT_TEST_FILE_LIST=... ./test.sh
138 passed

including the new leak matrix (RUNNING+stale stops once and does not restart; RUNNING+lease and start-demand do not stop; TTL-not-reached persists idleSince; idle is never a drift reason; README no longer claims RUNNING>2d; guest stop_instance() failures are logged).

Did not exercise live GCE or the prod CronJob. Existing 1,151 prod VMs are operator cleanup after merge; ownerless VMs are unreachable by this path (python3 backend/scripts/agent_vm_reaper.py --inventory).

Tests

  • test_idle_running_vm_past_ttl_is_stopped_without_restart — the leak itself
  • test_idle_running_vm_with_active_session_is_not_stopped
  • test_idle_running_vm_with_start_request_starts_not_stops
  • test_idle_ttl_not_reached_persists_idle_since_without_stop
  • test_idle_is_never_a_drift_reason
  • test_readme_does_not_reap_running_by_creation_age
  • test_stop_instance_is_observable_when_audience_missing
  • test_stop_instance_is_observable_when_broker_fails

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative (only when needed)

Violated contract: a healthy RUNNING omi-agent-* VM with no unexpired session lease must be stopped after a documented idle TTL so the TERMINATED reaper can delete it. The guest 30-minute self-stop is fail-silent and is not a fleet backstop.

Canonical guard: idle_stop_due() in backend/jobs/agent_vm_reconciler.py, used only on the no-drift RUNNING path (never folded into drift_reasons, which would stop-then-restart). Tests in backend/tests/unit/test_agent_vm_reconciler_job.py pin stop-once / lease-defer / start-demand / TTL-wait / not-a-drift-reason.

Registry lifecycle for the new class is a follow-up PR after this instance fix merges.

Review in cubic

Git-on-my-level and others added 2 commits August 18, 2026 00:08
Healthy no-session RUNNING omi-agent VMs had no server-side stop path, so
the TERMINATED-only reaper never saw them and the fleet leaked. The
reconciler now records idleSince and stops after a documented TTL.

Failure-Class: new
Co-authored-by: Cursor <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Required by Failure-Class: new on the idle-stop reconciler fix.

Co-authored-by: Cursor <[email protected]>
Co-authored-by: multica-agent <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 34bd15d into BasedHardware:main Aug 17, 2026
33 checks passed
Git-on-my-level added a commit that referenced this pull request Aug 17, 2026
## What changed and why

Signed-in macOS launch warmup (`ensureProvisioned`) now only adopts an
existing Agent VM (`ready` / `stopped` / `provisioning`). A missing VM
or a failed status check logs and returns instead of falling through to
`provisionAgentVM` / `runPipeline`. Onboarding still calls
`startPipeline()` for explicit first create. There is no first-open
Agent chat/tool path that assumed a VM already exists, so no extra
create site was added.

Closes SCA-328

Please merge with a regular merge commit (do not squash).

This is the low-hanging create-rate cut. Do not duplicate #11755
(idle-stop in the reconciler, already merged). Reaper LIVE / public IP /
#7326 / provision architecture are out of scope.

## Product invariants affected

none

## How it was verified

Focused desktop Swift tests after a clean package build:

```text
./scripts/dev-feedback.py --once swift 'AgentVMWarmupAdoptionTests|AgentVMLifecycleFenceTests|AgentVMCompressionRatioTests'
Executed 14 tests, with 0 failures
Iteration 1: PASS
```

`python3 scripts/check_desktop_test_quality.py` stayed at the
source-inspection baseline (54 files / 147 sites). Did not exercise a
live GCE provision; the production create call is now unreachable from
the warmup path.

## Tests

- `testWarmupAdoptsAReadyVMWithAnIP` /
`testWarmupPollsProvisioningAndStoppedVMs` — adopt-only happy path
- `testWarmupDoesNotCreateWhenStatusIsMissing` — missing VM on warmup
does not create
- `testWarmupDoesNotCreateWhenStatusCheckFails` — status error never
provisions
- `testWarmupDoesNotCreateForUnrecognizedOrErrorStatus`
- `testStartPipelineStillCreatesWhileWarmupOnlyAdopts` — create stays
off the warmup decision
- `testLaunchWarmupNeverCallsTheCreatePipeline` — static contract:
`ensureExistingOrProvision` never calls `runPipeline` /
`provisionAgentVM`; home warmup still calls `ensureProvisioned`;
onboarding still calls `startPipeline`

## Failure class (fixes)

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11759?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. -->
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.

Orphaned omi-agent VMs and SSD Disks causing unnecessary cloud billing

1 participant