run_code
Execute Python or C++ code snippets in isolated Docker containers with no network access, memory cap, and read-only filesystem. Returns output, status, and duration for safe code testing and verification.
Instructions
Execute a Python or C++ code snippet inside an isolated, network-disabled Docker container and return its output.
Each run happens in a fresh, ephemeral container with no network access, a
256 MB memory cap, a 0.5 CPU cap, and a read-only root filesystem. The
container is destroyed immediately after the run. Use this tool to run
untrusted or exploratory code snippets, verify that code works, or inspect
program output, without touching the host machine.
Returns a dict with:
- status: one of "success", "error", "timeout", or "compile_error" (C++ only)
- exit_code: the process exit code, or null if it never ran
- stdout / stderr: captured output, truncated at 100 KB
- duration_ms: wall-clock execution time in milliseconds
- language: the normalized language that was actually run
Note: this sandbox provides Docker-level isolation suitable for personal/
local use. It is not a hardened multi-tenant sandbox and should not be
used to run code from untrusted third parties in a production setting.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The full source code to execute, as a single string. Max size 50 KB. For C++, this must be a complete, compilable program including a main() function and any necessary #include directives. For Python, this is executed directly as a standalone script. | |
| language | Yes | Programming language of the snippet. Supported values: 'python' (runs in python:3.12-slim) and 'cpp' (compiled with g++ -std=c++17 -O2 then run in gcc:14). Case-insensitive. | |
| timeout_seconds | No | Maximum time in seconds to allow the code to run before it is force-killed. Default 10, hard ceiling 30 (requests above this are rejected). For C++, this timeout applies to the run stage only, not the compile stage. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||