Expand description
A Python CodeRuntime for the ADK-Rust CodeActAgent, backed by
Pydantic Monty — a minimal, secure,
Rust-native Python interpreter built for running LLM-generated code.
MontyRuntime lets a CodeActAgent act by writing Python: the model emits a
script each turn, invokes your Tools with the built-in
call_tool("name", {"arg": value}) function, composes their results with real
control flow, and returns a tagged value. Monty executes that script
in-process in microseconds, with no container and no subprocess — and can
snapshot a paused run to bytes, which is exactly what the CodeAct
suspend/resume model (HITL confirmation, long-running tools, durable
checkpoints) requires.
§OS access
Operating-system effects a script attempts — filesystem reads/writes,
os.getenv/os.environ, and date.today()/datetime.now() — are serviced
in-place by the runtime against a host-controlled OsAccess policy. They
are not tools: they never pause the agent loop. By default a runtime is
fully sandboxed (no filesystem access, empty environment), but you can grant
a script specific read-only or read-write paths and an explicit environment
map:
use adk_codeact_monty::{MontyRuntime, PathAccess};
let runtime = MontyRuntime::builder()
.allow_path("/data", "/srv/agent/data", PathAccess::ReadOnly)
.allow_path("/out", "/srv/agent/out", PathAccess::ReadWrite)
.environ_var("PROJECT", "acme")
.build();Network and subprocess access have no Monty OS-call surface and remain unavailable regardless of policy.
§Quick start
use std::sync::Arc;
use adk_agent::codeact::CodeActAgent;
use adk_codeact_monty::MontyRuntime;
let agent = CodeActAgent::builder()
.name("python_agent")
.model(model)
.runtime(Arc::new(MontyRuntime::new()))
.instruction("Solve the task by writing Python.")
// .tool(Arc::new(MyTool))
.build()?;§Resource limits
Cap a script’s time or memory with the builder — limits ride along inside a serialized continuation, so a resumed run stays bounded:
use std::time::Duration;
use adk_codeact_monty::MontyRuntime;
let runtime = MontyRuntime::builder()
.max_duration(Duration::from_secs(2))
.max_memory(64 * 1024 * 1024)
.build();Structs§
- Monty
Runtime - A Python
CodeRuntimefor theCodeActAgent, backed by the Monty interpreter. - Monty
Runtime Builder - Builder for
MontyRuntime. - OsAccess
- The OS-access policy a
MontyRuntimeenforces while driving a script. - OsAccess
Builder - Builder for
OsAccess. - Resource
Limits - Re-export of Monty’s resource-limit configuration, for
MontyRuntimeBuilder::resource_limits. Sourced throughadk-code’s Monty re-exports, so the Monty release is pinned exactly once. Configuration for resource limits.
Enums§
- Path
Access - Access mode for a path made available to a script.