Return Markdown section text from the graph, not just a heading's line
Problem
For a question about documentation, Graphify tells the agent where the answer is but not what it says. A Markdown heading node carries its label and a single line (source_location: L42). query_graph, get_node and graphify query return that, and the agent then has to open the .md to read the section, often the whole file.
A public benchmark on X (shumatsumonobu's "agent-readable-docs", 30 docs x 10 questions) measured this. With Graphify the agent opened the Markdown files 197 times, against 23 for a heading line-range index. It cost +87% more than no index and made +43% more round trips, even though Graphify had the best accuracy (0.980). The graph finds the right heading. The agent just can't read it from the graph.
I reproduced the gap on Graphify's own docs (15 files, 425 nodes, a graph built by unmodified v8, 10 questions whose answers sit under one heading each):
query_graphsurfaced the correct heading for 9/10 questions (rank 1 for 7/10).- The answer text was in the
query_graphoutput for 0/10. The agent always has to open the file. - Opening the file the top heading points at cost 91.9k characters for 10 questions. The sections that hold the answers total 5.5k.
Proposal
Return the section text a heading opens, from the graph tools agents already use:
- MCP: a
get_sectiontool (labelornode_id, optionalmax_chars). - CLI:
graphify section "<heading>", withpath/file.md#Headingto pick one heading when several files share a name.
A section runs from its heading to the line before the next heading of the same or a shallower level, so subsections are included. A page node returns the body without frontmatter.
Design constraints:
- No schema change, nothing stored. The end of a section is computed at read time from the current file, using the Markdown extractor's own ATX heading, fence and frontmatter rules. Existing graphs work without a rebuild, and an edit inside a section after indexing can't truncate it.
- Reads are confined to the project root. Control characters are stripped and secrets go through
redact_secrets. A heading that has moved is found by label and flagged. A heading that was removed is refused, with a hint to rungraphify update. get_nodepoints atget_sectionfor Markdown headings, and the always-on and skill text tell agents to use it.
Out of scope (follow-ups)
- Heading search over section bodies.
query_graphranks on labels and misses headings whose answer is only in the body (for example "shrink guard" under "Data Integrity Rules"). A prototypesearch_sections(BM25 over heading + body, top 5 asfile#Heading Lx-Ly+ snippet) cut agent input tokens by a further 87% in my tests. It's a separate change. - Getting agents to call Graphify at all on harnesses without a search hook. OpenCode + DeepSeek V4.1 Flash didn't call Graphify in any of the sessions I ran, whether it was offered through AGENTS.md or MCP. That's a separate issue.
Thanks for opening this issue, @nothariharan. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Fixed by #5166 (0391b037), released in graphify 0.9.110. Thanks @nothariharan.