Fix enableThinking mismatch causing inline summarization cache misses#311851
Merged
Fix enableThinking mismatch causing inline summarization cache misses#311851
Conversation
The inline summarization path computed enableThinking differently from the main agent loop in toolCallingLoop.ts. For Anthropic on non-continuation turns without thinking blocks yet, the old logic set enableThinking=false while the main agent kept it true. This thinking parameter mismatch invalidated the Anthropic message cache, causing 0% cache hit rate on inline summarization requests. Align with the main loop: only disable thinking on continuation turns for Anthropic when no thinking blocks exist in messages.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a prompt-cache miss issue in the inline/background summarization path by aligning Anthropic enableThinking computation with the main agent tool-calling loop, preventing “thinking parameter” changes that invalidate Anthropic’s message cache.
Changes:
- Introduce
shouldDisableThinkingin the inline summarization capability-caching path. - Set
enableThinkingto!shouldDisableThinking, matchingToolCallingLoop.runOne()behavior (disable only on Anthropic continuation turns when no thinking blocks exist yet).
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/intents/node/agentIntent.ts | Mirrors ToolCallingLoop.runOne() thinking enablement logic when caching model capabilities for inline/background summarization to preserve Anthropic prompt-cache parity. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Contributor
Screenshot ChangesBase: Changed (4) |
alexdima
approved these changes
Apr 22, 2026
Collaborator
|
@bhavyaus thank you very much for fixing this one 🙏 Super impactful! |
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.
The inline summarization path computed
enableThinkingdifferently from the main agent loop (toolCallingLoop.ts). For Anthropic on non-continuation turns, the old logic (!isAnthropicFamily || messagesContainThinking) would setenableThinking=falsewhen no thinking blocks existed yet, while the main agent always kept ittrue. Per Anthropic docs, changing thinking parameters invalidates the message cache — causing 0% cache hits on summarization requests.Fix: mirror the main loop's
shouldDisableThinking = isContinuation && isAnthropicFamily && !messagesContainThinkinglogic exactly.cc: @kevin-m-kent who tracked down this issue! 🙏