ModelRefs / REPL Tool — Tool Pattern
REPL Tool — Tool Pattern
Stateful sandbox where variables persist across calls, letting the model iterate like a notebook. A long-lived REPL session per conversation.
Overview
A long-lived REPL session per conversation. The model can define variables, import data, and reference them across multiple tool calls without re-uploading.
When to use it: You want stateful, iterative analysis within a session.
Pattern details
| Pattern class | code-execution |
|---|---|
| Difficulty | advanced |
| Invocation mode | synchronous |
| Also known as | stateful sandbox, notebook tool |
| Last reviewed | 2026-06-07 |
Known failure modes
- State poisoning — Earlier calls leave the kernel in a broken state. Mitigation: Expose a reset action and detect repeated errors.
- Resource leak — Long sessions accumulate memory. Mitigation: Enforce per-session memory cap and TTL.
When not to use it
- Sharing one kernel across multiple users.
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to REPL Tool — Tool Pattern.
Frequently asked questions
When should I use the REPL Tool tool pattern?
You want stateful, iterative analysis within a session.
What are common failure modes of REPL Tool?
State poisoning • Resource leak
Is REPL Tool production-ready?
Yes when paired with the safety controls and observability hooks documented on the pattern page.