Python Execution Environment
Zene provides an isolated and safe environment for executing Python code generated by the Agent.
1. The Virtual Environment (.venv)
Zene automatically manages a Python virtual environment in the project root to prevent host system pollution.
- Auto-Creation: Creates
.venvif missing. - Performance (uv): Prioritizes
uvfor sub-millisecond setup; falls back tovenv. - Isolation: Each script runs within this project-scoped environment.
2. Session Isolation
Environment variables are managed at the Session level:
- Variables set via
set_envare stored in the session state. - They are injected only into the child processes (
Command::envs). - The server host environment remains untouched and thread-safe.
3. Tools API
run_python: Executes a script within the.venv.set_env: Persists a key-value pair for the current session.get_env: Retrieves a variable from the session context.
4. Safety & Limits
- Timeout: Hard 60-second limit on all scripts.
- Standard Input:
stdinis closed to prevent hanging on interactive prompts (e.g.,input()). - Cleanup: Ephemeral files and dependencies are tracked per project.
5. Security Best Practices
- Secrets: Use
set_envinstead of hardcoding API keys. - Dependencies: Use
requirements.txt; Zene will automatically attempt to resolve missing packages. - Non-interactive: Ensure scripts are fully automated.
