feat(sandbox): make E2B cloud isolation runnable + lease correctness fixes - #256
Merged
Conversation
…fixes Adds a reproducible e2b template build (infra/sandbox/e2b.Dockerfile + make e2b-template) so cloud isolation can be stood up end-to-end, and fixes lease-lifecycle bugs found while getting it working live. - auto-renew defaults ON (fail-open); opt out with AGENT_DAEMON_SANDBOX_AUTO_RENEW=false - Maintain(): transient renew errors retry (never permanently disable); 405/501 (e2b.IsUnsupported) disable; 404 marks killed + evicts - persist real sandbox id right after Create (SetSpawningSandboxBindingSandboxID) to close the crash-before-Finalize cost leak - maintenance batch size 2 -> 50; compose/.env aligned to AGENT_DAEMON_SANDBOX_* names the server actually reads - CreateAgentDialog sandbox auto-renew toggle; CONTRIBUTING sandbox/image rules
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.
What & why
The agent_daemon connector already had E2B client/provider code, but no
committed, reproducible way to build the sandbox template it needs (no
e2b.Dockerfile, no make target), so cloud isolation could not be stood up
end-to-end. Self-host compose also passed
PARSAR_E2B_TEMPLATE_ID, a namethe server never reads (it reads
AGENT_DAEMON_SANDBOX_TEMPLATE), silentlydisabling managed sandbox mode. This PR makes cloud isolation actually
runnable and fixes several lease-lifecycle correctness bugs found while
getting it working live.
How
infra/sandbox/e2b.Dockerfiletargetse2b's non-BuildKit builder: no multi-stage, no persisted
/tmp,literal-quote ARG lowering; it COPYs prebuilt linux/amd64 binaries staged
into
infra/sandbox/.build/(gitignored) bymake e2b-template. AgentCLI installs stay single-sourced in
scripts/install-agents.sh, sharedby both Dockerfiles.
AGENT_DAEMON_SANDBOX_AUTO_RENEW=false. Default TTL is 1h, so withoutrenewal a continuously-used agent's sandbox would be reaped mid-session.
Maintain()renew errors: transient → leaverenewingfor thecrashed-claim recovery re-claim (retries, never permanently disables);
provider-unsupported (405/501 via new
e2b.IsUnsupported) → disablepolicy; gone (404) → mark killed + evict, freeing the reservation slot.
(
SetSpawningSandboxBindingSandboxID, guarded onlifecycle_status='spawning') so reclaim can kill it — closes thecrash-before-Finalize window that previously leaked a billed sandbox.
AGENT_DAEMON_SANDBOX_*names the server actually reads (kept distinctfrom the e2b-only
PARSAR_E2B_*credentials).only); CONTRIBUTING sandbox maintenance + two-Dockerfile rules.
Verification
make checkn/ago build ./...,go testfor agentdaemon / e2b /store / cmd/server packages, and web typecheck all pass; verified a
live E2B acquire end-to-end through an ngrok tunnel.
Notes for reviewers
AGENT_DAEMON_SANDBOX_*is provider-neutral (shared by thedocker and e2b backends: backend/ttl/auto_renew/template/docker_*),
while
PARSAR_E2B_*stays e2b-only (api key, base url, host, CA). Thecompose rename aligns to what the code already read.
slowness only a few of a 50-batch complete per tick (soonest-to-expire
first, self-heals next tick). Parallelize before simultaneously-due count
makes this the bottleneck.
sandbox_provider.gois ~1900 lines — candidate for a follow-up split.