tools / execute.py

Sandboxed code execution with multiple validation guards and stateful Jupyter support.

Tool: execute

Three execution modes selected from arguments:

1. Bash command (line 32-117)

2. File execution (line 119-494)

3. Stateful Jupyter (line 198-306)

Output handling

Truncates output at 512 KB (head 100 KB + tail 400 KB). Extracts error line numbers and produces snippet context for tracebacks. Diagnostic mode shows the surrounding lines around an error.

Return shape

--- EXECUTION RESULT ---
EXIT CODE: {code}
STDOUT/STDERR:
{output}

Safety guards summary