Skip to main content

Module python_repl

Module python_repl 

Source
Expand description

The sandbox-routed python_repl tool.

Each call pipes the code to a fresh interpreter in the sandbox, so variables, imports and definitions do not persist across calls; files written to the sandbox do.

Structs§

MakePythonReplOptions
Options for make_python_repl (MakePythonReplOptions).
MakePythonReplOptionsBuilder
Use builder syntax to set the inputs and finish with build().
PythonReplError
The sandbox failed to run the code (PythonReplError), for example an unreachable container. Errors in the code itself are results with error and a non-zero exit_code.
PythonReplOutput
What the interpreter produced (PythonReplOutput).
PythonReplTimeoutError
The code exceeded its timeout: the sandbox’s SandboxTimeoutError (the source) with the partial output appended to the message as JSON with exit code 124, because the model sees only the message.

Constants§

PYTHON_REPL_DESCRIPTION
The description of the python_repl tool shown to the model (PYTHON_REPL_DESCRIPTION).

Functions§

make_python_repl
Creates a sandbox-routed Python tool: it runs code with the sandbox’s execute_code and returns a PythonReplOutput as JSON.
python_repl
The default python_repl tool, running in the calling agent’s sandbox.