Skip to content

fix: handle BudgetExceededError after background compaction re-render#312901

Merged
bhavyaus merged 2 commits intomainfrom
dev/bhavyau/fix-budget-exceeded-after-compaction
Apr 27, 2026
Merged

fix: handle BudgetExceededError after background compaction re-render#312901
bhavyaus merged 2 commits intomainfrom
dev/bhavyau/fix-budget-exceeded-after-compaction

Conversation

@bhavyaus
Copy link
Copy Markdown
Collaborator

@bhavyaus bhavyaus commented Apr 27, 2026

Problem

When the initial prompt render throws BudgetExceededError and 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), the BudgetExceededError propagated uncaught and crashed the chat with:

Fixes #311407

Copilot AI review requested due to automatic review settings April 27, 2026 20:51
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
@bhavyaus bhavyaus force-pushed the dev/bhavyau/fix-budget-exceeded-after-compaction branch from b50510f to fc58a66 Compare April 27, 2026 20:52
@bhavyaus bhavyaus added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Apr 27, 2026
@bhavyaus bhavyaus added this to the 1.118.0 milestone Apr 27, 2026
@vs-code-engineering
Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.118 when merged.

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

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/catch and add a fallback to renderWithoutSummarization when the re-render still hits BudgetExceededError.
  • Emit telemetry for the new fallback outcome (appliedButReRenderFailed) and rename the shadowed renderer variable to reRenderer.
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

Comment thread extensions/copilot/src/extension/intents/node/agentIntent.ts
Comment thread extensions/copilot/src/extension/intents/node/agentIntent.ts
@bhavyaus bhavyaus merged commit d025ee4 into main Apr 27, 2026
26 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/fix-budget-exceeded-after-compaction branch April 27, 2026 21:31
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot Chat crashes with "No lowest priority node found" during prompt rendering (Claude models only, after inline history summarization)

3 participants