Option for 1-hour prompt cache TTL for Claude models (5-minute cache expires during normal interactive use)
Describe the feature or problem you'd like to solve
Claude prompt caching in Copilot CLI appears to use Anthropic's default 5-minute cache TTL. In normal interactive use (read the answer, think, write the next prompt) gaps of more than 5 minutes are common, so the full conversation gets re-written to cache on almost every turn instead of being read from cache.
I measured this with copilot -p / --resume in fresh sessions (~35k-token context), sending a follow-up after different idle gaps, and reading cache_read_tokens / cache_write_tokens from the local session usage data. Two independent runs gave identical results:
| Idle gap | Claude Opus/Sonnet/Haiku 5.5 | GPT-6.1-sol / GPT-6-sol / GPT-5.6-sol |
|---|---|---|
| 2 min | ~95% cache read | ~95% cache read |
| 11 min | 0% cache read (~100% cache write) | ~95% cache read |
| ~85 min | 0% | 0% |
My broader session history (Claude 5.x, CLI) shows the same pattern: 98% cache read for gaps < 4 min vs ~1% for gaps of 6–60 min.
Anthropic supports a 1-hour TTL (cache_control: {"type": "ephemeral", "ttl": "1h"}). VS Code Copilot Chat already has experimental settings for this (github.copilot.chat.anthropic.promptCaching.extendedTtl / extendedTtlMessages), though they currently miss Claude 5.x models (microsoft/vscode#340830, fix in microsoft/vscode#340831). Copilot CLI has no equivalent option.
Proposed solution
Add an option in Copilot CLI (config setting and/or env var) to use the 1-hour cache TTL for Claude models, covering the Claude 5.x family. Consider making it the default for interactive sessions, since the higher write cost (2x vs 1.25x) is usually recovered after one or two follow-up turns with a pause longer than 5 minutes.
Example prompts or workflows
Any interactive session with a large context where the user pauses longer than 5 minutes between prompts (reviewing diffs, testing changes, meetings).
Additional context
- Related: #3808 (prompt caching for Claude), #4724 (auto-compact on idle aligned to cache TTL)
- Triggered by this discussion: https://www.reddit.com/r/GithubCopilot/comments/1xauf3s/anthropic_caching_is_this_a_bad_joke/
- Tested with Copilot CLI 1.0.102-1 on Windows.
+10 for this feature
I find I'm hitting this timeout while waiting for code review agent to give feedback, so responding to code review issues happens 5-10 minutes after pushing commits to GitHub and almost always results in a cache miss. It would be especially nice to let the agents selectively enable this when they know there is going to be a wait. As is right now it seems to add about 10% to my overall AI credit usage.
This ticket alone would save companies million of dollars, its crazy how little attention this is getting, at least for Anthropic this is a good thing.
I've looked into this and it looks bad! I have also Claude Enterprise seat and cache TTL in Claude Code is set for 1h there, so Copilot team, please look into that!
| Provider | Models tested | CLI-reported TTL | Exceptions or caveats |
|---|---|---|---|
| Anthropic | 7 | 5 min | Every Claude model, including both Fable versions and Haiku 4.5, reported 300 seconds on the first request. |
| OpenAI | 10 | 30 min | All reported 1800 seconds. GPT‑5.3‑Codex and GPT‑5.6 Sol only reported it on the second request. |
| Microsoft | 2 | 30 min | MAI Code 2 reported 1800 seconds on the second request; MAI Code 2 Flash on the third. |
| 4 | Not reported | Gemini 4 Argon, Carbon, Hydrogen, and Neon each reused 19,861–20,619 cached tokens on the follow-up, but none returned a TTL or expiry. Their actual lifetimes could differ. |
Script to verify:
$model = 'claude-opus-5.5' # or: mai-code-2, gpt-6.2-sol, gemini-4-neon
$session = [guid]::NewGuid().ToString()
$seed = 'Reply only OK. Synthetic cache probe: ' + ('apricot green square cobalt; ' * 1000)
foreach ($message in @($seed, 'Reply only OK again.')) {
$jsonl = copilot --model $model --session-id $session --output-format json `
--no-custom-instructions --available-tools -p $message
if ($LASTEXITCODE -ne 0) { throw "Copilot CLI exited with code $LASTEXITCODE" }
$checkpoint = $jsonl | ForEach-Object { $_ | ConvertFrom-Json } |
Where-Object type -eq 'session.usage_checkpoint' | Select-Object -Last 1
if (-not $checkpoint) { throw 'No usage checkpoint in the CLI output.' }
$state = $checkpoint.data.modelCacheState | Where-Object modelId -eq $model
if ($null -ne $state.cacheTtlSeconds) {
$state | Select-Object modelId, cacheTtlSeconds, cacheExpiresAt
break
}
"No TTL reported for $model on this turn."
}