Python REPL Agent Tool (python-repl/index.ts)

sdk-python · strands-ts/src/vended-tools/python-repl/index.ts · typescript · Apache-2.0
ai, cli, security, lang:python, tag:code-execution

Vended tool that runs Python code through the agent's sandbox via Sandbox.executeCode, with a fresh interpreter per call. Reuse when agents need ephemeral Python execution.

// Source: https://github.com/strands-agents/harness-sdk | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Python REPL tool for running Python through the agent's sandbox.
 *
 * A thin shim over `Sandbox.executeCode`. Each call runs in a fresh interpreter,
 * so in-memory state does not persist across calls.
 *
 * @example
 * ```typescript
 * import { Agent } from '@strands-agents/sdk'
 * import { pythonRepl } from '@strands-agents/sdk/vended-tools/python-repl'
 *
 * const agent = new Agent({ tools: [pythonRepl] })
 * ```
 */

export { makePythonRepl, pythonRepl } from './python-repl.js'
export type { MakePythonReplOptions } from './python-repl.js'
export { PYTHON_REPL_DESCRIPTION, PythonReplError } from './types.js'
export type { PythonReplOutpu

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key