Run code
run_codeSave code to a temporary file in the sandbox and run it with python (default), node or bash; returns exit_code, stdout, stderr and duration. Use it for multi-line programs and quick experiments. A single shell line is shorter as a plain shell command, and work longer than a few minutes belongs in a background job, which keeps running without this connection.
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>"
},
"name": "run_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Source code | |
| language | No | Language (default python) | |
| timeout_s | No | Time limit in seconds (default 120) | |
| sandbox_id | No | Sandbox ID (sb_…). If omitted, the current sandbox of this session is used. A sandbox_id you pass becomes the current sandbox for later calls without sandbox_id. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stderr | Yes | Standard error output. | |
| stdout | Yes | Standard output (very long output is shortened in the middle). | |
| exit_code | Yes | Exit code of the command (non-zero is a normal result, not a tool error). | |
| shortened | Yes | stdout or stderr was shortened in the middle for this reply (a marker shows how many characters are missing). | |
| timed_out | Yes | The time limit was exceeded and the process was killed. | |
| truncated | Yes | stdout or stderr is incomplete (either of the two reasons below) – redirect large output to a file and read the part you need. | |
| sandbox_id | Yes | Sandbox ID. | |
| duration_ms | Yes | How long the command ran, in milliseconds. | |
| output_limit_hit | Yes | The command produced more than 1 MB of output and the rest was cut off in the sandbox. |