Major Language Limitations
These core Python features are currently not supported:No Classes (Yet)
Monty does not currently support class definitions.Class support is planned and should be added soon. Track progress on the Monty GitHub repository.
No Match Statements (Yet)
Pattern matching withmatch/case is not implemented.
Match statement support is planned and should be added soon.
Standard Library Limitations
Limited Module Support
Only these stdlib modules are available:sysostypingasynciorepathlib
datetime, dataclasses, json
No Third-Party Libraries
Monty cannot use third-party packages like Pydantic, requests, numpy, etc.- Written by an LLM/agent
- Executed in a sandboxed environment
- Using only built-in and stdlib features
- Making external calls via host-provided functions
Security Restrictions
These restrictions exist to ensure safe execution of untrusted agent code.No Direct Filesystem Access
All filesystem operations are sandboxed and controlled by the host.How filesystem access works
How filesystem access works
The host environment must explicitly provide filesystem access through external functions:The host controls:
- Which files can be accessed
- What operations are allowed
- Path validation and sandboxing
No Environment Variables
Direct access to environment variables is blocked.No Network Access
Sockets, HTTP requests, and all network operations are blocked.No Subprocess Execution
Running external commands or spawning processes is blocked.Resource Limits
Monty enforces strict resource limits to prevent abuse:Memory Limits
Execution Time Limits
Allocation Limits
Resource limits are configurable by the host and are designed to prevent runaway agent code from consuming excessive resources.
Import System Limitations
No Dynamic Imports
The__import__() function and importlib are not available.
No Import Hooks
Custom import hooks and meta path finders are not supported.Advanced Python Features
These advanced features are not supported:No Metaclasses
Since classes aren’t supported yet, metaclasses are also unavailable.No Decorators on Classes
Class decorators don’t work (no classes), but function decorators work fine:No Generators (Some Limitations)
Basic generators work, but some advanced features may not be fully supported:No Context Managers (Limited)
Thewith statement has limited support. Custom context managers may not work fully.
What Monty IS Designed For
Despite these limitations, Monty excels at its intended use case:Agent Code Execution
Agent Code Execution
Perfect for running LLM-generated Python code:
Tool Orchestration
Tool Orchestration
Excellent for coordinating external function calls:
Data Processing
Data Processing
Great for processing and transforming data:
Control Flow Logic
Control Flow Logic
Ideal for agent decision-making logic:
Comparing to Alternatives
Why use Monty despite these limitations?| Feature | Monty | Docker | Pyodide | Full Python |
|---|---|---|---|---|
| Startup time | <1μs | ~195ms | ~2800ms | ~30ms |
| Security | Strict sandbox | Good isolation | Poor | None |
| Stdlib | Limited | Full | Full | Full |
| Third-party libs | No | Yes | Most | Yes |
| Classes | Coming soon | Yes | Yes | Yes |
| Use case | Agent code | General | Browser | General |
- Running LLM-generated code
- Need microsecond startup times
- Security is critical
- Stdlib subset is sufficient
- Building agentic systems
- Need full Python compatibility
- Require third-party libraries
- Need classes today (coming soon)
- General-purpose scripting
Roadmap
Planned improvements:- Class support - Coming soon
- Match statements - Coming soon
- More stdlib modules -
datetime,dataclasses,json - Enhanced async features - Better asyncio integration
Follow development on GitHub and join the Pydantic Slack for updates.
Next Steps
Python Subset
See what Python features ARE supported
Standard Library
Explore available stdlib modules
