Available on crate features
sandbox and process only.Expand description
ProcessBackend — subprocess-based code execution via tokio::process::Command.
This backend spawns child processes to execute code in various languages. It enforces timeout and environment isolation but does not enforce memory limits, network isolation, or filesystem isolation.
§Supported Languages
| Language | Execution Strategy |
|---|---|
| Rust | Write to temp file → compile with rustc → run binary |
| Python | Write to temp file → run with python3 |
| JavaScript | Write to temp file → run with node |
| TypeScript | Write to temp file → run with node (same as JS) |
| Command | Execute code as sh -c "<code>" |
| Wasm | Not supported — use WasmBackend instead |
§Example
ⓘ
use adk_sandbox::{ProcessBackend, ExecRequest, Language, SandboxBackend};
use std::time::Duration;
use std::collections::HashMap;
let backend = ProcessBackend::default();
let request = ExecRequest {
language: Language::Python,
code: "print('hello')".to_string(),
stdin: None,
timeout: Duration::from_secs(30),
memory_limit_mb: None,
env: HashMap::new(),
};
let result = backend.execute(request).await?;
assert_eq!(result.stdout.trim(), "hello");Structs§
- Process
Backend - Subprocess-based sandbox backend.
- Process
Config - Configuration for
ProcessBackend.