Tangle vs Modal: start a coding agent in a sandbox without building an image
Claude Code, Codex, OpenCode and five more coding agents are installed in every sandbox, and their model calls go through Tangle Router on your Tangle balance.
Create a sandboximport os
from tangle_sandbox import BackendConfig, CreateSandboxOptions, GitConfig, Sandbox, SandboxStatus
client = Sandbox(api_key=os.environ["TANGLE_API_KEY"], base_url="https://sandbox.tangle.tools")
box = client.create(
CreateSandboxOptions(
git=GitConfig(url="https://github.com/tangle-network/sandbox-demo"),
backend=BackendConfig(type="claude-code"),
)
)
try:
box.wait_for(SandboxStatus.RUNNING)
run = box.prompt("`npm test` fails. Find the cause and fix it.")
print(run.success, run.response, run.usage)
finally:
box.delete()
client.close()The result and token usage come back from one call (docs.tangle.tools/sandbox/cloud-agents). Claude Code's first reply arrives 3.4s after create at p50 and 12s at p95, over 45 measured runs (tangle.tools/benchmarks).
What else you get
- A stopped sandbox keeps its files until you delete it or its delete timer passes, and resume starts it again. (docs.tangle.tools/sandbox/migrate-e2b#what-maps-to-what)
- Set a dollar budget for a fleet of agents, and the platform refuses any charge past it. (docs.tangle.tools/sandbox/agents-fleet)
- Every agent turn is traced, and a report summarizes what the agent did. (docs.tangle.tools/sandbox/observability)
Move your code from Modal
-import modal
+import os
+
+from tangle_sandbox import CreateSandboxOptions, Sandbox, SandboxStatus
-app = modal.App.lookup("my-app", create_if_missing=True)
-sb = modal.Sandbox.create(app=app, timeout=600)
-p = sb.exec("python", "-c", "print(42)")
-print(p.stdout.read())
-sb.terminate()
+client = Sandbox(api_key=os.environ["TANGLE_API_KEY"], base_url="https://sandbox.tangle.tools")
+box = client.create(CreateSandboxOptions(max_lifetime_seconds=600))
+box.wait_for(SandboxStatus.RUNNING)
+run = box.exec("python3 -c 'print(42)'")
+print(run.stdout)
+box.delete()
+client.close()For everything else, the move guide maps Modal Sandbox calls, Python first.
What every sandbox includes
- Coding agents
- Claude Code, Codex, OpenCode, Pi, Hermes, OpenClaw, Kimi Code and Prime Agent installed in every sandbox (tangle.tools)
- Stop and resume
- Timers you set stop a sandbox; a stopped sandbox keeps its files until you delete it or its delete timer passes (docs.tangle.tools/sandbox/migrate-e2b)
- Secrets
- Stored once; you choose whether the sandbox can read a secret or only the network proxy can (docs.tangle.tools/sandbox/secrets)
- SDKs
- TypeScript, Python (tangle-sandbox on PyPI) and the tangle CLI (docs.tangle.tools/sandbox/sdk-python)