Documentation · Interactive API Reference · 中文 README · 中文文档 · llms.txt
CubePod is an open-source, cloud-native execution platform designed for long-lived, high-autonomy AI Agents, featuring native E2B compatibility and native Kubernetes Runtime scheduling. Part of the Open-Source CubePlex Agent Stack, CubePod provides the persistent hardware-isolated execution layer powering ** CubePlex** (Team Agent Workspace) and ** CubeLoop** (Async Agent Runtime), delivering MicroVM execution with instant hibernation/resume and full system-level persistence.
Modern AI agents (DevOps agents, software engineering assistants, interactive data analysts) operate with broad shell privileges: they dynamically install system packages (apt, pip, npm, Rust/C++ compilers), launch headless or interactive GUI browsers, and interact with external APIs using privileged credentials.
Existing sandbox solutions suffer from four fundamental architectural limitations:
- Ephemeral RootFS (Only
/workspacePersists) : Standard container sandboxes discard modifications to/usr,/etc, and/varwhenever a sandbox sleeps or restarts. Agents are forced to repeatedly reinstall toolchains and libraries, wasting minutes on every wakeup. - Heavyweight Snapshot Overhead : VM memory snapshotting (CRIU / VM dumps) produces gigabyte-scale state files sensitive to host CPU architecture, while OCI commit/export approaches require tens of seconds to push layers to registries. Modern agents follow a**"Decoupled Brain & Hand"** model—reasoning context resides in the agent framework, meaning the sandbox only needs100% persistent disk state with zero CPU/RAM allocation during sleep .
- Network Filesystem I/O Bottleneck : Mounting NFS or CephFS across sandboxes causes catastrophic latency during
npm install,pip install, orgit statusdue to millions of small-file RPC round-trips. - Plaintext Secret Exposure : Injecting real API keys into container environment variables exposes credentials to untrusted LLM-generated code or host memory leaks.
CubePod solves these challenges with Dual-Volume CSI Raw Block persistence, Kata Containers MicroVM isolation, Zero-Export instant hibernation, and an in-guest Zero-Trust egress vault.
| Capability / Dimension | Upstream E2B Cloud / Standard Sandboxes | CubePod Open-Source Platform |
|---|---|---|
| Persistence Model | VM snapshots (E2B) orephemeral overlay (containers;/workspace only) |
Block-Backed Persistent RootFS + Independent /workspace Volume |
| Storage Architecture | Snapshot-coupled rootfs/state (optional E2B Volumes) or slow shared NFS | Dual CSI Raw Block PVCs (volumeMode: Block`` virtio-blk``ext4 ) with native NVMe-oF speed |
| RootFS & Workspace Lifecycle | Coupled in VM snapshots or full reset on container rebuild | Fully Decoupled : incrementrootfsGeneration to re-image OS while preserving/workspace intact |
| Hibernation & Resumption | Export/restore VM memory & disk snapshots or cold VM restart | Zero-Export Suspend (fsfreeze , delete Pod**~1s Cross-Node Mount Resume** |
| MicroVM Cold Start | Standard VM boot latency (several seconds) | Pre-Attached WarmPool (PodWarmPool) : blank pre-formatted ext4 MicroVMs claimed in**< 50ms** |
| Sandbox Forking | Not supported / full volume copy | < 1s Copy-on-Write Fork : instantaneous sub-agent cloning via CSI block snapshots |
| Isolation Boundary | Shared-kernel containers or cloud black-box | Hardware-Isolated Kata MicroVM (dedicated Guest Linux Kernel per sandbox) |
| Secret & Egress Security | Plaintext API keys injected into environment variables | Zero-Trust Egress Vault : transparentcpodref_ placeholder substitution via per-pod mTLS |
| Interactive GUI & Browser | Port mapping with port collision risks | Signed Panel Reverse Proxy : path/token-authenticated HTTP, WebSocket, & WebRTC (Chromium/Neko/ttyd) |
| API & Ecosystem | Proprietary API & SaaS vendor lock-in | 100% Wire-Compatible E2B Superset : drop-in support for official E2B SDKs + MCP |
| Deployment Model | Proprietary cloud only | 100% Open Source : Self-host on Kubernetes (Kata + CSI) or single-node Docker Compose |
+---------------------------------------------------------------------------------------+
| 1. Access Layer: Agent Platforms & SDKs |
| CubePlex Platform | Official E2B SDKs (Python / JS) | CubePod SDK | MCP Clients |
+---------------------------------------------------------------------------------------+
|
v
+---------------------------------------------------------------------------------------+
| 2. Control & Gateway Plane (Stateless High-Availability) |
| cubepod-gateway (Go) | cubepod-controller (Go K8s Operator) |
| • E2B-compatible REST/SSE router | • Dual Block PVC & WarmPool lifecycle |
| • Auto-Resume traffic interceptor | • In-memory per-pod mTLS certificate minting |
| • Signed Panel reverse proxy | • Zero-Trust Egress sidecar injection |
+---------------------------------------------------------------------------------------+
|
v
+---------------------------------------------------------------------------------------+
| 3. Data Plane: Hardware-Isolated Kata MicroVM Pod |
| +-------------------------------------------------------------------------------+ |
| | Kata Guest Linux Kernel (virtio-blk direct attachment) | |
| | | |
| | podd-init (PID 1 Rust Mounter): | |
| | 1. Auto e2fsck -p / mkfs.ext4 on raw block devices | |
| | 2. Assemble OverlayFS (lowerdir=Base Image, upperdir=/dev/cubepod-rootfs) | |
| | 3. Mount /workspace (/dev/cubepod-workspace) & pivot_root | |
| | | |
| | Container Merged RootFS (/) | |
| | • podd (Rust Daemon :49983): Execution, background logs cursor, archive sync | |
| | • Desktop Stack (Lazy-loaded): Xorg + Chromium CDP + Neko WebRTC + ttyd | |
| | • Egress Sidecar: nftables transparent redirection + mTLS secret vault swap | |
| +-------------------------------------------------------------------------------+ |
+---------------------------------------------------------------------------------------+
|
v
+---------------------------------------------------------------------------------------+
| 4. Persistent Storage Plane (CSI Raw Block) |
| Base OCI Image (RO) | RootFS Upper Block PVC (Thin) | Workspace Block PVC |
| (virtio-fs / EROFS) | (/dev/cubepod-rootfs -> ext4) | (/dev/cubepod-workspace) |
| Storage Backends: Longhorn V2 (SPDK NVMe-oF) / OpenEBS Mayastor / Local Loopback |
+---------------------------------------------------------------------------------------+
CubePod decouples system dependencies from user files by provisioning two independent CSI Raw Block PVCs (volumeMode: Block):
rootfs-pvc: Carries the OverlayFSupperdirandworkdir. Stores all delta modifications to/usr,/etc, and/varcreated byapt-get,pip, ornpm.workspace-pvc: Mounted directly at/workspace(with1000:1000ownership). Preserves source code, artifacts, and skills.
This decoupling enables RootFS Re-imaging without Data Loss: developers or agent frameworks can increment rootfsGeneration to purge a corrupted OS environment or upgrade the base image while keeping all /workspace project files intact.
- Suspend : When an agent sandbox is d or hits its idle timeout,
poddexecutessync+fsfreezeto flush kernel page caches and quiesce filesystem transactions. The Kata MicroVM Pod is immediately deleted, reducing CPU and memory consumption toabsolute zero . - Resume : Any incoming request (HTTP, command execution, or panel access) triggers
cubepod-gatewayto schedule a fresh MicroVM Pod onany cluster node . The CSI driver re-attaches the existing Raw Block PVCs, andpodd-initmounts the ext4 filesystems in**~1 second** without transporting multi-gigabyte memory state over the network.
Standard Kubernetes cannot mount Raw Block devices as the container rootfs without custom host-level Kubelet or containerd patches. CubePod bypasses this via In-Guest RootFS Pivot:
- MicroVM binaries (
podd-initandpodd) are injected at Pod startup via a sharedemptyDirvolume populated by an init container (cubepod-podd,< 1MB). podd-initruns as PID 1 in the Kata Guest kernel, mounts/dev/cubepod-rootfsand/dev/cubepod-workspace, builds the OverlayFS, callspivot_root(2), and hands execution over topodd.- User container images remain standard OCI images without baking in infrastructure binaries.
To achieve sub-50ms cold starts without violating Kubernetes Pod volume immutability:
-
Standby MicroVMs run in
PodWarmPoolwith pre-created, pre-formatted, thin-provisioned block devices already pivoted into ext4. -
When a new sandbox is requested,
cubepod-controllerre-labels and transfers ownership of the standby Pod and volumes in**< 50ms** , completely bypassing container scheduling and image pull delays. -
Sensitive external credentials (e.g., GitHub tokens, payment keys) never enter the sandbox filesystem, environment variables, or process memory .
-
The sandbox receives only opaque
cpodref_references. -
All outbound traffic is intercepted by an in-guest Egress Sidecar via
nftables. The sidecar inspects TLS SNI, enforces domain allowlists, and dynamically exchangescpodref_tokens with the egress vault over dedicated per-sandbox mTLS.
CubePod provides 100% wire-compatible drop-in interoperability with official E2B SDKs (CEP-0018). Existing AI Agent pipelines (LangChain, LlamaIndex, AutoGen, OpenHands, Smolagents) connect to CubePod without changing code—simply point E2B_DOMAIN to cubepod-gateway.
export E2B_DOMAIN="localhost:8080"
export E2B_API_KEY="cpod_live_secret"
python
from e2b import Sandbox
with Sandbox.create("base", timeout=300) as sandbox:
cmd = sandbox.commands.run("echo 'Hello from CubePod Kata MicroVM!'")
print(cmd.stdout) # "Hello from CubePod Kata MicroVM!"
sandbox.files.write("/workspace/agent_data.txt", "persistent state")
content = sandbox.files.read("/workspace/agent_data.txt")
python
import asyncio
from e2b import AsyncSandbox
async def main():
sandbox = await AsyncSandbox.create("base")
try:
cmd = await sandbox.commands.run("uname -a")
print(cmd.stdout)
finally:
await sandbox.kill()
asyncio.run(main())
CubePod provides native newline-delimited JSON (NDJSON) streaming and rich display formatters (png, svg, html, json) compatible with Jupyter protocols:
from e2b_code_interpreter import Sandbox
with Sandbox.create() as sandbox:
code = """
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame({"A": np.random.randn(5), "B": np.random.randn(5)})
plt.figure()
plt.plot([1, 2, 3], [4, 5, 6], label="Trajectory")
plt.title("Agent Convergence")
plt.show()
df
"""
execution = sandbox.run_code(code)
for result in execution.results:
if result.png:
print("Chart captured! Base64 PNG length:", len(result.png))
if result.html:
print("HTML table captured:\n", result.html[:100], "...")
e2b-code-interpreter on CubePod supports 6 standard execution kernels out-of-the-box:
| Language | language Parameter |
Execution Kernel | Capabilities |
|---|---|---|---|
| Python | "python" (default) |
ipykernel (IPython) |
Matplotlib/Seaborn charts, Pandas HTML tables, LaTeX |
| JavaScript | "javascript" |
ijavascript (Node.js) |
Node.js algorithms and Web data processing |
| TypeScript | "typescript" |
tslab /ts-node |
Typed TypeScript script execution |
| R | "r" |
IRkernel |
Statistical analysis, ggplot2 plotting |
| Java | "java" |
ijava (JShell) |
Java classes and JVM runtime execution |
| Bash | "bash" |
bash_kernel |
Interactive shell commands and pipeline scripts |
Beyond the standard E2B interface, CubePod exposes high-throughput enterprise extensions for mission-critical agent platforms:
- 1-Second Copy-on-Write Sandbox Fork (
POST /sandboxes/{id}/fork) : Clones an active sandbox and its dual block volumes in< 1susing CSI snapshots. Enables sub-agents to branch off speculative code execution in complete isolation. - Independent RootFS Reset : Increment
rootfsGenerationin thePodBoxCRD or API to rebuild the system layer after a brokenaptor compiler update while leaving user code in/workspace100% untouched. - Stateless Log Cursors (
GET /commands/{pid}/logs?cursor={byte_offset}) : Process logs are persisted to ring buffers on disk. Any gateway replica or agent worker can reconnect and resume streaming logs from arbitrary offsets after network interruptions. - Atomic Skill Archive Sync (
POST /files/archive-sync) : Streams atar.gzpayload unpacked in-memory directly to/workspace/.skillswith exactuid:gidownership and atomic cleanup of removed tools in a single< 50msHTTP call. - Signed Panel & GUI Proxy (
/panel/{jwt_token}/{path}) : Path- and JWT-authenticated reverse proxy supporting HTTP, WebSocket, and WebRTC streaming for Chromium CDP (:9222), Neko browser sharing (:8080), and ttyd web terminal (:7681).
| Path | Responsibility | Tech Stack |
|---|---|---|
docs/architecture.md ·中文 |
Platform architecture specification & CubePlex integration blueprint | Markdown / Mermaid |
docs/enhancements/ |
CubePod Enhancement Proposals (CEPs) | CEP Specification |
api/v1alpha1/ |
Kubernetes CRD schemas ( PodBox ,PodTemplate ,PodWarmPool ) |
Go ( controller-gen ) |
api/openapi/ |
Canonical E2B-compatible superset OpenAPI 3.1 specification | OpenAPI 3.1 |
crates/podd-init/ |
In-guest PID 1 raw block ext4 healer/formatter &OverlayFS`` pivot_root mounter |
Rust (single-threaded, zero-GC) |
crates/podd/ |
In-guest execution, background process ( cursor logs), andtar.gz file sync daemon |
Rust ( tokio ,axum ) |
cmd/cubepod-controller/ &pkg/controller/ |
Kubernetes Operator reconciling dual Block PVCs, WarmPools, and Kata Pods | Go ( kubebuilder ,client-go ) |
cmd/cubepod-gateway/ &pkg/gateway/ |
Control Plane Gateway, E2B router, Auto-Resume, and Panel HTTP/WS/WebRTC Proxy | Go |
cmd/cubepod-egress/ &pkg/egress/ |
Zero-Trust mTLS cpodref_ secret vault and egress forward proxy sidecar |
Go |
cmd/cubepod/ & pkg/client/ |
Official Go Client SDK and cubepod CLI |
Go |
sdks/python/ |
Sync & Async Python SDK ( cubepod ) |
Python 3.11+ ( httpx ) |
deploy/ |
Helm chart ( deploy/helm/cubepod ), K8s manifests, and local Docker Compose |
Helm / K8s / Docker |
- Go 1.22+
- Rust 1.78+ (cargo)
- Docker / Podman (optional for container image verification)
make build
make fmt
make vet
make test
make test-e2e
make test-e2b-compat
Built on a Brain-Hands Decoupling architecture, CubePod provides the persistent hardware-isolated execution layer (Hands) powering ** CubePlex** (Team Agent Workspace) and ** CubeLoop** (Async Agent Runtime & Reasoning Brain):
- CubePlex —** Brain / Workspace** : Team Agent Workspace for collaborative multi-agent workflows, sessions, and governance.
- CubeLoop —** Brain / Runtime** : Async Agent Runtime orchestrating long-running, multi-model autonomous execution loops.
- CubePod —** Hands / Execution** : Persistent Writable RootFS MicroVM execution substrate with Dual CSI Raw Block persistence,
<50msWarmPool claims,~1sCoW forks, and Zero-Trustcpodref_egress.
CubePod is open-source software licensed under the Apache License, Version 2.0.
Run make test-kind-e2e on a Linux Docker host to build and deploy this checkout
into an isolated kind cluster and exercise real sandboxes with both official E2B
SDKs. See requirements, coverage, diagnostics and local reuse.
No KVM or existing Kubernetes environment is needed.