fix: enforce lookup max_tokens budgets - #1020
Merged
Merged
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
max_tokensbudget against the formatter's actualselected_blocksaccumulator.max_tokensin the query-cache key. This is an incomplete-key defect: a cached payload produced for one budget is not valid for another budget.max_chunkscontrol.Evidence
On a fixed ten-chunk fixture:
max_tokensmax_chunkscontrolThe token ladder is monotone non-decreasing, the 10-token row is strictly smaller than the 2400-token row, and each result is bounded by the requested estimate plus the documented one-first-block and header tolerance. Distinct
max_tokenscalls create distinct cache entries; repeating the same value keeps the cache size unchanged.Three isolated mutations each killed only its matching witness:
selected_blockswith the stalelen(lines) > 1guard killed only the token ladder.max_tokensfrom the cache key killed only the cache witness.max_chunksfrom the cache key killed only themax_chunkscontrol.Validation:
af83265ereproduced the same 23 failures: two missing-build-tool failures, twenty code-index parser/plugin environment failures, and one model-router plugin-state failure.Premium boundary: core OSS retrieval budget and cache correctness only. No identity, organization, entitlement, or premium behavior.
Ref #993 - closes at promotion.