Copy this notebook before editing it. Run setup, then ask one AI question at a time. The read questions inspect this open notebook, including unsaved or offscreen cells; the edit questions each use a different scratch cell below so one demonstration does not invalidate another. Browser-backed functions are offered to the model through the declaration note, not called directly from Python. Review each changed cell and save the copy only if you want to keep it.
Tool catalog: live notebook cells
Copy this notebook before editing it. Run setup, then ask one AI question at a time. The read questions inspect this open notebook, including unsaved or offscreen cells; the edit questions each use a different scratch cell below so one demonstration does not invalidate another. Browser-backed functions are offered to the model through the declaration note, not called directly from Python. Review each changed cell and save the copy only if you want to keep it.
from nbinlineai.tools import tools_markdown
from nbinlineai.tools import list_cells, read_cell, find_cells, insert_markdown, insert_code, replace_cell, cell_str_replace, cell_insert_line, cell_replace_lines, delete_cell, move_cell, copy_cell, split_cell, merge_cells
print("Live notebook tools imported for AI questions below.")
Live notebook tools imported for AI questions below.
Available tools (delete any line you do not want to offer):
- &`list_cells` — List live notebook cells, including unsaved edits, by ID and position.
- &`read_cell` — Read live notebook cell source, including unsaved edits, by cell ID.
These browser-backed functions have no direct Python-call variant. For a manual comparison, use a second disposable copy of this notebook in JupyterLab. The AI questions below run against the open first copy; manual editor actions in the second copy must not alter their scratch cells.
The editor is the normal manual route; the & questions demonstrate the corresponding controlled AI tool route and report stable IDs or edit acknowledgements.
Observed in JupyterLab (list_cells): The visible list reaches the scratch heading, then catalog-scratch-read before catalog-scratch-replace.
Observed in JupyterLab (read_cell): The editor displays catalog_marker_read = “current”.
Observed in JupyterLab (find_cells): Notebook Find showed 6/17 matches for catalog_marker.
Observed in JupyterLab (insert_markdown): A new Markdown cell immediately below it displays Disposable manual note. (e8925436).
Observed in JupyterLab (insert_code): A new unrun code cell immediately below it contains manual_inserted_code = 1 (8bb1e5bc).
Observed in JupyterLab (replace_cell): The same cell ID now contains catalog_marker_replace = 9.
Observed in JupyterLab (cell_str_replace): The same cell now reads catalog_marker_literal = “green”.
Observed in JupyterLab (cell_insert_line): A new comment line was inserted between the original two code lines.
Observed in JupyterLab (cell_replace_lines): The first line remains = 3 and the second now reads catalog_marker_lines = 5.
Observed in JupyterLab (delete_cell): Delete Cell removed that disposable cell from the saved notebook.
Observed in JupyterLab (move_cell): Move Cell Up placed the same cell ID one position earlier.
Observed in JupyterLab (copy_cell): Paste Cell Below created a second code cell with the same source (96e2dd4c).
Observed in JupyterLab (split_cell): Split Cell created a first-line cell (c9f54630) and retained the second line in the original cell.
Observed in JupyterLab (merge_cells): Merge Cell Below retained both note paragraphs in one cell (2068532f) and removed the other cell ID.
list_cells
Use list_cells(start=0, limit=20) and report the stable IDs of the first two AI question cells in this notebook. Do not execute either question.
The first two AI question cell IDs are catalog-demo-list_cells and catalog-demo-read_cell.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
Returned the ten matching scratch code-cell IDs listed in the answer.
insert_markdown
Use insert_markdown(content="Catalog note: inspect before saving.") to add an ordinary note after your answer. This changes the live notebook; save only if you want it.
Inserted the Markdown note after this answer in the live notebook (cell 057bc5f0-f40e-4727-a5eb-f80de2aab559). It has not been saved to disk.
Catalog note: inspect before saving.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
Inserted one ordinary code cell after the answer, with no execution count or outputs. The worked copy was saved afterward.
replace_cell
Use read_cell to get the complete current source of catalog-scratch-replace, including its trailing newline. Then use replace_cell with that exact expected_source and new_source catalog_marker_replace = 2\n.
Replaced catalog-scratch-replace with catalog_marker_replace = 2\n after confirming its complete source, including the trailing newline. The live notebook change is not saved to disk.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
The worked copy was saved afterward. The deleted scratch cell is restored below for replay.
move_cell
Use move_cell(cell_id="catalog-scratch-move", after_cell_id="catalog-scratch-copy") to move the ordinary scratch cell. Then use list_cells(start=55, limit=20) to verify and report the resulting order without executing cells.
Moved catalog-scratch-move after catalog-scratch-copy. The live cell order is now catalog-scratch-copy (61) → catalog-scratch-move (62) → catalog-scratch-split (63). No cells were executed; the change is not saved to disk.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
Created unexecuted code cell 57435006-7e6b-414a-b3dd-3d36af557235 directly after the anchor.
The worked copy was saved afterward. The new unexecuted copy remains below.
split_cell
Use split_cell on catalog-scratch-split before line 2, passing its complete current source as expected_source. Report both resulting IDs.
Split before line 2. The resulting cell IDs are catalog-scratch-split and d7d916b9-f8f8-4689-af6e-8895a9824ff2. The live notebook change is not saved to disk.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
Split the live source into the retained ID and new unexecuted cell d7d916b9-f8f8-4689-af6e-8895a9824ff2.
The worked copy was saved afterward. The original two-line scratch source is restored below for replay; the new unexecuted cell remains visible.
merge_cells
Use read_cell(cell_id="catalog-scratch-merge-first") and read_cell(cell_id="catalog-scratch-merge-second") to get both complete current sources. Then use merge_cells on these adjacent Markdown cells with those exact sources. After merging, call read_cell(cell_id="catalog-scratch-merge-first") once on the retained cell and report its exact merged source. End after that read.
The retained cell catalog-scratch-merge-first now contains exactly:
First disposable note.
Second disposable note.
The source ends with a newline. The change is not saved to disk.
Observed live tool calls for the answer above (actual subscription events; private fields shortened).
The worked copy was saved afterward. Both original Markdown scratch cells are restored below for replay.
Disposable scratch cells
These cells supply stable IDs and complete, short source for the edit questions. The questions may act on cells below them because live tools use the notebook model.
In the worked copy, each AI edit is observed with its before-and-after result. The disposable scratch cells are then restored to the original IDs, source, and order so you can replay the examples. Verified notes and code inserted by insert_markdown or insert_code remain visible; the inserted code is not run automatically.