Mitos cookbook
Isolated, forkable computers for your AI agents.
Four recipes to get from zero to a forked swarm.
01Parallel attempts with fork()
Do the slow setup once, then fork the live sandbox into N warm siblings. Each daughter shares the parent's memory pages until it writes, so every attempt starts from the same ready state in milliseconds.
import mitos
sb = mitos.create("python")
sb.exec("pip install -q requests") # shared setup, paid once
attempts = sb.fork(4) # 4 warm copies of this exact state
for i, fork in enumerate(attempts):
fork.exec(f"python solve.py --strategy {i} > /workspace/out.txt")
# read each fork's /workspace/out.txt, keep the winner, terminate the rest
sb.terminate()
Quickstart →
02A sandbox tool for smolagents
Give a smolagents agent a tool that runs code inside its own microVM instead of your machine. Same pattern works for LangGraph or a hand-rolled harness.
from smolagents import CodeAgent, InferenceClientModel, tool
import mitos
sb = mitos.create("python")
@tool
def run_python(code: str) -> str:
"""Run Python code in an isolated microVM sandbox.
Args:
code: The Python source to execute.
"""
sb.exec(f"cat > /workspace/cell.py <<'EOF'\n{code}\nEOF")
return sb.exec("python /workspace/cell.py").stdout
agent = CodeAgent(tools=[run_python], model=InferenceClientModel())
agent.run("Compute the first 10 Fibonacci numbers")
More agent patterns →
03Migrating from E2B
The create/exec surface maps one to one. What you gain is the part E2B does not have: forking a running sandbox.
# before: e2b
from e2b_code_interpreter import Sandbox
sbx = Sandbox()
sbx.run_code("print('hello')")
# after: mitos
import mitos
sb = mitos.create("python")
sb.exec("python -c \"print('hello')\"")
a, b = sb.fork(2) # the part you could not do before
Full migration guide →
04Self-host on Kubernetes
Everything above runs unchanged on your own cluster. Any Kubernetes with KVM nodes works; bare metal is a first-class target. Your data never leaves your infrastructure.
# point the SDK at your cluster instead of the hosted endpoint
export MITOS_BASE_URL=https://mitos.internal.example.com
Install guide →