Parent: #173
Overview
Future phase: implement a CodeRuntime that runs LLM-generated code inside a Docker container for full isolation (network, filesystem, resource limits). Same CodeRuntime.execute(code, tools) interface as InProcessRuntime and SubprocessRuntime.
Difference from SubprocessRuntime
|
Subprocess |
Container |
| Isolation |
Process-level |
Container-level (namespace, cgroup) |
| IPC channel |
stdin/stdout pipe |
HTTP / Unix socket |
| Network |
Shared with host |
Can be fully restricted |
| Filesystem |
Shared with host |
Isolated, ephemeral |
| Resource limits |
OS-level (ulimit) |
cgroup (CPU, memory, disk) |
| Startup cost |
~ms |
~seconds |
Architecture
Same bidirectional tool-call pattern as SubprocessRuntime:
Main Process Container
──────────── ─────────
CodeRuntime.execute(code, tools)
→ start/connect container ───────→ Python interpreter
→ HTTP POST code + tool specs ───→ build stub namespace
exec(code, stubs)
await query_database(sql)
stub: HTTP POST {name, args} →
← recv {name, args}
tool.callable(sql)
HTTP response {result} ─────────→
stub: return result
...
HTTP POST stdout ───────────→
← recv stdout
return CodeResult(stdout)
ToolProjection = HTTP stub instead of pipe stub. Everything else follows the same protocol.
Scope (to be refined when this becomes active)
- Container lifecycle management (pool, reuse, expiration)
- Resource limits configuration (CPU, memory, timeout)
- Network policy (deny-all by default, allowlist for specific tool endpoints)
- Environment variable control (explicit passthrough, not inherited)
- Pre-built container image with common Python packages
Dependencies
Parent: #173
Overview
Future phase: implement a
CodeRuntimethat runs LLM-generated code inside a Docker container for full isolation (network, filesystem, resource limits). SameCodeRuntime.execute(code, tools)interface as InProcessRuntime and SubprocessRuntime.Difference from SubprocessRuntime
Architecture
Same bidirectional tool-call pattern as SubprocessRuntime:
ToolProjection= HTTP stub instead of pipe stub. Everything else follows the same protocol.Scope (to be refined when this becomes active)
Dependencies