Skip to main content

Crate adk_sandbox

Crate adk_sandbox 

Source
Expand description

§adk-sandbox

Isolated code execution runtime for ADK agents.

This crate provides the SandboxBackend trait and two implementations:

  • ProcessBackend (default feature process): Executes code in child processes via tokio::process::Command. Enforces timeout and environment isolation but not memory or network isolation.

  • WasmBackend (feature wasm): Executes WebAssembly modules in-process via wasmtime. Enforces timeout, memory limits, and full sandboxing (no filesystem or network access).

§Quick Start

use adk_sandbox::{ProcessBackend, ExecRequest, Language};
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?;
println!("stdout: {}", result.stdout);

§Feature Flags

FeatureDescriptionDefault
processSubprocess execution via tokio
wasmIn-process WASM execution via wasmtime

Re-exports§

pub use backend::BackendCapabilities;
pub use backend::EnforcedLimits;
pub use backend::SandboxBackend;
pub use error::SandboxError;
pub use sandbox::AccessMode;
pub use sandbox::AllowedPath;
pub use sandbox::NetworkRule;
pub use sandbox::SandboxEnforcer;
pub use sandbox::SandboxPolicy;
pub use sandbox::SandboxPolicyBuilder;
pub use sandbox::WrappedCommand;
pub use sandbox::get_enforcer;
pub use tool::SandboxTool;
pub use types::ExecRequest;
pub use types::ExecResult;
pub use types::Language;
pub use process::ProcessBackend;
pub use process::ProcessConfig;

Modules§

backend
The SandboxBackend trait and BackendCapabilities descriptor.
error
Error types for sandbox execution.
process
ProcessBackend — subprocess-based code execution via tokio::process::Command.
sandbox
OS-level sandbox enforcement types and traits.
tool
SandboxTool — an adk_core::Tool implementation that delegates execution to a configured SandboxBackend.
types
Core types for sandbox execution: Language, ExecRequest, and ExecResult.