refactor(agent): improve notebook prompts and tool response clarity#351
refactor(agent): improve notebook prompts and tool response clarity#351moyiliyi wants to merge 4 commits into
Conversation
|
Really nice work on this, and thank you for taking the time to include tests. It's a pleasure to review. A few notes from reading through it: Returning the inserted cell index is a great idea, and the code looks spot on. I followed it all the way through: The Two things on
The notebook instruction updates toward smaller, step-by-step exploration read really well too, and splitting the guidance into exploratory versus more defined tasks is a thoughtful distinction. Overall this is clean, careful, well-tested work. The cell-index part looks ready to go as is, and the two |
|
Hi @pjdoland , I’ve just pushed a follow-up fix based on your feedback. The truncation marker now shows where the output stopped Let me know if this looks better now. |
Summary
This PR combines three related improvements to notebook-agent behavior and tool response clarity.
add-code-cellandadd-markdown-cellto return the insertedcellIndexwhen available, improving traceability in iterative notebook editing.read_fileso large file reads stay within an output budget, with regression tests covering truncation, multibyte content, and non-text files.Motivation
In a data analysis and modeling task, the agent followed the prompt by first stating a high-level goal and then proceeding to generate the entire notebook implementation in one pass. For exploratory notebook work, this is not a reasonable default behavior. The notebook instructions should instead encourage incremental analysis, intermediate validation, and task-adaptive planning rather than upfront full-pipeline code generation.
add-celltool actions previously returned generic success responses, which made it harder to reference newly inserted cells in subsequent steps. Returning the inserted cellIndex improves traceability for iterative notebook workflows.read_filecould emit overly large outputs, which is risky for tool usability and model context management.What changed
add_code_cellandadd_markdown_cellresponses to return{ cellIndex }when the UI command provides it.max_output_tokenstoread_file, with UTF-8-safe truncation and an[output truncated]marker.