[GH-ISSUE #24401] issue: KV cache invalidation with dynamic variables in system prompt #107282

Closed
opened 2026-05-18 06:01:15 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @FrederikDeVree on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24401

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

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

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

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.

Originally created by @FrederikDeVree on GitHub (May 6, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24401 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### 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 - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### 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](https://github.com/user-attachments/files/27436311/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.
GiteaMirror added the bug label 2026-05-18 06:01:15 -05:00
Author
Owner

@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:

  1. #23999 issue: Clicking on text in sys prompt scrolls to top of screen
    by frenzybiscuit · bug

  2. #24193 issue: System Prompt missing after reload
    by Scarjit · bug

  3. #23480 issue: "Save" button unresponsive when saving prompt with dynamic variables
    by daniporr · bug

  4. #23269 issue: Pyodide prompt injection constantly poisons the token cache (native tool calling)
    by arbv · bug

  5. #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.

<!-- gh-comment-id:4387309404 --> @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: 1. [#23999](https://github.com/open-webui/open-webui/issues/23999) **issue: Clicking on text in sys prompt scrolls to top of screen** *by frenzybiscuit · `bug`* 2. [#24193](https://github.com/open-webui/open-webui/issues/24193) **issue: System Prompt missing after reload** *by Scarjit · `bug`* 3. [#23480](https://github.com/open-webui/open-webui/issues/23480) **issue: "Save" button unresponsive when saving prompt with dynamic variables** *by daniporr · `bug`* 4. [#23269](https://github.com/open-webui/open-webui/issues/23269) **issue: Pyodide prompt injection constantly poisons the token cache (native tool calling)** *by arbv · `bug`* 5. [#15589](https://github.com/open-webui/open-webui/issues/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.
Author
Owner

@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

<!-- gh-comment-id:4387329349 --> @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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#107282