fix: handle BudgetExceededError after background compaction re-render#312901
Merged
fix: handle BudgetExceededError after background compaction re-render#312901
Conversation
When the initial render throws BudgetExceededError and a completed background compaction is applied, the re-render was unprotected. If the compacted prompt still exceeds the budget (e.g. many MCP tools consuming token space, or cache breakpoints preventing pruning), the BudgetExceededError propagated uncaught and crashed the chat with 'No lowest priority node found'. Now the re-render is wrapped in a try-catch that falls back to renderWithoutSummarization (full budget, no cache breakpoints) on BudgetExceededError, with telemetry outcome 'appliedButReRenderFailed' to track how often this path is hit. Fixes #311407
b50510f to
fc58a66
Compare
Contributor
|
This PR will be automatically cherry-picked to |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the Copilot agent prompt build flow when an initial BudgetExceededError triggers background compaction: the subsequent “re-render with compacted history” is now guarded so a second budget exceed won’t propagate uncaught.
Changes:
- Wrap the post-background-compaction re-render in a
try/catchand add a fallback torenderWithoutSummarizationwhen the re-render still hitsBudgetExceededError. - Emit telemetry for the new fallback outcome (
appliedButReRenderFailed) and rename the shadowedrenderervariable toreRenderer.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/intents/node/agentIntent.ts | Adds a protected re-render path after applying background compaction, with telemetry for a new failure outcome and a fallback render path. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Yoyokrazy
approved these changes
Apr 27, 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.
Problem
When the initial prompt render throws
BudgetExceededErrorand a completed background compaction is applied, the re-render was unprotected. If the compacted prompt still exceeded the budget (e.g. many MCP tools/skills consuming token space, or Anthropic cache breakpoints preventing pruning), theBudgetExceededErrorpropagated uncaught and crashed the chat with:Fixes #311407