run_python
Run Python code directly via stdin and get stdout, stderr, and exit code. Preserves quotes, f-strings, and backslashes exactly, ideal for executing scripts with complex syntax.
Instructions
Execute Python code and return its stdout, stderr and exit code.
The code is fed to the interpreter over STDIN, so it is never parsed by a shell or split into argv. Write it exactly as it would appear in a .py file: f-strings, nested quotes and backslashes all survive verbatim.
Runs in the working directory (PY_EXEC_CWD or cwd), which is also prepended to PYTHONPATH so the project's own packages import. timeout_s is clamped to [1, PY_EXEC_MAX_TIMEOUT]; on timeout, whatever was produced is still returned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout_s | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |