Execute code in the sandbox
run_codeExecutes Python, JavaScript, TypeScript, Bash, R, or Java code in a sandbox Jupyter kernel and returns stdout, stderr, rich results, and error tracebacks so you can test code safely.
Instructions
Execute Python/JavaScript/TypeScript/Bash/R/Java in the sandbox Jupyter kernel and return stdout, stderr, rich results and any error traceback. Requires a code-interpreter template. When sandbox_id is omitted a temporary sandbox is created and killed afterwards.
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 to execute. | |
| language | No | Execution language, defaults to "python". | |
| sandbox_id | No | Reuse this sandbox instead of creating a temporary one. | |
| timeout_ms | No | Sandbox TTL in milliseconds. Defaults to SANDBOX_TIMEOUT_MS (300000 = 5 minutes). |