Skip to content

feat(adapters): pause/resume on agent-sandbox warm pools with GKE Pod Snapshots - #136

Merged
reachjalil merged 1 commit into
pre-releasefrom
feat/agent-sandbox-warm-pod-snapshots
Nov 21, 2026
Merged

reachjalil merged 1 commit into
pre-releasefrom
feat/agent-sandbox-warm-pod-snapshots

Conversation

@reachjalil

Copy link
Copy Markdown
Member

Fast start and snapshot-backed pause on GKE, together. Until now the agent-sandbox adapter refused warmPool combined with podSnapshotPolicy, so a pool had either sub-second warm starts or checkpointing pauses, never both.

What changes

  • A pool with both settings claims a running warm pod, and pauses it into a GKE pod snapshot. The pause deletes the pod and frees its node resources; resume restores the checkpoint into a new pod.
    • It offers lifecycle.pause-resume and lifecycle.pause-checkpoint.
    • It doesn't offer snapshots or fork: a claimed pod is already running, so nothing can be restored into it.
  • Isolation stays fail-closed. A warm pod has no snapshot group until it's claimed, so GKE never restores it. The claim then gives it a group of its own through additionalPodMetadata. The policy checks from feat(adapters): snapshots, fork and pause/resume on GKE for agent-sandbox #131 still apply.
  • Where things are written. agent-sandbox's claim controller rewrites the claimed Sandbox's pod template from the template and the claim on every pass (read in its source, then confirmed on a real controller). So the group and ps-name go through the claim, the adapter's annotations go on the claim, and only operatingMode is set on the Sandbox.
  • Patch ordering. A pause writes the claim first and suspends last. Undoing a pause, or suspending an unverified resume, sets the mode first.
  • State and listing. A paused claim reads its state from its Sandbox. It follows the controller when it adopts a new Sandbox, and never fails the whole List.
  • Health checks that the warm pool's SandboxTemplate sets a runtimeClassName.
  • Faster creates. Claims are polled every 100 ms instead of 500 ms, so a create from a warm pool took 110 ms on kind, down from 510 ms. This benefits warm pools with or without snapshots.
  • Setup requirement. differently.dev must be in agent-sandbox's allowed-label-domains. A create refused for that names the fix.
  • The docs drop a stale "Pod Snapshot extension not wired" line left over from before feat(adapters): snapshots, fork and pause/resume on GKE for agent-sandbox #131.

Verification

  • Fake API (every go test): the fake claim controller now behaves like the real one.
    • It adopts a separate warm Sandbox whose pod starts without a group.
    • It checks label domains, rewrites the template from the claim, re-adopts when the Sandbox is gone, can lag, and can refuse claim patches.
    • New tests: pause/resume through the claim, an unrestored resume, re-adoption followed by recovery, an unreadable Sandbox, a lagging controller, a failed claim patch, the health checks, and refused snapshot/fork.
    • Each guard was removed once to confirm its test fails.
  • agent-sandbox v1.0.12 on kind (Kubernetes 1.37, runc, a RuntimeClass named gvisor with the runc handler), by hand:
    • The differently.dev label is refused until it's allowlisted.
    • The label reaches the running warm pod in 0.2 s, with the same UID and no restart.
    • ps-name set on the claim reaches the Sandbox's template, and so does its removal.
    • Suspending the claimed Sandbox isn't undone by the claim controller.
    • Resume creates a new pod carrying the group and ps-name, which is what GKE restores from.
  • The adapter itself on kind, with stand-in podsnapshot.gke.io CRDs and a loop that marks each trigger's PodSnapshot ready:
    • Health, then create in 110–120 ms.
    • Pause in 1.5–3 s, reported as paused by both Get and List.
    • A resume that, with nothing restored, finds the marker missing and suspends the sandbox again.
    • A delete that removes the claim, the trigger and the snapshot.
  • Review: an independent review of the first version found the patch-ordering, list, lag and re-adoption issues, all fixed and covered above. It found no cross-tenant restore path.
  • Checks: make verify and the site build pass.

Not run: GKE itself, meaning real checkpoints, restores and gVisor. TestLivePodSnapshots is still unrun.

🤖 Generated with Claude Code

… Snapshots

A pool with both warmPool and podSnapshotPolicy claims a running warm pod
and pauses it into a GKE pod snapshot that frees its node resources, so
fast starts and checkpointing pauses combine. Snapshots and fork are not
offered there: a claimed pod is already running, so nothing can be
restored into it.

The claim controller rewrites the claimed Sandbox's pod template from the
template and the claim on every pass, so the snapshot group and the
checkpoint to restore go into the claim's additionalPodMetadata, the
adapter's annotations onto the claim, and only the operating mode onto the
Sandbox. A pause writes the claim first and suspends last; undoing a pause
or suspending an unverified resume sets the mode first. A paused claim
reads its state from its Sandbox, follows the controller when it adopts a
new one, and never fails the whole List. Health checks the warm pool's
template runs under a RuntimeClass, and a create the controller refuses
for its label domain says how to allow it.

Claims are polled every 100 ms: a create from a warm pool took 110 ms on
kind, down from 510 ms.

Tested with the fake (whose claim controller now adopts separate warm
Sandboxes, checks label domains, can lag and can refuse patches) and, by
hand, against agent-sandbox v1.0.12 on kind with a stand-in for GKE's
snapshot controller. Not run on GKE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jalil <reachjalil@gmail.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI passed at 82e5dc0.

@reachjalil
reachjalil merged commit 7308217 into pre-release Nov 21, 2026
22 checks passed
@reachjalil
reachjalil deleted the feat/agent-sandbox-warm-pod-snapshots branch November 21, 2026 00:26
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.

1 participant