Skip to content
igaurab edited this page Nov 27, 2026 · 2 revisions

The agent panel puts a coding agent beside the notebook. The agent reads the cells, changes them, runs them on your kernel and looks at the variables. You see each change at once.

The agent panel is new. If gpython says that :agent is not a command, your gpython is older than this page. gpython --update gets the newest release.

On this page:

What you need

gpython starts the agent; it does not install it. The agent must be installed and logged in before you use it here.

Name Agent What gpython runs What you need
claude Claude Code npx -y @agentclientprotocol/claude-agent-acp claude and npx
codex Codex npx -y @agentclientprotocol/codex-acp codex and npx
opencode OpenCode opencode acp opencode
gemini Gemini gemini --acp gemini
pi pi npx -y pi-acp pi and npx

npx comes with Node.js. For Claude Code, Codex and pi it gets a small adapter program the first time, so the first start is slower.

To check an agent, run its own command in a terminal (claude, codex, opencode, gemini, pi) and make sure that it answers.

Open the panel

Command Result
:agent Show the panel and go to it. The first time, this starts the agent. From the panel, :agent hides it
:agent codex Start that agent in a new conversation
:agent new Start a new conversation with the same agent
:agent stop End the agent. The conversation stays on screen
:agent hide Hide the panel. The agent and the conversation stay

Type what you want in the line at the bottom and press enter. A line that you send while the agent starts is sent when the agent is ready.

With each line, gpython tells the agent which notebook is open, how many cells it has and which cell the cursor is in. You can say "this cell" or "c5".

Keys in the panel

Key Result
enter Send the line
ctrl+c Stop the agent's turn
1 - 9 Answer the agent's question about permission with that choice
escape or n Refuse the permission
pageup / pagedown Scroll the conversation
escape Go back to the notebook. The panel stays
ctrl+w h Go back to the notebook
ctrl+w l From the rightmost window: go to the panel

While the cursor is in the panel, the notebook keys (ctrl+d, ctrl+n and the others) do nothing to the notebook.

Choose the agent

:agent starts the default agent. With no setting, the default is the first agent in the table above that is installed.

Command Result
:agent default codex :agent starts Codex from now on. gpython saves this
:agent default Show the default agent and the names you can use

In the config file:

[agent]
default = "codex"

What stays in the conversation

An agent makes many tool calls and writes its thoughts while it works. By default gpython shows them while the agent works and removes them when the agent is done. One line, such as 5 tool calls, stays in their place.

Mode Result
fold Shown while the agent works. Then one line tells you how many tool calls there were (the default)
keep They stay in the conversation
hide They never show
Command Result
:agent tools keep Set the mode for tool calls
:agent thoughts hide Set the mode for the agent's thoughts
:agent tools Show the mode

gpython saves the mode. A change applies from the agent's next step.

A tool call is one line. A long shell command is cut at the edge of the panel. A question about permission always shows the full command.

What the agent can do

The agent gets these tools for the open notebook:

Tool Result
notebooks List the open notebooks
cells_read Read cells: source, run state and output. A plot comes back as a picture
cell_edit Change the text of a cell
cell_insert Add a cell, and run it if asked
cell_delete Remove a cell
cells_run Run cells (numbers, all, or the out-of-date ones) and wait for the result
variables List the variables in the kernel
variable_value The full value of one variable
python_eval Run code in the kernel without a cell, to look at values
kernel Interrupt or restart the kernel
notebook_save Save the notebook
  • A change by the agent is the same as a change by you: u takes it back, and the cells that depend on it become out of date.
  • The agent uses your kernel. It sees the values that your cells made, and what it runs changes them.
  • The agent can also use its own tools (read files, run shell commands). It asks for permission as it does in its own program.

Add another agent

Any program that speaks the Agent Client Protocol on its standard input and output can be an agent. Give it a name and a command in the config file:

[agents]
mine = "my-agent --acp"
claude = "claude-agent-acp"

:agent mine starts it. A built-in name with a command, such as claude above, uses your command.

An agent in another terminal

An agent that runs in its own terminal can use the same notebook tools. gpython must be open.

  1. In gpython, type :agent link.

  2. In the agent's terminal, add gpython as an MCP server. Do this one time:

    claude mcp add gpython -- gpython mcp
    codex mcp add gpython -- gpython mcp

gpython mcp finds the gpython that is open in the same folder, or the newest one. The link accepts connections from this computer only, and only with a secret that gpython writes to a file that only you can read (~/.gpython/links/).

Settings

Config key Values Default Command
[agent] default An agent name The first installed agent :agent default NAME
[agent] tools keep, fold, hide fold :agent tools MODE
[agent] thoughts keep, fold, hide fold :agent thoughts MODE
[agents] NAME A command

Limits

  • If the agent changes the notebook's file on disk, the open window does not show the change. gpython tells the agent to use the notebook tools. If it happens, :e! file opens the file again and discards what the window has.
  • The line that you type is one line.
  • The agent's model and mode are those of its own program. gpython has no picker for them.
  • A new conversation does not remember the previous one.

Clone this wiki locally