Skip to content

perf(skills): reuse unchanged sandbox skill snapshots - #121379

Merged
steipete merged 1 commit into
mainfrom
steipete/jolly-stonebraker-bf8098
Aug 10, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/jolly-stonebraker-bf8098

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Sandboxed agent attempts rediscover every eligible skill, wipe the sandbox skill tree, and recursively copy the same files again on every turn even when the watched skill snapshot has not changed. The same hydration path also serializes, redacts, and hashes the whole config repeatedly to rediscover an unchanged fingerprint.

Why This Change Was Made

The watcher already owns the authoritative skill snapshot version, so sandbox synchronization now pairs that version with a small persisted entry-identity manifest. Safe destination and read paths remain process-owned, unchanged entries are retained, and version or identity changes trigger an incremental reconcile. Config fingerprints are memoized by config object identity in a WeakMap and reset only by the applied-config lifecycle owner, so source-only reload work cannot evict the active runtime's memo.

This is AI-assisted work. The final rebased diff was inspected, focused-tested, and passed the repository autoreview gate with no accepted or actionable findings.

User Impact

Repeated sandboxed turns reuse unchanged skill trees instead of rediscovering and recursively copying them. This lowers turn setup latency and filesystem churn without adding or changing configuration.

Evidence

  • Final rebased head focused proof:
    • node scripts/run-vitest.mjs src/skills/loading/workspace-sync.test.ts src/agents/sandbox.resolveSandboxContext.test.ts src/agents/embedded-agent-runner/run/attempt-setup.test.ts src/skills/runtime/snapshot-config-fingerprint.test.ts — 37 tests passed across four shards.
    • node scripts/run-vitest.mjs src/gateway/server-reload-handlers.test.ts -t 'applies a current in-process hot config|refreshes owner refs when only the resolved source snapshot changes' — 2 passed, 208 unrelated tests filtered.
    • git diff --check origin/main...HEAD — clean.
  • Mandatory autoreview on the final rebased branch diff — clean, no accepted/actionable findings; patch correct 0.98.
  • Changed gate before rebase: Blacksmith Testbox tbx_01kzmrza9nsfj2fqjnabn2t01d, Actions run 31350660086 — green.
  • Real behavior/performance proof before rebase: Blacksmith Testbox tbx_01kzmsw3jc47yzzpbxfj5gbyt6, sync sync_67e828304b5d, Actions run 31351394396.
    • Five real Gateway-backed, Docker-sandboxed session pairs with isolated state directories and ports, a local mock OpenAI-compatible provider, 120 prompt-hidden skills, and 1,560 files.
Five-sample median Baseline Patch Change
Attempt setup 244.451 ms 22.497 ms 90.8% faster
Embedded turn 424 ms 200 ms 52.8% faster
Recursive copies 141 0 eliminated

The behavior comparison used baseline 8430fc0e3b864dee6840cf663d3724f5cbcc7076 and pre-rebase head d7cdb2e60b7a1ed0e46d9e4c8f82bde4f2d122cf plus dirty diff SHA-256 dcb28dc2f7ff2fceb1ad97c7a048534f1911e3d1f9d953bc21e954a60b876893; the lease stopped cleanly. Limitation: the performance run predates the final rebase. The source patch applied without conflict, the generated SDK baseline was regenerated against current main, and focused tests plus autoreview were rerun on the final head. Exact-head PR CI remains the authoritative landing gate.

Production LOC is +205/-42 (net +163); tests are +333/-1; the generated SDK hash baseline is +3/-3. The positive production growth establishes the ownership/performance invariant: a process-owned safe-path cache and identity-only manifest make unchanged reuse possible, while version changes, entry changes, and interrupted copies still reconcile safely. The added tests cover reuse, tamper resistance, incremental add/remove, watcher refresh, interrupted copy recovery, sandbox snapshot plumbing, and config-apply invalidation.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 10, 2026 03:40
@steipete
steipete requested a review from a team as a code owner August 10, 2026 03:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime docker Docker and sandbox tooling agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 10, 2026
Gate reuse on the watcher-owned snapshot version and persisted entry manifest, while keeping safe paths process-owned and reconciling only changed skills.

Cache config fingerprints by object identity and reset them at the applied-config lifecycle owner.
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 11:54 PM ET / August 10, 2026, 03:54 UTC.

ClawSweeper review

What this changes

The PR reuses a versioned sandbox-skill snapshot and cached config fingerprint so unchanged sandboxed agent turns avoid rediscovering and copying skill trees.

Merge readiness

✅ Ready for maintainer review

No actionable correctness or security finding was identified. This maintainer-owned PR remains necessary for repeated sandbox setup performance; let exact-head CI complete before normal maintainer review.

Priority: P2
Reviewed head: 697e26ce0a89a6803224586d3cdcfb817b181ac6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows the synchronization owner boundary with focused recovery coverage and no discrete review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR includes a Gateway/Docker performance comparison in its body; exact-head CI remains the normal landing gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes a Gateway/Docker performance comparison in its body; exact-head CI remains the normal landing gate.
Evidence reviewed 6 items Current-main performance premise: Current main always clears the target skill directory, rediscovers entries, and recursively copies each skill during sandbox synchronization.
Fast-path owner boundary: The PR requires a matching snapshot version, identity-only manifest, and same-process usage cache before it skips discovery; otherwise it reconciles the copied tree.
Sandbox integrity boundary: Writable sandbox workspaces overlay materialized skills as read-only, so sandbox commands cannot alter the reused skill tree.
Findings None None.
Security None None.

How this fits together

A session snapshot describes the skills available to an agent turn. Sandbox setup materializes those skills into a read-only workspace tree before the embedded agent reads or invokes them.

flowchart LR
A[Session skill snapshot] --> C[Sandbox setup]
B[Skills watcher version] --> C
C --> D[Manifest and cache check]
D -->|changed| E[Reconcile copied skills]
D -->|unchanged| F[Reuse materialized skills]
E --> G[Read-only sandbox skills]
F --> G
G --> H[Embedded agent turn]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +163, Tests +332, Generated 0. Total +495 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 205 42 +163
Tests 5 333 1 +332
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 3 3 0
Other 0 0 0 0
Total 13 541 46 +495

Review metrics

Metric Value Why it matters
Production versus test LOC production +205/-42 (net +163); tests +333/-1; generated baseline +3/-3 The production growth implements the cache and reconciliation ownership boundary; the larger test delta covers reuse and recovery cases.

Stored data model

Persistent data-model change detected: serialized state: src/skills/runtime/session-snapshot.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the versioned-manifest synchronization after the current-head CI gate is green, retaining its process-owned cache and read-only skill-mount boundary.

Do we have a high-confidence way to reproduce the issue?

Yes—current main visibly clears, rediscovers, and copies the sandbox skill tree for every synchronization; the PR's focused tests encode the unchanged-snapshot case.

Is this the best way to solve the issue?

Yes—the synchronization owner receives the watcher-owned snapshot and decides reuse from version, manifest identity, and process-owned paths, avoiding a duplicate cache layer at callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 592bf90b079c.

Labels

Label justifications:

  • P2: This is a bounded performance improvement to repeated sandbox setup rather than an urgent runtime failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR includes a Gateway/Docker performance comparison in its body; exact-head CI remains the normal landing gate.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame and the dominant history for sandbox skill synchronization, session snapshots, and sandbox context converge on Peter Steinberger. (role: recent area contributor; confidence: high; commits: d7cdb2e60b7a, 2d5c24bc297d; files: src/skills/loading/workspace.ts, src/skills/runtime/session-snapshot.ts, src/agents/sandbox/context.ts)
  • Vito Cappello: Authored the recent lazy skill-snapshot cache-key work adjacent to the fingerprint optimization. (role: adjacent cache contributor; confidence: medium; commits: ac795a5821b1; files: src/skills/runtime/session-snapshot.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-10T03:46:28.950Z sha cb3b44a7f49c384c616ba02f57c2bd4771f042ca :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/jolly-stonebraker-bf8098 branch from cb3b44a to 697e26c Compare August 10, 2026 03:48
@steipete
steipete merged commit 232281f into main Aug 10, 2026
126 of 128 checks passed
@steipete
steipete deleted the steipete/jolly-stonebraker-bf8098 branch August 10, 2026 04:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
Gate reuse on the watcher-owned snapshot version and persisted entry manifest, while keeping safe paths process-owned and reconciling only changed skills.

Cache config fingerprints by object identity and reset them at the applied-config lifecycle owner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant