Skip to content

fix(tree_renderer): collapse duplicate sibling/cousin summaries#169

Open
designcomputer wants to merge 1 commit into
VectifyAI:mainfrom
designcomputer:fix/pageindex-duplicate-summaries
Open

fix(tree_renderer): collapse duplicate sibling/cousin summaries#169
designcomputer wants to merge 1 commit into
VectifyAI:mainfrom
designcomputer:fix/pageindex-duplicate-summaries

Conversation

@designcomputer

Copy link
Copy Markdown

Problem

PageIndex's whole-page text slicing (not a finer offset) can hand byte-identical source text to multiple nodes that happen to land on the same physical page (VectifyAI/PageIndex#340). This isn't confined to parent/child pairs — siblings and cousins anywhere earlier in the document can collide too. The LLM then writes the same summary for each, and the renderer previously repeated that summary verbatim at every colliding node.

On a real-world example (a 31-page manual with a "no TOC found" fallback that split numbered list items into individual nodes), this produced a 484-line summary file with the same paragraph copy-pasted 10, 8, and 7 times across different sections.

Fix

_render_nodes_summary now tracks every summary already rendered, mapped to the title that first produced it (seen: dict[str, str], threaded through the recursion). A later node with an identical summary renders as _(same content as "<title>" above)_ instead of repeating the block.

Testing

Added three tests: direct-sibling collapsing, cross-branch ("cousin") collapsing (confirming this isn't scoped to parent/child), and a negative test confirming genuinely distinct summaries are never collapsed. Full suite (929 tests) passes; ruff format, ruff check, mypy openkb/tree_renderer.py clean.

Found while investigating PageIndex long-doc rendering quality for a real knowledge base — sibling PRs: #167 (title truncation), #168 (source text rendering), plus #166 (images) to follow.

PageIndex's whole-page text slicing (not a finer offset) can hand
byte-identical source text to multiple nodes that happen to land on
the same physical page (see VectifyAI/PageIndex#340) — not just
parent/child pairs, but siblings and cousins anywhere earlier in the
document. The LLM then writes the same summary for each, which the
renderer previously repeated verbatim at every one of them.

Track every summary already rendered, mapped to the title that first
produced it. A later node with an identical summary now renders as a
short pointer back to that title instead of repeating the block.
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