Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Monty is a Rust-based interpreter for a restricted Python subset. MontyCodeActProvider gives an Agent Framework agent one execute_code tool and lets generated code call provider-owned tools as typed async functions or through call_tool(...).
This integration uses the CodeAct pattern with a restricted interpreter rather than a hardware-isolated sandbox.
Use Monty when you need a cross-platform CodeAct runtime without Hyperlight's hypervisor or WASM guest dependency.
Note
agent-framework-monty is a beta package. Monty restricts operating-system, subprocess, and direct network access, but it isn't a hardware-isolated virtual machine.
Warning
MontyCodeActProvider and MontyExecuteCodeTool don't currently support FIDES. Provider-managed host-tool calls don't pass through the agent's per-function middleware pipeline.
Checks on direct agent tools or the outer execute_code call don't cover nested calls, code-internal intermediate values, or file and network capabilities. Host tools must enforce their own authorization and destination controls.
Keep FIDES-dependent tools as direct agent tools, not Monty-managed tools, or leave CodeAct disabled for workflows requiring those guarantees. See CodeAct's current limitations.
Install the packages
pip install agent-framework-monty agent-framework-foundry --pre
Add MontyCodeActProvider
Register host tools on the provider rather than directly on the agent. The model sees execute_code and calls those tools from generated code.
Control host tool parameter descriptions
MontyCodeActProvider and MontyExecuteCodeTool accept tool_description_format. The default, "compact", includes scalar parameter types, required or optional status, descriptions, enum values, and defaults in the execute_code description and CodeAct instructions. Use "json" for complete JSON Schema, or select a format by exact, case-sensitive tool name:
codeact = MontyCodeActProvider(
tools=[compute, fetch_data],
tool_description_format={
"compute": "json",
"fetch_data": "compact",
},
)
Tools omitted from a mapping use compact format. Compact rendering automatically falls back to complete JSON Schema when it can't represent a schema without losing constraints, such as nested objects, arrays, references, or unions. Parameter schemas are visible to the model, so don't include credentials or other secrets in descriptions, enum values, defaults, or custom schema fields.
Generated code must call typed host tools with keyword arguments, such as
await tool_name(value=1). Positional arguments are rejected by type checking
before the host tool runs. A runtime guard also rejects them if type checking is
bypassed. Use await call_tool("name", value=1) as the untyped fallback.
Configure capabilities
MontyCodeActProvider and MontyExecuteCodeTool support:
- host tools and runtime tool management
never_requireoralways_requireapproval forexecute_code- a workspace root and explicit file mounts
- Monty resource limits
- files returned from read-write mounts as Agent Framework content
The integration requires pydantic-monty 1.0 or later within the supported
1.x range. Use max_feed_duration_secs for the overall execution-feed limit.
The legacy max_duration_secs name remains an alias, but passing both names is
an error.
Post-execution file capture returns only real regular files from read-write mounts. It skips symlinks, Windows junctions and other reparse points, and non-regular files at every path level. Before reading a file, Monty verifies that the opened descriptor matches the validated path and rechecks the path components. If the file or an ancestor changes during capture, the file is omitted instead of followed.
Each execution captures at most 20 files and 20 MiB of raw data across all read-write mounts, with a 5-MiB limit per file. Empty files count toward the file limit. Files that don't fit the remaining budget are skipped, but later smaller files can still be captured. The response includes one omission summary when any file exceeds a capture limit. The files remain written in the sandbox; these limits apply only to returned attachments.
Control host-tool error diagnostics
Host-tool failures generate code that resumes with a generic RuntimeError by default. Original exception types and messages remain on the trusted host side. Set include_detailed_errors=True only when you trust the generated code and every downstream channel. This option is separate from Agent Framework sensitive data logging and outer chat-client error settings.
Network access and Python packages
Monty runs its own Python interpreter, not the host's Python environment. This
integration doesn't provide pip or another package-installation option.
Installing a dependency on the host doesn't make it importable in Monty code.
Use the interpreter's supported modules for code that runs inside Monty.
Monty doesn't provide an allowed_domains option. For external API calls or
operations that require host-installed packages, register a narrow host tool
and invoke it from Monty code. Keep credentials, authorization, and
destination allow-list checks in that function because it executes on the
host, outside the Monty interpreter.
Choose Monty or Hyperlight
| Runtime | Choose it when |
|---|---|
| Monty | Cross-platform execution and a restricted interpreter are sufficient. |
| Hyperlight | You need a hardened sandbox, filesystem controls, or outbound-domain allow lists. |