Fixes #4860: Cap problems output to prevent context overflow #4861
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.
Summary
This PR fixes issue #4860 by implementing a reasonable cap on the number of problems sent to the session context when users mention
@problems.Problem
When VSCode has a large number of problems (e.g., 60,000+ from a failed Scope: all 15 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
╭───────────────────────────────────────────────╮
│ │
│ Update available! 10.8.1 → 10.12.1. │
│ Changelog: https://pnpm.io/v/10.12.1 │
│ To update, run: corepack use [email protected] │
│ │
╰───────────────────────────────────────────────╯
╭ Warning ─────────────────────────────────────────────────────────────────────╮
│ │
│ Ignored build scripts: @tailwindcss/oxide, @vscode/vsce-sign, │
│ better-sqlite3, core-js, esbuild, keytar, puppeteer-chromium-resolver, │
│ sharp. │
│ Run "pnpm approve-builds" to pick which dependencies should be allowed │
│ to run scripts. │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
. preinstall$ node scripts/bootstrap.mjs
. preinstall: Done
. install$ node scripts/bootstrap.mjs
. install: Done
. prepare$ husky
. prepare: Done
Done in 1.1s using pnpm v10.8.1 in a large monorepo), the extension would feed all problems into the session context without any limits. This could cause the session context to grow excessively (800k+ tokens), making sessions unresponsive, slow, and expensive.
Solution
@problemsmentionsKey Features
Example Output
When there are more than 100 problems, users will see:
Testing
This change ensures that
@problemsmentions remain useful while preventing context overflow that could make sessions unusable.Important
Cap problems output to 100 in session context to prevent overflow, with updates to
diagnosticsToProblemsString()and comprehensive tests added.getWorkspaceProblems()inindex.tsto prevent overflow.diagnosticsToProblemsString()inindex.tsupdated to handle optionalmaxProblemsparameter for truncation.DiffViewProviderinDiffViewProvider.tscontinues to show all problems for edit-specific diagnostics.diagnostics.spec.tsto cover new limiting functionality, including edge cases.MAX_PROBLEMS_IN_CONTEXTconstant inindex.tsfor problem limit.This description was created by
for 82a4fa9. You can customize this summary. It will automatically update as commits are pushed.