fix(tree_renderer): collapse duplicate sibling/cousin summaries#169
Open
designcomputer wants to merge 1 commit into
Open
fix(tree_renderer): collapse duplicate sibling/cousin summaries#169designcomputer wants to merge 1 commit into
designcomputer wants to merge 1 commit into
Conversation
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.
This was referenced Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_summarynow 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.pyclean.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.