Skip to content

Allow summarization threshold setting to be a ratio or token count#319220

Merged
bhavyaus merged 3 commits into
mainfrom
dev/bhavyau/summarize-threshold-ratio-or-tokens
May 31, 2026
Merged

Allow summarization threshold setting to be a ratio or token count#319220
bhavyaus merged 3 commits into
mainfrom
dev/bhavyau/summarize-threshold-ratio-or-tokens

Conversation

@bhavyaus
Copy link
Copy Markdown
Collaborator

chat.advanced.summarizeAgentConversationHistoryThreshold previously only accepted an absolute token count. This makes it accept either:

  • a ratio of the model's context window — 0 < value <= 1 (e.g. 0.8 to compact at 80%), or
  • an absolute token countvalue >= 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 like 80 (meant as 80%) fails loudly instead of silently compacting after 80 tokens.

Tests: 4 new specs in summarizeThreshold.spec.ts covering undefined/non-positive → undefined, ratio resolution, absolute passthrough, and rejection of the ambiguous range. All pass.

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.
Copilot AI review requested due to automatic review settings May 31, 2026 21:17
@bhavyaus bhavyaus enabled auto-merge (squash) May 31, 2026 21:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 >= 100 tokens, 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

Comment thread extensions/copilot/src/extension/intents/node/agentIntent.ts
Comment thread extensions/copilot/package.nls.json Outdated
bhavyaus and others added 2 commits May 31, 2026 14:23
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>
@bhavyaus bhavyaus merged commit 991f245 into main May 31, 2026
25 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/summarize-threshold-ratio-or-tokens branch May 31, 2026 21:44
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants