ds4 icon indicating copy to clipboard operation
ds4 copied to clipboard

KV cache misses with `reason=token-mismatch` on every request with tools enabled in Open WebUI

Open links486 opened this issue 6 months ago • 2 comments

In Open WebUI with the model configured to use "native" function calling, every single request seems to miss the cache.

Here's a complete log captured with the --trace flag:

https://gist.github.com/links486/47e35c15e70c978d52f968b020b8c66b

You can see memory_miss_reason: token-mismatch on each request, and the cached_tokens: 578 count never increases as the conversation progresses.

If I switch the Function Calling parameter to "Default" instead of "Native" in Open WebUI to disable the model's native tool-calling, the cache works correctly, but then tools are disabled of course.

If any additional tests or traces would be helpful I can run more. Thanks again for this great project.

links486 avatar May 19 '26 08:05 links486

This looks like a bug in Open WebUI: https://github.com/open-webui/open-webui/issues/23339

Here's a simple fix that doesn't require a custom filter or any of the other complex workarounds suggested in that issue:

  1. Go to your Open WebUI admin settings.
  2. Click on "Connections".
  3. Click on the gear icon next to the OpenAI API connection that you have configured for DS4.
  4. Look for "Provider" and switch it from "Default" to "llama.cpp".

After changing this setting, subsequent requests within the same chat are cached correctly.

Closing this issue because it isn't a DS4 bug.

links486 avatar May 19 '26 08:05 links486

this is not limited to OWUI. When litellm router routes a request the same happens ds4-server: thinking not closed, ignoring DSML in reasoning 0606 13:14:36 ds4-server: chat ctx=0..5:5 gen=1 THINKING finish=length 0.164s 0606 13:14:37 ds4-server: live kv cache miss live=6 prompt=5 common=5 reason=token-mismatch 0606 13:14:37 ds4-server: chat ctx=0..5:5 prompt start 0606 13:14:37 ds4-server: chat ctx=0..5:5 prompt done 0.122s 0606 13:14:37 ds4-server: chat ctx=5..6:1 gen=1 THINKING decoding chunk=25.86 t/s avg=25.86 t/s 0.039s ds4-server: thinking not closed, ignoring DSML in reasoning 0606 13:14:37 ds4-server: chat ctx=0..5:5 gen=1 THINKING finish=length 0.161s 0606 13:14:37 ds4-server: live kv cache miss live=6 prompt=5 common=5 reason=token-mismatch 0606 13:14:37 ds4-server: chat ctx=0..5:5 prompt start 0606 13:14:37 ds4-server: chat ctx=0..5:5 prompt done 0.123s 0606 13:14:37 ds4-server: chat ctx=5..6:1 gen=1 THINKING decoding chunk=29.07 t/s avg=29.07 t/s 0.034s ds4-server: thinking not closed, ignoring DSML in reasoning 0606 13:14:37 ds4-server: chat ctx=0..5:5 gen=1 THINKING finish=length 0.157s

javi2375 avatar Jun 06 '26 17:06 javi2375