Skip to content

Commit 117078f

Browse files
authored
feat(cloud-workers): warm project seeds and automatic image refresh (#131744)
* feat(cloud-workers): warm project seeds and automatic image refresh * fix(cloud-workers): keep seed freshness on the store clock and cover slow captures
1 parent 9a7de4d commit 117078f

14 files changed

Lines changed: 1126 additions & 148 deletions

‎docs/gateway/cloud-sessions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Two profile settings turn cloud workers from always-on machines into compute tha
5454
- `suspendAfter: "2h"` — after the session has been idle for the duration, the Gateway performs the same safe stop as **Stop cloud worker…**: it reconciles the workspace first, then releases the machine. While suspended, you pay for retained snapshot storage only. The next message provisions a replacement automatically — no button to press.
5555
- `settings.warmImage: true` — capture a scrubbed machine image when a worker stops, and start later workers for the same profile from that image instead of provisioning cold. Paired with `suspendAfter`, a suspended session wakes on a warm machine in a fraction of the cold provisioning time.
5656

57+
With warm images enabled, repeat sessions for the same repository can also avoid a fresh clone. For clean workspaces eligible for the published-origin path, node-tunnel sync copies the machine's per-repository Git seed, fetches only the Git delta, and checks out the requested commit. Other workspaces keep the normal sync path.
58+
5759
Suspension never interrupts work: sessions with an active turn, queued messages, or unreconciled results are skipped and re-checked on the next sweep. See the profile fields in [Cloud Workers](/gateway/cloud-workers#configuration) for costs, capture boundaries, and prerequisites.
5860

5961
## What stays with the Gateway

‎docs/gateway/cloud-workers.md‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,21 @@ Add a profile under `cloudWorkers.profiles` in `openclaw.json`:
122122

123123
Profile fields:
124124

125-
| Key | Meaning |
126-
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127-
| `provider` | Worker provider id registered by a plugin (`crabbox` for the bundled plugin). |
128-
| `install` | Installation preference for SSH-backed providers. The bundled Crabbox provider always installs the current Gateway bundle through the authenticated node channel. |
129-
| `suspendAfter` | Optional idle duration, such as `45m`, `90m`, or `2h`; minimum `1m`. Automatically suspend an idle worker using the same safe stop as manual reclaim. The next message provisions a replacement, warm when a snapshot exists. While suspended, only retained snapshot storage is billed; omit this field to keep workers running until explicitly stopped. |
130-
| `settings` | Provider-owned JSON. For crabbox: `provider` (backend), `class` (machine class), `ttl`, `idleTimeout` (Go durations), optional idempotent `setup`, optional `desktop`, and absolute `binary` path. While a session remains placed, OpenClaw heartbeats its lease at a safe fraction of `idleTimeout`; teardown stops the heartbeat before releasing the machine. `desktop: true` asks Crabbox to warm the lease with its browser and loopback RFB desktop before node enrollment. |
131-
| `settings.warmImage` | Optional, disabled by default. Set to `true` to save a reusable machine image when an enrolled worker stops and start later workers with the same profile from that image — pair it with `suspendAfter` so suspended sessions wake warm. Images incur snapshot storage charges in your cloud provider account. OpenClaw removes worker identities, device tokens, bundles, and all workspace files before capture, but the image also retains whatever `settings.setup` wrote elsewhere on the machine, so keep setup credential-free and enable reuse only for mutually trusted workloads. Capture adds at most about three minutes to a stop on providers with slow native snapshots, then degrades to cold-only provisioning. Capture needs a Crabbox release with fixed-ID checkpoint forks, and coordinator-brokered leases additionally need `broker.adminToken`; without either, every stop degrades to normal cold provisioning with one warning. |
125+
| Key | Meaning |
126+
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
127+
| `provider` | Worker provider id registered by a plugin (`crabbox` for the bundled plugin). |
128+
| `install` | Installation preference for SSH-backed providers. The bundled Crabbox provider always installs the current Gateway bundle through the authenticated node channel. |
129+
| `suspendAfter` | Optional idle duration, such as `45m`, `90m`, or `2h`; minimum `1m`. Automatically suspend an idle worker using the same safe stop as manual reclaim. The next message provisions a replacement, warm when a snapshot exists. While suspended, only retained snapshot storage is billed; omit this field to keep workers running until explicitly stopped. |
130+
| `settings` | Provider-owned JSON. For crabbox: `provider` (backend), `class` (machine class), `ttl`, `idleTimeout` (Go durations), optional idempotent `setup`, optional `desktop`, and absolute `binary` path. While a session remains placed, OpenClaw heartbeats its lease at a safe fraction of `idleTimeout`; teardown stops the heartbeat before releasing the machine. `desktop: true` asks Crabbox to warm the lease with its browser and loopback RFB desktop before node enrollment. |
131+
| `settings.warmImage` | Optional, disabled by default. Set to `true` to save a reusable machine image when an enrolled worker stops and start later workers with the same profile from that image. Pair it with `suspendAfter` so suspended sessions wake warm. Images incur snapshot storage charges. See [Warm images](/gateway/cloud-workers#warm-images) for capture boundaries, refresh, and prerequisites. |
132+
133+
### Warm images
134+
135+
Warm images work on `machine0` through Crabbox's `--strategy image`; other backends keep their native checkpoint strategy. Images refresh automatically at the next eligible worker stop once they are 24 hours old, keeping captured caches current. After recording the replacement, OpenClaw deletes the superseded checkpoint on a best-effort basis. A deletion failure warns and leaves cleanup to Crabbox's `checkpoint prune`. OpenClaw also retains its 14-day cleanup for unused images. A failed refresh preserves the previous image for later forks.
136+
137+
Before capture, OpenClaw removes per-lease worker identities, device tokens, and session state, including node-host workspaces and SSH-transport workspaces under `~/.openclaw-worker/workspaces`. Machine-level caches intentionally survive: npm caches, content-addressed worker bundle installs under `~/.openclaw-worker`, and per-repository Git seeds under `~/.openclaw-worker/git-seeds`. A seed is a pristine post-sync repository copy, not a session snapshot. Images also retain whatever `settings.setup` wrote elsewhere, so keep setup credential-free and enable reuse only for mutually trusted workloads.
138+
139+
Scrubbing has a three-minute timeout. Checkpoint creation has a separate three-minute timeout, extended to ten minutes on `machine0` because image capture stops the source and waits for image availability even with `--wait=false`. Capture failure does not prevent teardown; without a usable image, later workers provision cold. Capture needs a Crabbox release with fixed-ID checkpoint forks, and coordinator-brokered leases additionally need `broker.adminToken`; without either, capture degrades to cold-only provisioning with a warning.
132140

133141
### Per-project default profiles
134142

‎docs/plan/worker-hibernation.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ read_when:
88

99
## Status
1010

11+
Implementation update (2026-08-28): warm images support `machine0` through
12+
`--strategy image`, refresh automatically at the next eligible teardown after
13+
24 hours, and delete superseded checkpoints after replacement. Scrubbing now
14+
also removes SSH-transport session workspaces under
15+
`~/.openclaw-worker/workspaces`. Core node-tunnel sync adds per-repository Git
16+
seeds: pristine post-sync repository copies stored outside the scrub root at
17+
`~/.openclaw-worker/git-seeds`, alongside retained machine-level caches. These
18+
extend warm starts, not phase-2 per-session hibernation, which remains gated;
19+
the historical phase-1 scrub description below predates this cache boundary.
20+
1121
Accepted 2026-08-26 (maintainer: "build live test document PR land"). Phase 1
1222
is implemented in `extensions/crabbox/` and live-proven; phases 2 and 3 remain
1323
gated as designed. Written from direct source inspection of this repo and the

0 commit comments

Comments
 (0)