agent-repl

Shared REPL sessions for coding agents

agent-repl lets you and your coding agents work in the same running Python, Julia, R or other session (see the list below). Agents can use the variables and functions you define, and you can inspect or change theirs as you work.

In this one-minute example, Pi integrates a Lorenz trajectory and stores it as a. The operator adds b from a nearby starting point, then Claude Code uses both arrays to plot their separation.

Details of the demo

The imports and Lorenz function are loaded before filming. The Python example includes that setup. The typing is automated. The agents’ replies and the code they run are real, recorded in real time.

  1. Pi integrates a Lorenz trajectory, stores it as a and plots the attractor.
  2. The operator sends b = odeint(lorenz, [1.0001, 1, 1], t) with !agent-repl-py, from Pi’s shell mode.
  3. Claude Code uses a and b to plot how their separation grows. Both plots appear inline on the REPL page.

Fortran

Here is the same demo in Fortran, using LFortran’s interactive kernel. You send cells with agent-repl-f90, the agents send theirs through their tools, and they all run in the same kernel. This is experimental while LFortran’s REPL matures.

Pi integrates an orbit and plots it with fplotlib. The operator adds a second orbit from a nearby start, then Claude Code plots how far apart they get.

Details of the Fortran demo

A setup cell, sent before filming, loads fplotlib and defines a Runge–Kutta step and an orbit subroutine. fplotlib is built with the same LFortran, and its module files sit in the session’s folder. The step is written in scalars, because LFortran’s REPL can’t yet link some array temporaries from one cell to the next. The Fortran example includes the setup. The typing is automated. The agents’ replies and the code they run are real, recorded in real time.

  1. Pi runs call orbit(1d0, x, y, z) and plots the attractor with fplotlib’s scatter.
  2. The operator declares x2, y2 and z2 and runs call orbit(1.0001d0, x2, y2, z2), in one line with !agent-repl-f90, from Pi’s shell mode.
  3. Claude Code computes the separation as one array expression and plots it with semilogy. Both plots appear inline on the REPL page.

Installation

agent-repl supports Python or IPython, Julia, R, Haskell (GHCi), Clojure, Ruby (irb), Java (jshell), C++ (cling), Octave, MATLAB, gnuplot and, experimentally, Fortran (LFortran). Each has a shortcut for sending code, such as agent-repl-py or agent-repl-f90.

You need Node.js 22 or later, tmux and the runtime you want to use. To install agent-repl and start Python:

npm install -g agent-repl
agent-repl python -d

Add the tools to Claude Code:

claude mcp add --scope user agent-repl -- agent-repl mcp

Ask Claude Code to use the shared Python REPL. To work at the same prompt yourself, run agent-repl attach python in another terminal. The Lorenz example also needs NumPy, SciPy and Matplotlib.

The setup guide covers Codex, OpenCode and other MCP clients.

Pi and the browser preview

agent-repl uses pi-repl’s session handling outside Pi. Inside Pi, use pi-repl to connect to the same sessions.

For a browser view of submitted code and saved plots, use agent-markdown-preview with --repl, as shown in the video.

Code runs with the REPL’s permissions. See the privacy and safety notes before connecting an agent.