Repository navigation
Description
Does this issue occur when all extensions are disabled?: Yes
-
VS Code Version: 1.110.0-insider (user setup)
-
Extension: github.copilot-chat
-
Extension Version: 0.38.2026022801
-
OS Version: Windows 11 x64 (10.0.26200)
Description
When using GitHub Copilot Chat with a locally hosted llama.cpp server (llama-b8183-bin-win-cuda-13.1-x64, Qwen3-Coder-Next-GGUF), I am observing frequent KV cache invalidation and forced full prompt re-processing on the server side.
This happens especially during larger reading / review workflows (multi-step reasoning, MCP-style interactions, larger file context). It appears that the extension repeatedly resends large rolling context, which leads to server-side checkpoint invalidation.
Server logs frequently show:
forcing full prompt re-processing due to lack of cache data- Erasing all context checkpoints
- Full prompt re-evaluation (~40k–50k tokens)
- Significant performance degradation
This makes iterative review workflows noticeably slower.
Server Setup
Running:
lama-b8183-bin-win-cuda-13.1-x64
Startup script:
@echo off
"D:\llama_ai\llama-b8183-bin-win-cuda-13.1-x64\llama-server.exe" ^
-m "C:\Users\chris\AppData\Local\llama.cpp\unsloth_Qwen3-Coder-Next-GGUF_UD-Q6_K_XL_Qwen3-Coder-Next-UD-Q6_K_XL-00001-of-00003.gguf" ^
--alias "Qwen3-Coder-Next-GGUF:UD-Q6_K_XL" ^
--gpu-layers all ^
-ot "\.(1[9-9]|[2-9][0-9]|[0-9][0-9][0-9])\.ffn_(gate|up|down)_exps.=CPU" ^
--flash-attn on ^
--cache-type-k q8_0 ^
--cache-type-v q8_0 ^
--cache-ram 28384 ^
--cache-reuse 956 ^
--ctx-size 81536 ^
--batch-size 1024 ^
--ubatch-size 512 ^
--threads 8 ^
--kv-offload ^
--op-offload ^
--fit off ^
--parallel 1 ^
--host 0.0.0.0 ^
--port 11434 ^
--seed 3407 ^
--temp 1.0 ^
--top-p 0.9 ^
--min-p 0.01 ^
--top-k 40 ^
--jinja
pauseSteps to Reproduce
- Connect Copilot Chat to the local llama.cpp server (compatible openai)
- Open a larger file or perform multi-step reasoning / review.
- Let Copilot perform read → analyze → follow-up steps.
- Observe repeated full prompt re-processing in server logs.
Expected Behavior
- Incremental requests should reuse prior context efficiently.
- No repeated full re-evaluation of ~40k–50k tokens for small incremental steps.
- Stable server-side checkpoint reuse.
Actual Behavior
- Frequent cache invalidation.
- All checkpoints erased.
- Full prompt re-processing.
- Large latency spikes during review workflows.
Logs
The issue appears more related to conversation/session handling than to raw model performance (although I hear swa issues recently)
Example logs
slot update_slots: id 0 | task 3487 | prompt done, n_tokens = 50966, batch.n_tokens = 54
slot init_sampler: id 0 | task 3487 | init sampler, took 4.03 ms, tokens: text = 50966, total = 50966
slot update_slots: id 0 | task 3487 | erasing old context checkpoint (pos_min = 47392, pos_max = 47392, size = 75.376 MiB)
slot update_slots: id 0 | task 3487 | created context checkpoint 8 of 8 (pos_min = 50911, pos_max = 50911, size = 75.376 MiB)
slot print_timing: id 0 | task 3487 |
prompt eval time = 599.17 ms / 54 tokens ( 11.10 ms per token, 90.12 tokens per second)
eval time = 12570.80 ms / 371 tokens ( 33.88 ms per token, 29.51 tokens per second)
total time = 13169.98 ms / 425 tokens
slot release: id 0 | task 3487 | stop processing: n_tokens = 51336, truncated = 0
srv update_slots: all slots are idle
srv log_server_r: done request: POST /v1/chat/completions 192.168.1.247 200
srv params_from_: Chat format: Qwen3 Coder
slot get_availabl: id 0 | task -1 | selected slot by LCP similarity, sim_best = 0.485 (> 0.100 thold), f_keep = 0.500
srv get_availabl: updating prompt cache
srv prompt_save: - saving prompt with length 51336, total state size = 715.157 MiB
srv load: - looking for better prompt, base f_keep = 0.500, sim = 0.485
srv update: - cache state: 1 prompts, 1318.164 MiB (limits: 28384.000 MiB, 95744 tokens, 1105417 est)
srv update: - prompt 000002315DFAB240: 51336 tokens, checkpoints: 8, 1318.164 MiB
srv get_availabl: prompt cache update took 141.75 ms
slot launch_slot_: id 0 | task -1 | sampler chain: logits -> ?penalties -> ?dry -> ?top-n-sigma -> top-k -> ?typical -> ?top-p -> min-p -> ?xtc -> temp-ext -> dist
slot launch_slot_: id 0 | task 3859 | processing task, is_child = 0
slot update_slots: id 0 | task 3859 | new prompt, n_ctx_slot = 95744, n_keep = 0, task.n_tokens = 52970
slot update_slots: id 0 | task 3859 | n_past = 25665, slot.prompt.tokens.size() = 51336, seq_id = 0, pos_min = 51335, n_swa = 1
slot update_slots: id 0 | task 3859 | forcing full prompt re-processing due to lack of cache data (likely due to SWA or hybrid/recurrent memory, see https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 47955, pos_max = 47955, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 48633, pos_max = 48633, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 48938, pos_max = 48938, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 49247, pos_max = 49247, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 49820, pos_max = 49820, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 50122, pos_max = 50122, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 50505, pos_max = 50505, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | erased invalidated context checkpoint (pos_min = 50911, pos_max = 50911, n_swa = 1, size = 75.376 MiB)
slot update_slots: id 0 | task 3859 | n_tokens = 0, memory_seq_rm [0, end)
slot update_slots: id 0 | task 3859 | prompt processing progress, n_tokens = 1024, batch.n_tokens = 1024, progress = 0.019332
slot update_slots: id 0 | task 3859 | n_tokens = 1024, memory_seq_rm [1024, end)
Activity
[-]Frequent KV cache invalidation and forced full prompt re-processing (seems a prompt issue)[/-][+]Frequent KV cache invalidation and forced full prompt re-processing (github.copilot-chat, insider))[/+]chrisoutwright commentedon Mar 1, 2026
Don't tell me this is about tool ordering in the request (or dynamic mcp tool definitions?, i use standard only) or injected small variables per specific turns, that would break most prefix based caching, i don't want to write a proxy for that to check ...
roblourens commentedon Mar 1, 2026
Can you check the requests to see why the cache is being invalidated? We pay attention to this metric and I'm pretty sure we don't randomly invalidate it in typical cases for other models.
https://github.com/microsoft/vscode/wiki/Copilot-Issues#language-model-requests-and-responses
chrisoutwright commentedon Mar 2, 2026
I can do that, will try it during the weekdays, .. will I need to use "--swa-full true" better? I could do a faster non-replication as test probably .. I am confused if the model is the issue with automatically deciding to influence the attention of if this is prompt issue .. for a prompt issue, I would rather want to write a script as proxy that will do the diffing for me. Any available tool that can save the effort I can run?
chrisoutwright commentedon Mar 8, 2026
Proxy Evidence: Tool definition changes between requests cause prefix cache invalidation
I wrote an intercepting proxy that sits between Copilot and the llama.cpp backend, logging every request and structurally diffing tool definitions, system prompts, and message content across successive requests. Here are the findings:
1. Tool definitions change between consecutive requests
Across 22 requests in a single session:
f6f35a44(stable)016a6ab1(changed)a23401dc(changed again)Between req-009 and req-010, the tool
vscode_listCodeUsageswas removed, and 39 out of 64 tools shifted position in the array (everything after index 25 slid up by one). Between req-010 and req-011, it was added back — again shifting 39 positions.Additionally, tool parameter schemas changed between these requests —
requiredarrays were reordered, properties likenewName,packageList,pythonEnvironmentwere added/removed, andrenderMermaidDiagramwas removed and re-added.These are not just ordering changes — the actual JSON content of tool schemas changes, meaning every token after the first divergence in the serialized prompt is different, invalidating prefix-based KV cache.
2. System prompt swaps entirely on context compaction
Request req-001 used a "conversation summarizer" system prompt (for context compaction). Request req-002 switched to the standard coding assistant prompt. This is a complete system prompt replacement — every token changes. Since the system prompt sits at the very beginning of the token sequence, this invalidates the entire KV cache prefix.
3. Summary
vscode_listCodeUsages)requiredarrays, properties)Reproduction
I used a transparent async Python proxy that:
The tool definition shuffling alone is enough to explain the forced full prompt re-processing I reported. For servers that use prefix-based KV caching (llama.cpp, vLLM, etc.), any change in the token sequence before the divergence point invalidates the entire cache from that point forward.
Suggested fix
Stabilize the tool list sent to the model:
requiredarrays in a stable orderproxy_diffs.log
chrisoutwright commentedon Mar 8, 2026
so the problem is: vscode_listCodeUsages
captured version from this session's log said "Currently supported for: python, rust" but the live version now lists many more languages -> which means the extension updates this tool's description dynamically based on installed language extensions, and that alone could cause token-level changes between requests.
Can this be done differently? it causes the issue as explained in this ticket.
chrisoutwright commentedon Mar 15, 2026
I think I found the issue (took me to write a whole UI on that .. .):
the copilot is hiding lines and some point (injection/reduce in former messages), very hard to pick up
can this be prevented with some parameter?
Foxtr0t1337 commentedon Mar 15, 2026
VS Code Version: 1.111.0 (Universal)
Plugin version 0.39.1
I've met the same problem - almost every long tool result invalidates the whole cache for LM Studio (unsloth/Qwen3.5-35B-A3B-GGUF) via johnny-zhao.oai-compatible-copilot, making it increasingly difficult to work with.
ODtian commentedon Mar 18, 2026
I'm using a plugin to integrate my own API endpoint and have encountered a similar situation: when making requests using Copilot, the cache only hits occasionally, while using VS Code Codex results in a 100% cache hit rate. This would explain the issue if it were a tool-related problem, since both the local key-value cache and the remote API cache are prefix-based.
roblourens commentedon May 3, 2026
Sorry for the slow response, thanks for the investigation. I believe we actually just fixed this here: #312568