Implementation:ANative Lab EvoAgentX InterpreterToolkits
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Tools, Code_Execution |
| Last Updated | 2026-10-21 00:00 GMT |
Overview
Concrete tools for executing code in isolated Docker containers or local Python environments.
Description
EvoAgentX provides two code interpreter toolkits:
- DockerInterpreterToolkit — Extends `BaseInterpreter` using Docker SDK. Creates containers, executes code in isolation, captures stdout/stderr. Supports file transfer via tar archives. Integrates with `FileStorageHandler` for I/O. Critical for agent code generation and verification workflows requiring safe execution.
- PythonInterpreterToolkit — Extends `BaseInterpreter` for executing Python code locally using `exec`/`eval` with sandboxed import handling. Supports AST analysis, output capture via `contextlib.redirect_stdout/stderr`, and `importlib` for module management. Useful for data processing without Docker overhead.
Usage
- Secure code execution: Use `DockerInterpreterToolkit` for untrusted LLM-generated code.
- Local execution: Use `PythonInterpreterToolkit` for trusted code without Docker overhead.
- Alita agent pattern: Both serve as the `code_executor` backend for `GeneratedCodeTool`.
Code Reference
Source Location
- Repository: EvoAgentX
- Docker File: evoagentx/tools/interpreter_docker.py (L1-467)
- Python File: evoagentx/tools/interpreter_python.py (L1-472)
Signature
class DockerInterpreterToolkit(Toolkit):
def __init__(self, ...)
# Creates Docker containers, executes code in isolation
# Captures stdout/stderr, supports file transfer via tar
class PythonInterpreterToolkit(Toolkit):
def __init__(self, ...)
# Executes Python code locally via exec/eval
# Sandboxed import handling, AST analysis, output capture
Import
from evoagentx.tools.interpreter_docker import DockerInterpreterToolkit
from evoagentx.tools.interpreter_python import PythonInterpreterToolkit
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| code | str | Yes | Source code to execute |
| language | str | No | Programming language (default "python") |
Outputs
| Name | Type | Description |
|---|---|---|
| execute returns | str | stdout output from code execution |
| error | str | stderr output if execution fails |
Usage Examples
Docker Code Execution
from evoagentx.tools.interpreter_docker import DockerInterpreterToolkit
toolkit = DockerInterpreterToolkit()
# Attach to an agent for secure code execution
Local Python Execution
from evoagentx.tools.interpreter_python import PythonInterpreterToolkit
toolkit = PythonInterpreterToolkit()
# Attach to an agent for local code execution
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment