Repository navigation
Conversation
Closes Tarquinen#548 compress.minContextLimit accepts a percentage string, and a percentage can only be turned into a token count once the host has reported the model context window. Until then resolveContextTokenLimit returned undefined, and isContextOverLimits turned that into: const overMinLimit = minContextLimit === undefined ? true : ... So a configured "15%" behaved exactly like no threshold at all, and the turn/iteration nudges fired from the first request of a session. That is the reported symptom: compression starting at roughly 4% of the window with minContextLimit set to 15%. The same degradation happens for an unparseable value, and for a per-model override (modelMinLimits) whose key does not match the current provider/model. The upper limit already failed closed, which is why only the lower one misbehaved. Now a limit that was configured but could not be evaluated is distinguished from a limit that was never configured: - configured and evaluable -> compared against current usage, as before - configured but not evaluable -> treated as not reached, so no nudge is injected - never configured -> unchanged permissive default Behaviour with a resolvable threshold is unchanged in both directions, which the tests pin down. Tests: tests/nudge-thresholds.test.ts, three cases. The first two fail on the current implementation with `percentage threshold silently became permissive`.
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.
Closes #548
Problem
compress.minContextLimitaccepts a percentage string, and a percentage can only become a token count once the host has reported the model context window. Until thenresolveContextTokenLimitreturnedundefined, andisContextOverLimitscollapsed that into:A configured
"15%"therefore behaved exactly like no threshold at all, and the turn/iteration nudges fired from the first request of a session. That is the reported symptom: compression starting at roughly 4% of the window withminContextLimit: "15%".The same degradation happens when:
"not-a-number"yieldsNaNand falls through toundefined)modelMinLimitsexists but its key does not match the current provider/modelThe upper limit already failed closed, which is why only the lower one misbehaved — the asymmetry is the tell.
Change
A limit that was configured is now distinguished from one that was never configured:
overMinLimitfalse— no nudge is injectedtrue— the existing permissive defaultSo a threshold DCP cannot evaluate yet fails closed, which is the behaviour the user asked for when they set it, and a typo in the config no longer silently enables compression.
Verification
tests/nudge-thresholds.test.ts:minContextLimit: "15%"with the model context window not yet reported →overMinLimit === falseminContextLimit: "not-a-number"→overMinLimit === falseoverMaxLimitis unaffectedThe first two fail on the current implementation with
percentage threshold silently became permissive.Full suite 122 passing on this branch,
tsc --noEmitclean,prettier --checkclean.