Skip to content

repl

repl

Persistent Python REPL tool — maintains state across calls within a session.

Unlike CodeInterpreterTool (which runs each snippet in a fresh subprocess), this tool keeps variables, functions, and imports alive across invocations within the same session.

Classes

ReplTool

ReplTool(timeout: int = 30, max_output: int = 10000, max_sessions: int = 16)

Bases: BaseTool

Persistent Python REPL with session management.

PARAMETER DESCRIPTION
timeout

Maximum execution time in seconds per call.

TYPE: int DEFAULT: 30

max_output

Maximum characters of captured output.

TYPE: int DEFAULT: 10000

max_sessions

Maximum concurrent sessions (LRU eviction).

TYPE: int DEFAULT: 16

Source code in src/openjarvis/tools/repl.py
def __init__(
    self,
    timeout: int = 30,
    max_output: int = 10000,
    max_sessions: int = 16,
) -> None:
    self._timeout = timeout
    self._max_output = max_output
    self._max_sessions = max_sessions
    self._sessions: Dict[str, _ReplSession] = {}
    self._lock = threading.Lock()