fix(retrieve): only count preference_full_count on actual full render#3177
Open
nankingjing wants to merge 2 commits into
Open
fix(retrieve): only count preference_full_count on actual full render#3177nankingjing wants to merge 2 commits into
nankingjing wants to merge 2 commits into
Conversation
The preference_full_count counter was incremented before the budget check, so the first PREFERENCE_FULL_LIMIT preference memories that *failed* the budget check (e.g. oversized content) wasted the cap. Subsequent preferences that would have fit were denied full rendering even though budget was still available. Move the increment inside the successful-full branch so it only counts when a preference actually renders as 'full'. Add a regression test verifying that preferences after the limit can still render full when the preceding ones overflowed the budget.
Contributor
Author
| Self-reviewed: diff is correct, minimal, and well-tested. No issues found. |
… and parallelization
Contributor
Author
|
Updated the regression test for current main after #3175 introduced parallel recall and content-hash dedupe. The test now uses unique memory content and asserts by URI identity while preserving the original invariant: only successful full renders consume the preference limit. Focused test: pytest tests/server/test_type_quota_preference_counter.py -v (2 passed). |
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.
Bug
In
openviking/retrieve/type_quota_recall.py::search_type_quota_recall, the preference full-render cap counter (preference_full_count) was incremented before the budget check:So the first
PREFERENCE_FULL_LIMITpreference memories that failed the per-type character budget (e.g. oversized content) wasted the cap. Subsequent preferences that would have fit were denied full rendering even though their full fragments fit within both the per-type and global budgets.Fix
Move the increment inside the successful-full branch so it only counts when a preference actually renders as
"full":Regression test
tests/server/test_type_quota_preference_counter.pycovers two scenarios:PREFERENCE_FULL_LIMITentries have oversized content (5KB) that fails the budget; subsequent entries have small content. With the fix, the small entries render as"full"because the cap wasn't wasted on the oversized ones.PREFERENCE_FULL_LIMITrender as"full"; later entries stay at summary/uri. Pins the invariant that the cap still works when content does fit.