Repository navigation
fix(tier2): number shared review blocks from the most repeated text - #361
Merged
Merged
Conversation
A reference to shared block 10 or later is one character longer than one to blocks 1-9, and its header is too. No test covered that part of the cost model: passing a constant index to the saving check still passed every intra_skill test, and then shared a 64-character text repeated twice as block 10 although that made the prompt no shorter. Add a case with nine texts worth sharing and a tenth text repeated twice on the two-digit boundary: 64 characters stays inline, 65 is shared. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…text inline The CHANGELOG, the Tier 2 deduplication guide and the build_user_prompt docstring said a short text repeated under long headings stays inline. The heading line stays with every occurrence whether or not the body is shared, so only the body's length and repeat count decide: "See guide." under 200 short "## Hn" headings stays inline too. Long headings only explain why such a cluster was over budget. State the actual rule, and add a test that a short repeated body stays inline under short and long headings alike. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
build_user_prompt numbered shared blocks in first-seen order, and a reference to block 10 or later is one character longer than one to blocks 1-9. Nine rarely repeated texts seen first could push a body repeated 400 times to block 10: the request came to 64,022 characters and the scan stopped with llm_prompt_size_limit, while sharing the body as block 1 gave 63,630. For any set of shared texts the prompt is shortest when the most repeated texts get the lowest numbers, so candidates are now numbered in descending repeat count, ties in first-seen order. Choosing them greedily in that order is still not enough: a highly repeated text that saves only a little can push another past block 9 and cost it more than it saves. Which candidates to share is now chosen exactly by dynamic programming over that order. It runs in about 20 ms for the 512-member worst case and matched an exhaustive search over every ordered subset in 400 random clusters. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisknvidia
reviewed
Nov 6, 2026
chrisknvidia
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the shared-text selection. The dynamic program prices the extra character for block 10 and above correctly, and the three tests cover the two-digit overhead, the shortest reference going to the most-repeated text, and the marginal text that would push another past block 9. Non-blocking: the table is quadratic in the number of repeated texts. I measured 4.8 s for 2,000 distinct texts and 31 s for 5,000 by calling build_user_prompt directly. Those sizes are far above the 512-member cluster cap, so normal runs are unaffected, but a short comment noting that the cap bounds this cost would help whoever changes the cap. I merged main into the branch to clear the conflict.
…are-order Signed-off-by: Christopher Kevin <[email protected]>
rng1995
marked this pull request as ready for review
November 6, 2026 12:20
rng1995
added a commit
that referenced
this pull request
Nov 6, 2026
…Unreleased Nine PRs merged after the v0.8.0 tag (8149356). Four of them rewrote bullets inside the 0.8.0 section and one added a new bullet there, so main's 0.8.0 notes described behavior that 0.8.0 does not have. Two fixes to 0.8.0 features added no entry. - Restore the 0.8.0 section and everything below it to the tagged text, byte for byte. - Move the agent skill entry (#366) to Unreleased, Added. - Add Documentation entries for the 0.8.0 wording that #360, #361 and #363 corrected (refusal coverage error, inline short texts, capitalized HTTP prose that still warns). - Add Fixed entries for #361, #365, #359, #364 and #363 that describe only what changed after 0.8.0. The #364 entry states that path masking skips text after a non-file: URL up to the next whitespace, which is how main behaves today. - Move the #348 entry to Fixed and say what 0.8.0 did: a CI-redacted PII finding kept the digest of its unmasked value. - The refusal docs test now reads the Documentation correction, which matches the docs, and still requires the switch's entry in 0.8.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
added a commit
that referenced
this pull request
Nov 6, 2026
…Unreleased Nine PRs merged after the v0.8.0 tag (8149356). Four of them rewrote bullets inside the 0.8.0 section and one added a new bullet there, so main's 0.8.0 notes described behavior that 0.8.0 does not have. Two fixes to 0.8.0 features added no entry. - Restore the 0.8.0 section and everything below it to the tagged text, byte for byte. - Move the agent skill entry (#366) to Unreleased, Added. - Add Documentation entries for the 0.8.0 wording that #360, #361 and #363 corrected (refusal coverage error, inline short texts, capitalized HTTP prose that still warns). - Add Fixed entries for #361, #365, #359, #364 and #363 that describe only what changed after 0.8.0. The #364 entry states that path masking skips text after a non-file: URL up to the next whitespace, which is how main behaves today. - Move the #348 entry to Fixed and say what 0.8.0 did: a CI-redacted PII finding kept the digest of its unmasked value. - The refusal docs test now reads the Documentation correction, which matches the docs, and still requires the switch's entry in 0.8.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Narendran Raghavan <[email protected]>
rng1995
added a commit
that referenced
this pull request
Nov 6, 2026
…Unreleased (#371) Nine PRs merged after the v0.8.0 tag (8149356). Four of them rewrote bullets inside the 0.8.0 section and one added a new bullet there, so main's 0.8.0 notes described behavior that 0.8.0 does not have. Two fixes to 0.8.0 features added no entry. - Restore the 0.8.0 section and everything below it to the tagged text, byte for byte. - Move the agent skill entry (#366) to Unreleased, Added. - Add Documentation entries for the 0.8.0 wording that #360, #361 and #363 corrected (refusal coverage error, inline short texts, capitalized HTTP prose that still warns). - Add Fixed entries for #361, #365, #359, #364 and #363 that describe only what changed after 0.8.0. The #364 entry states that path masking skips text after a non-file: URL up to the next whitespace, which is how main behaves today. - Move the #348 entry to Fixed and say what 0.8.0 did: a CI-redacted PII finding kept the digest of its unmasked value. - The refusal docs test now reads the Documentation correction, which matches the docs, and still requires the switch's entry in 0.8.0. Signed-off-by: Narendran Raghavan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Summary
Follow-up to #346, which merged before its last review round. #346 shares a repeated text in a Tier 2 review prompt only when its block and references are shorter than its inline copies. It numbers the shared blocks in first-seen order, and a reference to block 10 or later is one character longer than one to blocks 1-9.
That can refuse a cluster that would fit. Example on
main: nine different 62-character texts, each repeated twice, come first, then a 40-character body repeated 400 times and one 26,100-character distinct section. The 400-copy body becomes[SHARED CONTENT 10], the request is 64,022 characters, and the scan stops withllm_prompt_size_limit. Sharing the body as block 1 gives 63,630 characters.build_user_promptnow numbers candidate texts in descending repeat count, with ties in first-seen order, and chooses which of them to share exactly (dynamic programming over that order). A greedy pass in count order is not enough: a highly repeated text that saves only a little can push another text past block 9 and cost it more than it saves.intra_skilltest.docs/tier2-deduplication.mdxand thebuild_user_promptdocstring no longer say that a short text "under long headings" stays inline. The heading line stays with every occurrence whether or not the body is shared, so only the body's length and repeat count decide.See guide.under 200 short## Hnheadings stays inline too.Why
#338 and #346 aim to finish scans of skills with heavily repeated content instead of marking deduplication incomplete. A numbering that makes the most referenced text pay an extra character per reference works against that near the budget. The docs should also give the rule that actually decides sharing, so authors are not led to shorten headings to no effect.
Kept from public
Tests
tests/deduplication/intra_skill/test_intra_llm_analyzer.py:tests/deduplication/intra_skill/test_intra_llm_analyzer.py: 37 passed.tests/deduplication/intra_skill: 136 passed.tests/deduplication,tests/test_ci_workflows.pyandtests/test_accuracy_arithmetic.pyonmainbefore feat(tier3): split measured agent time into LLM and tool seconds #344 plus this change: 371 passed, 1 skipped. feat(tier3): split measured agent time into LLM and tool seconds #344 touches only Tier 3 and its own CHANGELOG lines, and the branch merges cleanly with currentmain.ruff checkandruff format --checkare clean on the changed files, andscripts/check_oss_boundary.pypasses.🤖 Generated with Claude Code