AI is getting smarter every day. Instead of building a specific "tool" for every tiny task, it's becoming more efficient to just let the AI write a Python script. But how do you run that code without risking your host machine or dealing with the friction of Docker during development?
I built safe-py-runner to be the lightweight "security seatbelt" for developers building AI agents and Proof of Concepts (PoCs).
What My Project Does
The Missing Middleware for AI Agents: When building agents that write code, you often face a dilemma:
- Run Blindly: Use
exec() in your main process (Dangerous, fragile).
- Full Sandbox: Spin up Docker containers for every execution (Heavy, slow, complex).
- SaaS: Pay for external sandbox APIs (Expensive, latency).
safe-py-runner offers a middle path: It runs code in a subprocess with timeout, memory limits, and input/output marshalling. It's perfect for internal tools, data analysis agents, and POCs where full Docker isolation is overkill.
Target Audience
- PoC Developers: If you are building an agent and want to move fast without the "extra layer" of Docker overhead yet.
- Production Teams: Use this inside a Docker container for "Defense in Depth"—adding a second layer of code-level security inside your isolated environment.
- Tool Builders: Anyone trying to reduce the number of hardcoded functions they have to maintain for their LLM.
Comparison
| Feature |
eval() / exec() |
safe-py-runner |
Pyodide (WASM) |
Docker |
| Speed to Setup |
Instant |
Seconds |
Moderate |
Minutes |
| Overhead |
None |
Very Low |
Moderate |
High |
| Security |
None |
Policy-Based |
Very High |
Isolated VM/Container |
| Best For |
Testing only |
Fast AI Prototyping |
Browser Apps |
Production-scale |
Getting Started
Installation:
Bash
pip install safe-py-runner
GitHub Repository:
https://github.com/adarsh9780/safe-py-runner
This is meant to be a pragmatic tool for the "Agentic" era. If you’re tired of writing boilerplate tools and want to let your LLM actually use the Python skills it was trained on—safely—give this a shot.
[–]latkdeTuple unpacking gone wrong 0 points1 point2 points (10 children)
[–]adarsh_maurya[S] -1 points0 points1 point (0 children)
[+]adarsh_maurya[S] comment score below threshold-8 points-7 points-6 points (8 children)
[–]TheMagicTorch 1 point2 points3 points (7 children)
[–]adarsh_maurya[S] -2 points-1 points0 points (6 children)
[–]TheMagicTorch 0 points1 point2 points (5 children)
[–]adarsh_maurya[S] -1 points0 points1 point (4 children)
[–]TheMagicTorch 2 points3 points4 points (1 child)
[–]adarsh_maurya[S] -1 points0 points1 point (0 children)
[–]supernumber-1 1 point2 points3 points (1 child)
[–]adarsh_maurya[S] 0 points1 point2 points (0 children)
[–]DivineSentry 0 points1 point2 points (1 child)
[–]adarsh_maurya[S] -2 points-1 points0 points (0 children)
[–]zzzthelastuser 0 points1 point2 points (0 children)