mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[GH-ISSUE #24401] issue: KV cache invalidation with dynamic variables in system prompt #74891
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FrederikDeVree on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24401
Check Existing Issues
Installation Method
Git Clone
Open WebUI Version
v0.9.2
Ollama Version (if applicable)
No response
Operating System
Ubuntu 24.04
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
When including {{CURRENT_DATETIME}} in the system prompt, this is determined at the start of the conversation. When I continue the continue conversation the dynamic variables aren't recalculated, because this causes KV Cache invalidation (I'm using vLLM with --enable-prefix-caching), thus making every subsequent message in a conversation with a long context as slow as the first (in a case you've fed the model a long document).
Actual Behavior
The dynamic variables are recalculated for every turn in the conversation.
Steps to Reproduce
Logs & Screenshots
Additional Information
payload.py
I've had Claude add a cache, this resolves the issue. I'm not making a PR because I'm not sure if this behaviour is what's wanted.
@owui-terminator[bot] commented on GitHub (May 6, 2026):
🔍 Similar Issues Found
I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:
#23999 issue: Clicking on text in sys prompt scrolls to top of screen
by frenzybiscuit ·
bug#24193 issue: System Prompt missing after reload
by Scarjit ·
bug#23480 issue: "Save" button unresponsive when saving prompt with dynamic variables
by daniporr ·
bug#23269 issue: Pyodide prompt injection constantly poisons the token cache (native tool calling)
by arbv ·
bug#15589 feat: user prompt variables
by tjbck
💡 If this is a duplicate, consider closing it and adding details to the existing issue.
This comment was generated automatically. React with 👍 if helpful, 👎 if not.
@Classic298 commented on GitHub (May 6, 2026):
its intended that the values are recalculated on every request. changing that would break many users and deployments that require these variables to be resolved on a per-request basis everytime. Also it would require refactoring parts of the chat management to store any of the built in variables permanently on a per chat basis.
So this is not a bug but intended behaviour. You can use a filter to handle this wanted logic.
NAB - needs discussion if a feature for this is actually warranted, but probably not. Should rather be handled through a filter that dynamically detects the creation date of a chat from the database and then injects that date into the system prompt for example and since it's always the creation date it stays static