pip install langchain-e2bfrom e2b import Sandbox
from langchain_e2b import E2BSandbox
e2b_sandbox = Sandbox.create()
backend = E2BSandbox(sandbox=e2b_sandbox)
try:
result = backend.execute("echo hello")
print(result.output)
finally:
e2b_sandbox.kill()Install langchain-e2b into the dcode environment, then run with the E2B
sandbox provider:
dcode --install langchain-e2b --package
export E2B_API_KEY=...
dcode --sandbox e2blangchain-e2b adapts an existing E2B sandbox to the Deep Agents sandbox
protocol. It uses the low-level e2b SDK so Deep Agents can run shell commands
and move files through the standard Deep Agents sandbox interface.
For SDK use, this package intentionally does not hide E2B sandbox lifecycle
management. Use the E2B SDK to create, connect to, configure, and kill
sandboxes, then pass the connected sandbox object to E2BSandbox.
For Deep Agents Code, the package also exposes a dcode sandbox provider entry
point. The provider creates, reconnects to, and deletes E2B sandboxes for
dcode --sandbox e2b.
Contributions are welcome. Keep the adapter focused on implementing the Deep Agents sandbox backend protocol over the official E2B SDK.
uv sync --group test
make test
make lintIntegration tests require E2B_API_KEY:
E2B_API_KEY=... make integration_tests