adk-code
Language-aware code execution toolchain for ADK-Rust.
adk-code handles compilation, diagnostics, and language-specific pipelines. It delegates actual execution to adk-sandbox backends, cleanly separating language toolchains from isolation.
Architecture
Agent → CodeTool (adk-code)
│
▼
RustExecutor
check → build → delegate
│
▼
SandboxBackend (adk-sandbox)
ProcessBackend / WasmBackend
The RustExecutor pipeline:
- Check —
rustc --error-format=json→ parse structured diagnostics → halt on errors - Build — compile to binary using the harness template
- Execute — delegate to a
SandboxBackendviaExecRequest
Quick Start
use ;
use ProcessBackend;
use Arc;
let backend = new;
let executor = new;
let tool = new;
// Use with any LLM agent
let agent = new
.instruction
.tool
.build?;
User code must provide fn run(input: serde_json::Value) -> serde_json::Value. The harness wraps it with fn main(), stdin parsing, and stdout serialization.
Backend Matrix
| Backend | Timeout | Memory | Network | Filesystem | Environment |
|---|---|---|---|---|---|
ProcessBackend |
✅ Enforced | ❌ Not enforced | ❌ Not enforced | ❌ Not enforced | ✅ Isolated |
WasmBackend |
✅ Enforced | ✅ Enforced | ✅ Isolated | ✅ Isolated | ✅ Isolated |
EmbeddedJsExecutor |
✅ Enforced | ❌ Not enforced | ✅ No API available | ✅ No API available | ✅ No API available |
DockerExecutor |
✅ Enforced | ✅ Container limits | ✅ Configurable | ✅ Configurable | ✅ Configurable |
EmbeddedJsExecutor reports enforcement as true because boa_engine simply has no network/filesystem/environment APIs — isolation is by omission, not by active enforcement.
Feature Flags
| Feature | Description | Default |
|---|---|---|
| (none) | Core types, RustExecutor, CodeTool |
✅ |
embedded-js |
EmbeddedJsExecutor via boa_engine |
❌ |
docker |
DockerExecutor via bollard |
❌ |
Tools
| Tool | Name | Language | Scopes |
|---|---|---|---|
CodeTool |
code_exec |
Rust (phase 1) | code:execute, code:execute:rust |
SandboxTool (adk-sandbox) |
sandbox_exec |
Multi-language | code:execute |
Both tools follow the error-as-information pattern: compile errors and runtime failures are returned as structured JSON, never as ToolError.
Structured Diagnostics
Compile errors include parsed RustDiagnostic structs with level, message, spans, and error codes:
Migration from Previous API
The previous adk-code API (CodeExecutor, ExecutionRequest, RustSandboxExecutor, etc.) is deprecated. See the compat module for the full migration table.
| Old Type (deprecated) | New Type | Crate |
|---|---|---|
CodeExecutor |
SandboxBackend |
adk-sandbox |
ExecutionRequest |
ExecRequest |
adk-sandbox |
ExecutionResult |
ExecResult |
adk-sandbox |
RustSandboxExecutor |
RustExecutor |
adk-code |
RustSandboxConfig |
RustExecutorConfig |
adk-code |
RustCodeTool (adk-tool) |
CodeTool |
adk-code |
Key API changes:
SandboxBackendhas no lifecycle methods — justexecute(ExecRequest)ExecRequestis flat:language,code,stdin,timeout,memory_limit_mb,envRustExecutor::new(backend, config)takes aSandboxBackendinstead of embedding isolation- Deprecated aliases compile with warnings for one release cycle (removed in v0.6.0)
License
Apache-2.0