SC26AI agents lab + dinner on the river · Nov 17
Parallel Works

Notebooks

pw code can pair with a Jupyter notebook (.ipynb), so the agent can read and edit its cells. Pair it with a running platform kernel as well, and the agent can run Python in that kernel, with the same variables and imports the notebook has loaded.

Pairing a Notebook

Pass --notebook when you start pw code:

# A notebook on this machine
pw code --notebook analysis/eda.ipynb
 
# A notebook in your platform user workspace, from any machine
pw code --notebook workspace:analysis/eda.ipynb
  • A local path must point to an existing .ipynb file.
  • workspace:<path> names a notebook by its path in your platform user workspace. pw code reads and writes it through the platform, so this works from your laptop or a cluster alike. Only the paired notebook is reachable this way; other files in your user workspace are not.

Running Code in the Kernel

Add --kernel with the name of a kernel running on the platform's Notebooks page:

pw code --notebook workspace:analysis/eda.ipynb --kernel my-kernel

The agent can then run Python in that kernel. Because the code shares the notebook's state, the agent can inspect a DataFrame the notebook already loaded, or try code before writing it into a cell. --kernel requires --notebook.

In accept-edits mode, each run asks first and shows the whole code it is about to run. See Approval Prompts.

Each run waits up to 120 seconds by default. The agent can ask for up to 600 seconds; when the time runs out, the kernel is interrupted so the notebook stays usable. Code that calls input() cannot run, since there is no one to type an answer.

If the kernel cannot be reached, the agent is told to check that it is running on the Notebooks page.

Notebook Tools

Pairing gives the agent these tools:

ToolWhat it does
NotebookReadLists every cell's ID, type, execution count, source, and text output.
NotebookEditReplaces a cell's source, inserts a new cell, or deletes a cell. Editing a code cell clears its outputs.
NotebookRunRuns Python in the paired kernel and returns its output. Only with --kernel.

Permissions

The notebook tools follow the permission mode:

ModeNotebookReadNotebookEditNotebookRun
read-onlyAllowedDeniedDenied
planAllowedDeniedDenied
accept-editsAllowedAllowedAsks first
bypass-permissionsAllowedAllowedAllowed

An allow rule such as NotebookRun pre-approves kernel runs in accept-edits mode.