Skip to main content

make_python_repl

Function make_python_repl 

Source
pub fn make_python_repl(options: MakePythonReplOptions) -> Result<FunctionTool>
Expand description

Creates a sandbox-routed Python tool: it runs code with the sandbox’s execute_code and returns a PythonReplOutput as JSON.

A timeout fails with a PythonReplTimeoutError, cancellation with the sandbox’s SandboxAbortError with the partial output appended to its message as JSON with exit code 130, and any other sandbox failure with a PythonReplError.

use strands::vended_tools::python_repl::{MakePythonReplOptions, make_python_repl};

let tool = make_python_repl(MakePythonReplOptions::builder().language("python3.12").build())?;
assert_eq!(strands::Tool::name(&tool), "python_repl");

§Errors

When name is empty or language does not match LANGUAGE_PATTERN.