fix: state ctx_search throttle thresholds as absolute call numbers#920
Open
uwuclxdy wants to merge 1 commit into
Open
fix: state ctx_search throttle thresholds as absolute call numbers#920uwuclxdy wants to merge 1 commit into
uwuclxdy wants to merge 1 commit into
Conversation
The pre-soft-cap throttle line read `call #N/8 ... M call(s) before soft cap`, which mixed the hard-block denominator (8) with a countdown to the soft cap (3) and overcounted the remaining full-result calls by one. Report the soft cap and hard block as absolute call numbers so both limits are unambiguous.
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.
What / Why / How
Root cause: the pre-soft-cap
ctx_searchthrottle line printed> Throttle: call #${searchCallCount}/${SEARCH_BLOCK_AFTER} in this window. ${softCapRemaining} call(s) before soft cap.That mixes two different limits in one sentence. The#N/8denominator is the hard-block cap (SEARCH_BLOCK_AFTER), while "before soft cap" counts down toSEARCH_MAX_RESULTS_AFTER(default3). Since the soft cap engages atsearchCallCount >= SEARCH_MAX_RESULTS_AFTER, call#3is already truncated, so on call#1the old text read "2 call(s) before soft cap" and reported one more full-result call than actually remained.Fix: state both thresholds as absolute call numbers and drop the ambiguous countdown. On call
#1with defaults the line now reads> Throttle: search call #1 this window. Soft cap (fewer results/query) at call #3, hard block at #8. Prefer ctx_search(queries: [...]) array form; it counts as one call.The now-unusedsoftCapRemaininglocal is removed. The at/after-soft-cap⚠branch is left unchanged.Affected platforms
Test plan
npx tsc -b --noEmitclean.npx vitest run tests/core/server.test.tsgreen (499 tests). The source-text assertion inctx_search progressive throttle observabilitythat pinned the old wording was updated to the absolute-threshold phrasing.Checklist
npm testpassesnpm run typecheckpassesnextbranch (unless hotfix)Cross-platform notes
Our CI runs on Ubuntu, macOS, and Windows.
path.join()/path.resolve(), never hardcode/separatorsreadFileSync(0)breaks on Windowsos.tmpdir(), never hardcode/tmp