Reusable Python runtime for running persistent Claude Agent SDK / Claude Code sessions inside E2B sandboxes.
The package owns the generic sandbox runtime:
- E2B sandbox create/connect
- workspace preparation through pluggable providers
- persistent
ClaudeSDKClientinside the sandbox - durable turn request/response files
- socket wake + low-frequency sweep fallback
- structured streaming events
Application-specific integrations stay outside this package. For example, Feishu cards, database rows, channel messages, and project-specific CLIs should be implemented as adapters in the host application.
from e2b_cc_runtime import E2BSandboxFactory, RuntimeConfig, RuntimeRegistry
from e2b_cc_runtime.providers import LocalMount
config = RuntimeConfig(
template_id="your-e2b-template",
e2b_api_key="...",
anthropic_api_key="...",
workspace_provider=LocalMount(),
)
registry = RuntimeRegistry(
sandbox_factory=E2BSandboxFactory(api_key=config.e2b_api_key),
sandbox_id_store=your_store,
config=config,
)
session = await registry.get_or_create("session-1")
turn_id = await session.submit_turn("hello")
async for event in session.stream_turn(turn_id):
print(event)LocalMount creates a sandbox-local workspace directory. It is useful when the
workspace only needs to live for the sandbox lifetime.
ArchilMount mounts an Archil disk, checks out sessions/<session_id>, prefetches
it, and bind-mounts that session directory to the runtime workspace. It is useful
when Claude state and project files must survive sandbox pause/resume/kill.