Repository navigation
Agent Host: add a setting for the runtime's adaptive prompt cache - #350904
Open
Bhavya U (bhavyaus) wants to merge 1 commit into
Open
Bhavya U (bhavyaus) wants to merge 1 commit into
Bhavya U (bhavyaus) wants to merge 1 commit into
Conversation
Copilot SDK sessions write their whole conversation into the Claude prompt cache again whenever more than five minutes pass between requests, for example while a long shell command runs in the foreground or while the user is away. The runtime has an adaptive prompt cache that picks a 5-minute or 1-hour cache lifetime per request and keeps the cache warm with small requests while idle, but VS Code sessions never get it: the runtime skips its own experiment assignment whenever the host supplies one, and VS Code always does. Add `chat.copilot.adaptivePromptCache.enabled` (off by default). When it is on, the experiment assignment VS Code supplies for a created or resumed session selects the runtime's `ttl_select_refresh_keepalive` arm. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The adaptive prompt cache opt-in is not forwarded to explicitly connected remote Agent Hosts, leaving new and resumed remote sessions on the default cache behavior.
2 open issues
What changed in this PR
Adds an opt-in setting for the Copilot runtime’s adaptive prompt cache in Agent Host sessions, intended to reduce cache rewrites after idle periods or long tool calls with Claude models.
Changes:
- Registers an application-scoped, experimental setting that defaults to off.
- Forwards the setting to the ambient Agent Host and supplies the runtime cache assignment when creating or resuming sessions.
- Extends tests for settings forwarding and session assignments, including cases without a VS Code assignment context.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostCopilotCliSettingsContribution.test.ts |
Updates schema fixtures and expected forwarded values. |
src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts |
Registers the user-facing adaptive-cache setting. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCopilotCliSettingsContribution.ts |
Forwards the setting to Agent Host root configuration. |
src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts |
Tests cache assignments on session creation and resume. |
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts |
Adds the adaptive-cache arm to runtime experiment assignments. |
src/vs/platform/agentHost/common/copilotCliConfig.ts |
Defines the setting ID, root configuration key, and schema. |
Review effort: Balanced
| description: nls.localize('chat.copilot.adaptivePromptCache.enabled', "When enabled, Copilot SDK sessions using Claude models choose a 5-minute or 1-hour prompt cache lifetime for each request, and keep the cache warm with small background requests while the session is idle or a tool is running. This avoids rewriting the whole conversation into the cache after a pause, at the cost of those background requests. Applies to new and resumed sessions."), | ||
| default: false, | ||
| tags: ['experimental', 'advanced'], | ||
| scope: ConfigurationScope.APPLICATION, |
| tags: ['experimental', 'advanced'], | ||
| scope: ConfigurationScope.APPLICATION, | ||
| }, | ||
| [CopilotAdaptivePromptCacheEnabledSettingId]: { |
Alexandru Dima (alexdima)
approved these changes
Nov 28, 2026
This branch has not been deployed
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.


Adds an opt-in setting,
chat.copilot.adaptivePromptCache.enabled(experimental, default off), that turns on the Copilot runtime's adaptive prompt cache for Agent Host Copilot sessions.When a session using a Claude model sits idle, or waits on a long foreground tool call, for more than 5 minutes, the prompt cache expires and the next request writes the whole conversation into the cache again. The runtime already has an adaptive prompt cache that prevents this. It keeps the cache warm with small background requests, and picks a 1-hour cache lifetime when that is cheaper. It is gated by a runtime experiment that VS Code sessions never receive, because VS Code always supplies its own experiment assignments and the runtime then skips its own experiment lookup.
What changed
copilotCliConfig.ts: new root config keyadaptivePromptCacheand setting ID.chat.shared.contribution.ts: registers the setting. It is boolean, application-scoped, off by default, and taggedexperimentalandadvanced, like the neighbouring Copilot runtime settings.agentHostCopilotCliSettingsContribution.ts: forwards the setting to the agent host.copilotSessionLauncher.ts: when the setting is on,toSdkExpAssignmentsadds the runtime's adaptive prompt cache arm (ttl_select_refresh_keepalive) to thedefaultconfig of the session's experiment assignments. This works with or without a VS Code assignment context. When the setting is off, behaviour is unchanged.The setting applies when a session is created or resumed, the same as
chat.copilot.stabilityOrderedPrompt.enabled. An open session picks it up the next time it is reloaded.How to test
"chat.copilot.adaptivePromptCache.enabled": trueand use a Claude model in an Agent Host Copilot session.sleep 330in the foreground.~/.copilot/logs/process-*.logwithchat.agentHost.copilotSdk.logLevelset totrace), ananthropic_prompt_cache_keepaliveevent withkeepalive_kind: pingappears about 4.5 minutes after the last request. The request after the sleep then reads the conversation from the cache instead of writing it again.My manual run in Code OSS used the same session with a context of about 190k tokens and a 330-second foreground
sleep:The runtime only sends keep-alives once a session is past its warm-up threshold, so a short, fresh session shows no pings.
Validation
pnpm run typecheck-client: passed.pnpm run oxlinton the changed files: passed../scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotSessionLauncher.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostCopilotCliSettingsContribution.test.ts: passed (289 tests). The new launcher test checks that the arm is assigned on create and resume, with and without an assignment context.