perf: bake vm-agent into instant container image to cut cold-start latency#1566
Merged
simple-agent-manager[bot] merged 8 commits intoJul 12, 2026
Merged
Conversation
Contributor
Autofix simple-import-sort in the deploy-reusable workflow contract test and apply prettier table alignment to the architecture overview doc so the lint and format CI gates pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes HIGH and consensus-MEDIUM findings from the specialist review of the baked vm-agent container image: - test: assert the image bakes no secrets (no ARG / secret-bearing ENV) and that vm-agent-version.json carries only build metadata (test-engineer H1) - test: add behavioral vm-agent-bootstrap.sh tests exercising the fail-fast missing-artifact path and the success path (test-engineer H2). Parameterize the bootstrap binary/version/state paths (env with prod defaults) so the script is executable in a test sandbox - test: assert timing monotonicity + all timing fields, and add a launch failure-path test proving the container is destroyed and the workspace is marked error (test-engineer H3/M1) - ci: version R2 vm-agent binaries with $GITHUB_SHA so they match the container-baked binary; assert Go setup precedes prepare-container and the version parity in the workflow contract test (4-reviewer consensus) - build: make prepare-container sha256 portable (sha256sum or shasum) - docs: mark setup/install timings as deprecated aliases; note the container image bakes the binary so /api/agent/download is VM/cloud-init only; add the bake step to the deploy pipeline diagram; document the local docker build prerequisite in the Dockerfile Deliberately NOT adding runtime sha256 verification in the bootstrap: the Makefile computes the digest from the same binary it bakes in the same step, so a binary<->version.json comparison cannot fail from a supply-chain angle, and hashing a ~25MB binary on every boot works against the cold-start goal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
151a952 to
fc22f3e
Compare
|
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Materially reduces instant Cloudflare Container cold-start latency by removing the per-container network install of
vm-agentand baking the deployment-built binary into the runtime image. It also adds bounded phase timings so the remaining latency is attributable.Key changes:
vm-agentbefore Wrangler deploy, then copies the binary andvm-agent-version.jsonintoDockerfile.vm-agent-container.totalDurationMs,preContainerDurationMs, andcontainerLaunchDurationMs, while retaining deprecated response aliases for compatibility.Validation
ad7044fde(PR Phase 3a: runtime-neutral session hibernate/wake #1562); rebased tree matched the reviewed merge resolutionpnpm lintpnpm typecheckpnpm test(404 API files / 5,918 tests; 217 web files / 2,668 tests)pnpm build/usr/local/go/bin/go test ./...with Go 1.25.0/healthreturned healthy and baked bootstrap-ready telemetry emitted in 3 msStaging Verification (REQUIRED — merge-blocking)
Staging Verification Evidence
Deployment run 29185746568 passed Cloudflare deploy, backup/count baseline, migration integrity, API health, and Playwright smoke tests. It deployed implementation commit
fc22f3e80c8ab436cab63e3e50fdf1008b24554cwith baked artifactsha256:3653de9b288c7bed684b72dc84fd0f033835f0170cf19e58a479b9984554e949andVmAgentContainerimage digestsha256:b50c3fb289b42c39284ea07dd85f7af073119953aeaf4b6ee7a53dba1a04d408.A fresh launch created node
01KXAQFTDZBGFGPX5XZ0RSYTC9, workspace01KXAQFTJW9YVZCVB1A8T5JXJP, and session1637b2b0-a9cb-4e56-b0ad-5c7733dc4fa1. The API returned HTTP 201 and the agent completed a real response.Post-change phase slices: pre-container 724 ms; container launch 2,584 ms; agent-ready 567 ms; workspace create 2,898 ms; ACP session create 2,237 ms; ACP session start 842 ms.
Authenticated browser checks for dashboard, the new session, and project agent settings all returned HTTP 200. Session content rendered with no unexpected console, page, or network errors. The API health endpoint returned HTTP 200/healthy. The temporary session was stopped; staging D1 confirmed the node was deleted and its workspace row removed.
The result is materially improved but remains above the <5s target. Evidence and the next dominant slices (workspace creation, container launch, ACP creation) were appended to SAM idea
01KX6JK8ZFC1EFWGYQENRMFWFKrather than claiming the target was met.End-to-End Verification (multi-component)
pnpm quality:observability-noisefound no significant noise; D1/Workers telemetry subchecks were explicitly unavailable in this environmentSpecialist Review Evidence (agent-authored PR)
sha256sum/shasumfallback addedNo reviewer is pending or failed. All CRITICAL/HIGH findings were addressed.
Post-Mortem
N/A: performance and observability improvement, not an incident fix.
Agent Preflight (Required)
Classification
External References
N/A: this uses the repository's existing Cloudflare Containers, Wrangler, Go, and Make deployment path.
Codebase Impact Analysis
Documentation & Specs
Updated architecture overview, API reference, and self-hosting guide for baked artifact/version behavior.
Constitution & Risk Check
Generated version metadata derives from the deployment commit; artifact paths remain configurable; no new manual secret or environment prerequisite was added. Missing/mismatched baked artifacts fail fast and are observable rather than silently downloading on the cold path.