Repository navigation
Description
Summary
WorkspaceIdle defaults to 30 minutes, and idle reclaim is the only trigger that deletes a session's workspace. A human-in-the-loop session can sit idle for hours awaiting a person's response — so the workspace is deleted mid-session, and the next turn silently resumes in an empty /workspace with no signal to the caller.
The keying is correct: workspace_key is the session id and cross-turn continuity is tested (see #267, now closed). This is about the workspace's lifetime, not its identity.
Why it bites
// remote-worker/internal/vmpool/config.go
DefaultStandbyIdle = 90 * time.Second // drop standbys, KEEP workspace
DefaultWorkspaceIdle = 30 * time.Minute // delete the workspace tooThe two-stage policy is sound in shape — memory is reclaimed aggressively, the durable thing is kept longer. The problem is only that 30 minutes is short relative to how long a HITL turn boundary can be, and there is nothing else to fall back on:
/workspaceis the only durable thing on this tier. The writable guest layers (/tmp,/var) are tmpfs discarded on kill, and every Exec gets a fresh microVM, so a lost workspace loses everything the session had accumulated — a git clone, build artifacts, edited files.- The loss is silent. The next Exec succeeds. It just runs against an empty filesystem. An agent that cloned a repo in turn 1 and edits a file in turn 5 gets a confusing failure at best, and at worst re-clones and proceeds on a stale plan.
- There is no explicit release. Grepping the proto and the harness, there is no
Release{workspace_key}wire path — the only reference is a comment inselect-sandbox.ts. P4 §9 anticipated one ("already guarding forRelease{workspace_key}") and it has not landed, so reclaim cannot be driven by the session actually ending.
Why the TTL cannot simply be raised
Workspace disk is not admission-controlled. MaxCommittedBytes/MemoryReserveBytes gate VM memory only. The idle sweep is therefore the sole backstop against workspace disk exhaustion, and raising WorkspaceIdle trades HITL correctness directly against filling the host, with no other control in between.
Worth measuring before choosing a number: workspace.img is Truncate'd to WorkspaceImageBytes (2 GiB default) and then mkfs'd, so the real cost per idle session is what has actually been written rather than 2 GiB — but that should be confirmed on a real host rather than assumed, because it decides how long a TTL is affordable.
Options, not a decision
- Explicit release, as P4 §9 anticipated. The principled fix: the harness says when a session is over, so reclaim is not inferred from silence. Then
WorkspaceIdlebecomes a long backstop rather than the primary mechanism, and HITL gaps stop mattering. Costs the "one wire change" budget the spec reserved. - Raise
WorkspaceIdleand bound workspace disk. Independent of (1) and probably needed anyway: if disk is the real constraint, it should be a budget with admission control like memory, not a timer. - Make the reset observable. Whatever the TTL, a first Exec for a key that previously existed and was reclaimed should be distinguishable from a genuinely new session. Needs a small amount of bookkeeping for reclaimed keys, and it turns a silent data loss into something an agent or operator can react to. Cheapest of the three and independently useful.
- Per-session-class TTLs. If HITL and autonomous sessions have different idle profiles, one timer may be the wrong shape.
Suggested first step
(3) then (1). Observability first because it is cheap, it makes the failure mode visible in any environment, and it would have surfaced this without anyone reasoning about it. Then the explicit release, which is the actual fix. Raising the default in isolation is the tempting move and it is the one that risks exhausting a host.
Notes
- Found while reviewing P4 microVM tier: working memory cannot span a session's turns (workspace is keyed per run) #267, whose premise (workspace keyed per run) is stale — the keying is right, the lifetime is the gap.
- Relevant to P4 microVM tier: per-
ExecVM lifetime is finer-grained than the design needs — worth a separate architecture pass #274: the session already owns the workspace (WorkspaceIdle) and the standby pool (StandbyIdle). Anything that lengthens VM lifetime should be scoped to the session rather than adding a third lifetime, and a session-scoped VM makes this TTL question sharper rather than softer.
Activity
pdettori commentedon Sep 30, 2026
From the #369 live run (PR #376) on the KVM rig:
m8i.xlarge, Amazon Linux 2023, Firecracker v1.17.0,2026-09-30.
workspace.imgis 2 GiB apparent and 66 MiB actually on disk after a short session: a
git init, a commitand a few small files, on a freshly
mkfs'd ext4 of 2 GiB. The number grows with what a sessionwrites, so it is a lower bound for real workloads, not a typical value.
SH_WORKSPACE_IDLE(a Go duration)sets
WorkspaceIdleon microvm-worker.StandbyIdleis refused byNormalize.deploy/microvm/setup-microvm.shwrites8h.admission-controlled. The knob buys time; it does not replace option 3 (an observable reset) or
option 1 (an explicit release).
feat(microvm-worker): SH_WORKSPACE_IDLE sets the workspace idle lifetime
pdettori commentedon Oct 2, 2026
Narrowing the scope after #370, which closed on 2026-10-01.
Mitigated, for the demo path:
SH_WORKSPACE_IDLE(#376) lets the worker keep a workspace longer, andsetup-microvm.shwrites8h. A HITL session on adeploy/microvminstall no longer loses its workspace after 30 minutes. The code default is still 30 minutes, and the reset is still silent when it fires.What this issue still needs:
/workspace.Release{workspace_key}wire path, so a session's end frees its workspace instead of waiting for idle reclaim.A third gap, found in the #412 review: a restarted worker never reclaims at all. Idle reclaim walks only the worker's in-memory runs map (
remote-worker/internal/vmpool/sweep.go:36). A restarted worker starts with an empty map and "never sweeps a directory it does not know about" (vmpool/workspace.go:83-85). A session delete touches only Redis (packages/control-plane/src/ownership.ts,cascadeDelete). So across a worker restart, every session's workspace stays on disk indefinitely. That's a disk leak, and the users' files outlive their sessions.The demo runbook (
docs/demos/vm-multi-user-demo.md, Cleanup) now deletes the run's workspaces by hand for this reason. The explicit release in item 2 would cover it, as long as the release survives a restart, for example as a sweep of directories with no live session at worker start.feat(remote-worker): run each session in its own workspace directory …
docs: address review on the concepts pages
fix: scope the capacity latch to sandbox tools, correct the memory model
webchang commentedon Nov 17, 2026
@pdettori, a status check on what's left here, and four ways to close it. Each needs your call before anyone writes code.
Where it stands on main
deploy/microvm) is mitigated as you noted:setup-microvm.shwritesSH_WORKSPACE_IDLE=8h.remote-worker/internal/exec/workspace.gokeepsDefaultWorkspaceIdle = 30 * time.Minute. The container worker readsSH_WORKSPACE_IDLE(cmd/worker/main.go), but nothing underdeploy/sets it outsidedeploy/microvm. So a HITL session on adeploy/k8sstack that waits more than 30 minutes for a person still resumes in an empty workspace, with no signal./workspace/<sessionId>/directories accumulate on sandbox pods for workload runs #551) removes only empty session directories early; it doesn't change when a directory with files goes.Options
rm -rf.Release{workspace_key}frame sent when a session ends, as P4 §9 anticipated. Idle reclaim then becomes a long backstop, and a longSH_WORKSPACE_IDLEis affordable. It also covers the restarted-worker leak if the worker sweeps unknown directories at start. It's a wire change, plus a session-end hook in the harness and the control plane, which has no path to the worker today. This is the same release/workspace/<sessionId>/directories accumulate on sandbox pods for workload runs #551's remaining part needs, so one design could close both.deploy/k8ssetsSH_WORKSPACE_IDLE(for example8h, asdeploy/microvmdoes) throughmoca-settings. A small change that removes the 30-minute cliff on the container tier, but the reset stays silent when it fires and disk stays unbounded, so it narrows this issue rather than closing it.Our suggestion: (4) now, as a small PR, since it matches what the microVM tier already does. Then (2) or (1) for the signal: (2) if a convention is acceptable, (1) if you want it in the protocol. Then (3) together with #551. Which would you like?
pdettori commentedon Nov 17, 2026
@webchang I am ok with 4, 2 and then 3 with #551 as suggested
fix(remote-worker): remove an empty per-session workspace no process …
docs: rewrap the workspace paragraph in brain-and-hands
feat(k8s): set the container sandboxes' SH_WORKSPACE_IDLE, default 8h
Merge pull request #882 from webchang/pr/i338-k8s-workspace-idle
evaline-ju commentedon Nov 18, 2026
#551 is closed: #613 and #872 handle its empty-dir case. Its remaining part, freeing a non-empty session workspace when the session ends, is now tracked only here, as option 3 (the release signal).
fix(harness): the reset note beside the prompt; rewrite the marker af…
20 remaining items
Merge pull request #954 from webchang/pr/i338-startup-sweep
pdettori commentedon Nov 23, 2026
@webchang thanks — (a) on all four, with these conditions:
MOCA_RELAY_CONTROL_ADDRis set, one route, its own Service + NetworkPolicy. Return the worker's ack (released / kept_busy / unknown_key) in the response, andrelease_unsupportedas a distinct status, so the control plane can audit the outcome.releasedAtonly on a terminal answer from the worker (released, kept_busy, unknown_key, unsupported), not on send. A transport failure leaves it unset, so the next sweep retries while the record is retained.deleteSandboxuses the same path aftermarkDeleted. Note in the PR that expiry is noticed only when the host janitor sweeps; elsewhere idle reclaim is the backstop.sandboxPod, elsesandboxId; otherwise nothing. Read them before the cascade, but send the release only after the session delete commits: since a released key refuses new Execs, a release followed by a failed delete would strand a live session. Add an audit line when no worker is recorded.sbx-egress/sbx-template-hosts, generated by both setup scripts, with the boot-time refusal if it matches any other bearer.In every case the release is best-effort with a short bound, and it never fails or delays the DELETE beyond that bound.
fix(control-plane): clear CodeQL's alerts on the relay releaser (ross…
fix(control-plane): a session release's audit line names its worker a…
docs(control-plane): which workspace a session's release reaches, and…
docs(harness): name the coupling between the empty workspace key and …
feat(sandbox-relay): a release-only control listener for the control …
feat(control-plane): release an ended sandbox's or session's workspac…
feat(deploy): the relay's release listener behind a switch in both se…
docs: the relay's release listener and the control plane's workspace …
fix(control-plane): a DELETE never waits on its release; one sender p…
fix(control-plane): the release bearer must differ from every control…
fix(sandbox-relay): answer 413 before closing; throttle refused-beare…
docs: the release listener's one-time control-plane roll, and DELETE …
Merge pull request #1003 from webchang/pr/i338-release-cp