OpenDsec

Self-hosted sandboxes for AI agents and reinforcement-learning rollouts: Firecracker microVMs, containers and full VMs behind one API, with memory-preserving fork and an E2B-compatible gateway.

OpenDsec is an independent implementation of the architecture described in DeepSeek Elastic Compute (DSec): A Sandbox Infrastructure for Effective Agentic Training at Scale (arXiv:2609.22978). It is not DeepSeek code, not an official release, and not affiliated with or endorsed by that paper's authors.

What it is

OpenDsec runs many isolated sandboxes on your own Linux machines, from a single host to a cluster, for reinforcement-learning rollouts and agents that execute code. It ships a Python SDK, a CLI, and an API compatible with E2B's SDKs, under AGPL-3.0.

Architecture

Lifecycle

A microVM can be paused into a memory snapshot, restored, or forked while running. Copies on the same node share memory pages; a fork on another node pulls the snapshot from the source. A sandbox can also be packed back into a new image from its changes.

import asyncio
from opendsec import DSecClient, DSecRunArgs

async def main():
    async with DSecClient() as client:
        sb = await client.run_sandbox(DSecRunArgs(
            backend="microvm", image="root/py:3.12",
            cpu_cores_limit=1, memory_limit_mb=1024,
            network_rules={"pypi": True}))   # outbound denied unless allowed
        try:
            print((await sb.run_shell("python3 -c 'print(6*7)'")).stdout)
            forks = await sb.fork(count=4)   # four copies, memory included
            for f in forks:
                await f.stop()
        finally:
            await sb.stop()

asyncio.run(main())

Measured on our hardware

These are measurements of OpenDsec on its own machines, not figures from the paper. Method and conditions are in docs/SPEC.md.

MeasurementValue
microVM cold start~0.1 s
Restore from memory snapshot~55 ms
Resume after pause~50 ms
Source VM stall during fork~10 ms
Burst of microVMs, one 384-thread node5,120
Burst of containers, two nodes8,192, no failures

Where it differs from the paper

Where the paper leaves a decision open, docs/SPEC.md marks each point as either taken from the paper, with its section, or the project's own decision.

Known limits

Try it

One Linux x86_64 machine with systemd and cgroup v2 is enough. MicroVMs need /dev/kvm; without it the script sets up containers only.

git clone https://github.com/Kernflux/opendsec
cd opendsec
deploy/quickstart.sh        # or --no-microvm for containers only

Existing E2B programs need only three environment variables pointed at the gateway:

export E2B_API_URL=https://sandbox.internal:7400
export E2B_SANDBOX_URL=https://sandbox.internal:7400
export E2B_API_KEY=dsk.…

Links

Licensing

The server and tools are AGPL-3.0. The client parts (the Python SDK, the Go client, and the API definitions) are Apache-2.0, so programs using OpenDsec are not bound by the AGPL.