Run Code
run_codeExecute source code in an isolated sandbox and return its output, errors, exit status, runtime, and memory, with optional input files and stdin.
Instructions
Run one program in a sandbox and return its output.
Returns output, error, status, exit_code, time (wall-clock seconds), memory and truncated. Limited to 30 seconds (or time_limit) and 512 MB RAM. To check a solution against expected outputs, use run_tests instead.
python-3.14 includes numpy, pandas, scipy, scikit-learn, matplotlib, seaborn, statsmodels,
sympy, openpyxl, pillow, duckdb, polars, wordcloud, pgmpy and nltk (with WordNet, VADER and the
English POS tagger data) (no network, so nothing else can be installed).
Files a program writes to the directory in $OUTPUT_DIR come back in files (png, svg, csv,
json and txt; up to 8 files and 2 MB): PNG charts are returned as images, and SVG, CSV, JSON
and text files with their text. plt.show() saves each open figure as figure-N.png, so
tutorial code returns its chart. Pass files to give the program input data or helper source files.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>",
"compiler": "<compiler>"
},
"name": "run_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The source code to execute | |
| files | No | Files the program can use, up to 20 and 1,000,000 decoded bytes in total: helper source files (compiled with the program) and input data. Each {'name': 'util.py' or 'pkg/util.py', 'content': text, 'encoding': 'utf8' (default) or 'base64'}. They sit in the program's working directory, so pd.read_csv('data.csv') works. | |
| input | No | Standard input (stdin) to provide to the program | |
| compiler | Yes | Compiler identifier (e.g. 'python-3.14', 'gcc-15'). Use list_compilers to see all options. | |
| time_limit | No | Seconds the run may take, above 0 and at most 30. Defaults to 30. |