Repository navigation
feat(sandbox): add a Daytona sandbox provider - #320
Merged
Merged
Conversation
Daytona sandboxes as a built-in VM provider, `daytona`, behind the `daytona` extra. Each sandbox runs its own Docker daemon and serves its ports on Daytona preview URLs, so the docker-in-VM flows run on it unchanged. Adapted from Daytona's agentenv-daytona plugin (Apache-2.0), with these changes: - one SDK client per provider instance and event loop, so closing one provider can't close another's client; - get_sandbox raises SandboxNotFoundError for a sandbox that is gone and changes nothing, and terminate_sandbox deletes by id, so a sandbox its time-to-live already removed tears down cleanly; - a restricted egress policy is never widened: a download the policy doesn't admit goes through the file API; - Daytona's preview domains are declared in EGRESS_HOSTS instead of learned at run time; - a request bigger than the configured snapshot is refused, and cleanup after a cancelled create is shielded. Co-Authored-By: Daytona Platforms Inc. <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…ing, and log a snapshot's real size A create cancelled in flight, as an interrupted run's is, used to re-raise at once and leave the delete to a callback on a loop that was about to close, so its sandbox could run until its time-to-live. It now waits for the create to answer and deletes what it made before the cancellation is raised, for at most _CANCEL_WAIT, after which the delete carries on by itself. A sandbox booted from a snapshot is logged at the snapshot's size, not the request's, and the rate-limit retry cap is named. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
Adds Daytona as a built-in sandbox provider,
daytona, behind adaytonaextra:pip install 'agentenv-framework[daytona]' agent-env run hello --sandbox daytonaEach sandbox is a Daytona sandbox running its own Docker daemon, presented as a VM, with its ports on Daytona preview URLs. The docker-in-VM flows run on it unchanged: an env's docker-compose, an agent's
docker run, image loading and artifact collection. Configuration, networking, cost attribution and limits are in the provider README.The provider is adapted from Daytona's
agentenv-daytonaplugin (Apache-2.0), which is credited inNOTICE, the README and the commit.Changes from the plugin
get_sandboxraisesSandboxNotFoundErrorfor a sandbox that is gone, andterminate_sandboxdeletes by id. Sandboxes are ephemeral with a hard time-to-live, so a teardown often finds its sandbox already gone; before, that teardown failed.get_sandboxno longer updates network settings or fetches a sample preview link.EGRESS_HOSTSdeclares Daytona Cloud's preview domains (*.daytonaproxy01.net,*.daytonaproxy01.eu). They were learned at run time into a class attribute, which a fresh process didn't know. A self-hosted Daytona adds its own domain withegress_hosts.Wiring
The same places boxd's PR (#263) touched:
_BUILTIN_SANDBOX_PROVIDERSentry;daytonaextra, also indev, anduv.lock;THIRD_PARTY_NOTICES.mdandNOTICE;AGENTS.mdlists and the CLI--sandboxhelp;.agentenv/config.example.toml;daytonacase in the gateway and task-step integration tests;uv.lock:daytona-api-client0.224 requirespydantic>=2.13.5andtyping-extensions>=4.16.0, so the lock moves pydantic from 2.12.5 to 2.14.1, along withpydantic-core,typing-extensions,typing-inspection,aiohttpandyarl. Installs from PyPI resolve their own versions; this changes what CI anduv syncuse.Tests
daytona_sandbox_provider_test.py,daytona_sandbox_test.pyanddaytona_network_test.py, offline against an in-memory SDK. To check they bite, 13 deliberate breakages of the provider in a scratch copy each failed them; examples are a handle that never re-reads, an unknown policy allowing downloads, unshielded cleanup and a shared client. The provider, config, capabilities, optional-extras and task suites pass: 2,308 passed, 6 skipped.ruff,uv lock --checkand the plugin API check (no break) are clean.agent-env run hello --sandbox daytonapasses in about 30 s; with the local object store its artifact goes through the file-API upload.daytona_sandbox_smoke_test.pypasses, 2 of 2: nested Docker, a container port reached through its preview URL, a 9 MiB multi-part upload to a root-owned path checked by sha256, a reconnect from a fresh provider keeping ports and policy, then terminating twice andget_sandboxraisingSandboxNotFoundError.docker compose up.Notes
helloonce before puttingdaytonain a chain.api_key,snapshot, the Tier 3 requirement for egress allowlists and the first host-image build.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge, with all three previous findings addressed and no new actionable issues found.Summary
Adds
daytonaas an optional built-in provider for Docker-capable sandboxes.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Create Daytona sandbox] --> B{Create outcome} B -->|Success| C[Restore port URLs and start Docker] C -->|Ready| D[Return sandbox] C -->|Setup fails| E[Delete sandbox] B -->|Caller cancels| F[Wait for create and delete its sandbox] F -->|Cleanup finishes| G[Raise cancellation] F -->|120 seconds pass| H[Continue cleanup in background] H --> G B -->|Uncertain failure| I[Find sandbox by unique name and delete]Reviews (2) · Last reviewed commit: "fix(sandbox): delete a cancelled Daytona..." · Reviewed by Greptile