Skip to content

Create the agent's create_node through the document path the CLI uses - #4275

Merged
mstomar125 merged 2 commits into
mainfrom
agent-create-node-document
Nov 13, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
agent-create-node-document

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

What

The in-app agent's create_node now calls node_ops::create_document_node (the function behind the CLI's CreateDocument RPC) instead of node_ops::create_node. No parsing is re-implemented. The same text through the tool and through the CLI gives the same tree: same child types and order, same title rule (first line), same front-matter handling (to custom:/declared properties on the root), same document-type allow-list, same 1 MB / 1000-node caps and error messages (the tool wraps the core message as create_node failed: ...).

The result carries child_count when a body was written, and the tool description tells the model content may be a document.

Why

User decision on #4237: the agent tool takes document markdown like the CLI.

Non-document types

The allow-list is text, task, project, spec, plan, decision, plus types extending them (issue, software-project, custom types that extend one). Everything else (header, code-block, quote-block, table, person, date, collection, schema, plain custom types like ticket) keeps multi-line content as given, as before; verified by a test with quote-block. Single-block content with no front matter is stored as given for every type.

Parity test

create_node_document_parity in packages/agent/src/local_agent/tools.rs:

  • the_tool_and_the_cli_path_give_the_same_tree (text, task, decision; front matter, header, paragraph, ordered list, checkbox, code fence): fails on main (tool leaves the whole text in one node), passes now.
  • a_bad_first_line_is_refused_with_the_cli_message: fails on main (tool created a node), passes now.
  • a_block_type_keeps_multi_line_content_whole and a_single_line_is_stored_as_given: guards. Mutation: removing the allow-list in core makes the block-type test fail; removing child_count makes the tree test fail. The single-line test holds under every mutation I tried (core also stores a single line as given), so it is a regression guard only.

Risk review of existing flows

Grepped seeds/rules, guidance, goldens, evals, and the agent tests. Seeded rules create one node per call with one-line or one-paragraph content (decision-create, skill-authoring-create, section-create, task-review-*, task-breakdown-create, spec/plan create), so they are unchanged in behaviour; task-review-note / decision-create text with several paragraphs would now become a root plus children instead of one multi-line node. Bulk import still goes through create_nodes_from_markdown, untouched. No seed changed, so no shape-record entry is needed (shape files untouched). The only snapshot affected is stage2_tool_surface.golden (tool description), regenerated. The older goldens/*.toml ablation files embed historical tool text and are not checked against the live description. All 1056 agent lib tests and the prompt snapshot tests pass (one unrelated test, a_held_update_nodes_schema_decision..., failed once in a full run and passed on every rerun and on main in isolation).

Limits

1 MB content and 1000 nodes per call (core's MAX_MARKDOWN_SIZE / MAX_NODES_PER_IMPORT). Root and body are two transactions; on body failure the root is deleted and the call fails (core behaviour).

Not run: live model runs (handled separately), so the new description sentence is unmeasured against the model.

Refs #4237

🤖 Generated with Claude Code

mstomar125 and others added 2 commits November 13, 2026 12:14
exec_create_node calls node_ops::create_document_node instead of
create_node, so a text, task, project, spec, plan or decision (and the
types that extend them) given a markdown document gets the same tree as
`nodespace node create`: first line the title, front matter the fields,
the rest parsed into children, with the same type allow-list, caps and
errors. Single-block content and every other type are stored as given.
The result reports child_count when a body was written, and the tool
description says content may be a document. Adds parity tests and
updates the tool-surface golden.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ace a failure

The descendants query runs only when the content has a line break, and a
failure to read it is returned instead of dropping child_count. The tool
description now names the document case as the exception to "title and
nothing else" and points imports at create_nodes_from_markdown.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant