Skip to content

Optimize prompt cache hit rate by freezing deferred tool list in initial context#312577

Merged
bhavyaus merged 2 commits intomainfrom
dev/bhavyau/inline-history-gpt55-tool-search
Apr 26, 2026
Merged

Optimize prompt cache hit rate by freezing deferred tool list in initial context#312577
bhavyaus merged 2 commits intomainfrom
dev/bhavyau/inline-history-gpt55-tool-search

Conversation

@bhavyaus
Copy link
Copy Markdown
Collaborator

@bhavyaus bhavyaus commented Apr 26, 2026

Optimizes Anthropic prompt cache hit rate by moving the dynamic deferred-tool list out of the cached system prompt and into the global agent context (first user message), which is frozen across turns via GlobalContextMessageMetadata. The instructional/guidance prose stays in the system prompt; only the dynamic tool inventory moves.

Also wires up tool-search support for HiddenModelB.

cc: @kevin-m-kent

Copilot AI review requested due to automatic review settings April 26, 2026 05:33
@bhavyaus bhavyaus force-pushed the dev/bhavyau/inline-history-gpt55-tool-search branch from 93cebad to b0861b3 Compare April 26, 2026 05:33
@bhavyaus bhavyaus enabled auto-merge (squash) April 26, 2026 05:34
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

This PR improves Anthropic prompt-cache hit rates by relocating the dynamic deferred-tool inventory from the system prompt into the cached “global agent context” (initial user message), while keeping tool-search guidance in the system prompt. It also enables tool-search prompt support for HiddenModelB.

Changes:

  • Split tool-search prompt responsibilities: keep guidance in ToolSearchToolPromptOptimized, and emit the deferred-tool inventory once via DeferredToolListReminder.
  • Render the deferred-tool inventory inside GlobalAgentContext so it’s frozen via GlobalContextMessageMetadata across turns.
  • Update Anthropic and HiddenModelB prompts + snapshots to reflect the new placement of <availableDeferredTools>.
Show a summary per file
File Description
extensions/copilot/src/extension/prompts/node/agent/toolSearchInstructions.tsx Adds DeferredToolListReminder and removes the inline deferred-tool list from the optimized tool-search system prompt.
extensions/copilot/src/extension/prompts/node/agent/agentPrompt.tsx Emits <availableDeferredTools> from GlobalAgentContext to keep it in the cached initial context.
extensions/copilot/src/extension/prompts/node/agent/anthropicPrompts.tsx Updates legacy Anthropic tool-search prompt to no longer inline the deferred-tool list and to reference initial context.
extensions/copilot/src/extension/prompts/node/agent/openai/hiddenModelBPrompt.tsx Adds tool-search guidance to HiddenModelB system prompt + a per-turn reminder gated on supportsToolSearch.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.6/all_tools.spec.snap Snapshot updates: <availableDeferredTools> moved from tool-search instructions to global context.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.6/all_non_edit_tools.spec.snap Snapshot updates for the same relocation.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.5/all_tools.spec.snap Snapshot updates for the same relocation + prose tweaks.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-sonnet-4.5/all_non_edit_tools.spec.snap Snapshot updates for the same relocation + prose tweaks.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.6/all_tools.spec.snap Snapshot updates: <availableDeferredTools> moved to global context.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.6/all_non_edit_tools.spec.snap Snapshot updates for the same relocation.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.5/all_tools.spec.snap Snapshot updates for the same relocation + prose tweaks.
extensions/copilot/src/extension/prompts/node/agent/test/snapshots/agentPrompts-claude-opus-4.5/all_non_edit_tools.spec.snap Snapshot updates for the same relocation + prose tweaks.

Copilot's findings

  • Files reviewed: 12/12 changed files
  • Comments generated: 1

@bhavyaus bhavyaus merged commit 602d64e into main Apr 26, 2026
26 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/inline-history-gpt55-tool-search branch April 26, 2026 08:39
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 26, 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