Tools catalog

Notebook edit

Let an agent read and change Jupyter notebooks cell by cell, instead of rewriting the JSON.

1 min read

A notebook is JSON, and rewriting it as text is how cells get lost. notebook_edit edits .ipynb files structurally: list the cells, read one, replace its source, add or delete a cell, or clear every output.

Actions

ActionArgumentsWhat it does
listpathEvery cell with its index, type and first line
readpath, indexOne cell's source
editpath, index, sourceReplace a cell's source
addpath, index, source, cell_typeInsert a code (default) or markdown cell
deletepath, indexRemove a cell
clear_outputspathRemove every saved output

Use it

python
from shipit_agent import Agent, NotebookEditTool
from shipit_agent.llms import build_llm_from_env

agent = Agent(llm=build_llm_from_env(), tools=[NotebookEditTool(root_dir="notebooks")])
agent.run("In analysis.ipynb, add a markdown cell before the chart explaining what it shows.")

root_dir is the folder whose notebooks it may touch; paths outside it are refused. Agent.with_builtins() includes the tool for the project root.

See also