Allow summarization threshold setting to be a ratio or token count#319220
Merged
Conversation
chat.advanced.summarizeAgentConversationHistoryThreshold now accepts either a ratio of the model's context window (0 < value <= 1, e.g. 0.8 for 80%) or an absolute token count (value >= 100). A new resolveSummarizeThresholdTokens() helper resolves the value; ratios track model/context-size changes automatically. Values in the ambiguous (1, 100) gap are rejected so a typo like 80 (meant as 80%) fails loudly instead of compacting after 80 tokens.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Copilot extension’s agent history compaction threshold setting to accept either a ratio of the effective model context window or an absolute token count, then resolves it to a concrete token budget at runtime.
Changes:
- Added
resolveSummarizeThresholdTokens()to interpret the configured threshold as either(0, 1]ratio or>= 100tokens, rejecting ambiguous(1, 100)values. - Updated agent prompt budget calculation to use the resolved token threshold before clamping to the effective context window.
- Added dedicated unit tests and expanded the setting’s UI description to explain the new input formats.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/intents/node/agentIntent.ts | Adds the threshold-resolution helper and applies it when computing the agent prompt budget. |
| extensions/copilot/src/extension/intents/node/test/summarizeThreshold.spec.ts | New tests covering unset/non-positive behavior, ratio resolution, absolute passthrough, and ambiguous-range rejection. |
| extensions/copilot/package.nls.json | Updates the setting description to document ratio vs absolute token usage. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
roblourens
approved these changes
May 31, 2026
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.
chat.advanced.summarizeAgentConversationHistoryThresholdpreviously only accepted an absolute token count. This makes it accept either:0 < value <= 1(e.g.0.8to compact at 80%), orvalue >= 100(e.g.60000).A new
resolveSummarizeThresholdTokens()helper resolves the configured value against the effective context window. Ratios automatically track model / context-size changes, so users no longer have to recompute a token number when the window grows.Values in the ambiguous
(1, 100)gap are rejected with a clear error, so a typo like80(meant as 80%) fails loudly instead of silently compacting after 80 tokens.Tests: 4 new specs in
summarizeThreshold.spec.tscovering undefined/non-positive → undefined, ratio resolution, absolute passthrough, and rejection of the ambiguous range. All pass.