Skip to content

Checkpoint a Managed Agents computer on park and roll it back on restart - #2156

Merged
16francej merged 3 commits into
yc-software:managed-agents-sandbox-backendfrom
gane5hvarma:managed-agents-checkpoint
Oct 9, 2026
Merged

16francej merged 3 commits into
yc-software:managed-agents-sandbox-backendfrom
gane5hvarma:managed-agents-checkpoint

Conversation

@gane5hvarma

@gane5hvarma gane5hvarma commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • On used-turn teardown, qm calls POST /v2/agents/sessions/{id}/checkpoints (CreateCheckpoint) before the portable home tar and pause. The call is throttled by DO_AGENTS_SNAPSHOT_INTERVAL_SEC (default five minutes). There is no timer; a turn that never opens the computer does not capture.
  • A successful capture stores the checkpoint id and deletes the previous one, so only the newest remains. A failed delete is remembered and retried on a later teardown. Checkpoint throttling is independent of the home tar, so a failed tar retries without taking another checkpoint.
  • A capture failure is recorded on recovery.error and the session still pauses. The portable tar remains the recovery path when the session itself is gone, because a checkpoint is bound to its session.
  • sandbox action=restart calls POST /v2/agents/sessions/{id}/checkpoints/{checkpoint_id}/rollback with the stored checkpoint. The session id stays, the response's sandbox id replaces the stored one, and any open port-forward is closed. Restart does not take a new checkpoint first. A paused session is rolled back directly. Restart with no stored checkpoint fails and leaves the session as it is.

Stacked on #2128.

Test plan

  • node --experimental-test-module-mocks --test test/managed-agents-sandbox.test.ts test/managed-agents-client.test.ts (58 passed)
  • Live smoke (scripts/managed-agents-sandbox-smoke.ts) against a real Managed Agents token, confirming teardown returns a READY checkpoint before pause and doctl harness-runtime rollback rewinds that session onto a new sandbox

The portable home tar survives a destroyed session, but it is not the provider's machine-state checkpoint. Call CreateCheckpoint while the session is still running so the live microVM is captured before pause.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Checkpoint throttling breaks after snapshot failures, and failed checkpoint deletions cannot be retried.

2 open findings
What changed in this PR

Adds Managed Agents checkpoints during teardown while retaining portable home snapshots as the cross-session recovery path.

Changes:

  • Adds checkpoint creation, validation, deletion, and durable status metadata.
  • Captures checkpoints before home snapshots and pause.
  • Expands fake services, tests, and preservation documentation.
File Description
src/​sandbox/​managed-agents-client.ts Adds checkpoint REST operations.
src/​sandbox/​managed-agents-sandbox.ts Integrates checkpoint lifecycle into teardown and status.
test/​managed-agents-client.test.ts Tests checkpoint API behavior.
test/​managed-agents-sandbox.test.ts Tests teardown capture, failure, throttling, and replacement.
test/​support/​fake-managed-agents.ts Adds checkpoint support to the sandbox fake.
test/​support/​fake-managed-agents-service.ts Implements fake checkpoint HTTP routes.
docs/​sandbox-preservation.md Documents checkpoint-based preservation.
adrs/​managed-agents-sandbox-backend.md Updates the backend architecture flow.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/sandbox/managed-agents-sandbox.ts Outdated
Comment thread src/sandbox/managed-agents-sandbox.ts Outdated
gane5hvarma and others added 2 commits October 9, 2026 11:34
A failed delete used to drop the only reference to the previous checkpoint, and a failed home tar cleared the capture throttle because both shared lastSnapshotMs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restart calls the harness rollback API so the same session boots a new microVM from the stored capture.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gane5hvarma gane5hvarma changed the title Capture a Managed Agents checkpoint on teardown Checkpoint a Managed Agents computer on park and roll it back on restart Oct 9, 2026
@16francej
16francej merged commit def4b84 into yc-software:managed-agents-sandbox-backend Oct 9, 2026
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.

3 participants