Fixes#22772: When a folder has a custom system prompt, creating a "Temporary Chat" in that folder now correctly applies the folder's prompt.
The root cause was that temporary chats are not persisted to the database, so the backend's folder lookup by chat_id returned nothing. The fix captures the folder_id on the frontend when a temporary chat starts and passes it in the request payload. The backend falls back to this client-supplied folder_id when the DB lookup finds no result.
This also ensures folder knowledge files are attached to temporary chats, not just the system prompt.
Changes
src/lib/components/chat/Chat.svelte: Store temporaryChatFolderId when initializing a temporary chat inside a folder; send it as folder_id in the chat completion request.
backend/open_webui/main.py: Extract folder_id from the request payload into metadata.
backend/open_webui/utils/middleware.py: Fall back to metadata["folder_id"] when Chats.get_chat_folder_id() returns nothing (as happens with temporary chats).
Test plan
Create a folder with a custom system prompt (e.g., "Always respond in pirate speak")
Create a regular chat in that folder — verify the prompt is applied
Create a temporary chat in that folder — verify the prompt is now also applied
Create a temporary chat outside any folder — verify no regression (no folder prompt injected)
Create a folder with knowledge files — verify temporary chats in that folder receive the files
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/22858
**Author:** [@gambletan](https://github.com/gambletan)
**Created:** 3/19/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `fix/temporary-chat-folder-prompt`
---
### 📝 Commits (1)
- [`dd592bb`](https://github.com/open-webui/open-webui/commit/dd592bb5d57f36b58639b7bf9e2c6826a6ae1666) fix: pass folder prompt to temporary chats
### 📊 Changes
**3 files changed** (+29 additions, -18 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/main.py` (+1 -0)
📝 `backend/open_webui/utils/middleware.py` (+22 -18)
📝 `src/lib/components/chat/Chat.svelte` (+6 -0)
</details>
### 📄 Description
## Summary
- Fixes #22772: When a folder has a custom system prompt, creating a "Temporary Chat" in that folder now correctly applies the folder's prompt.
- The root cause was that temporary chats are not persisted to the database, so the backend's folder lookup by `chat_id` returned nothing. The fix captures the `folder_id` on the frontend when a temporary chat starts and passes it in the request payload. The backend falls back to this client-supplied `folder_id` when the DB lookup finds no result.
- This also ensures folder knowledge files are attached to temporary chats, not just the system prompt.
## Changes
- **`src/lib/components/chat/Chat.svelte`**: Store `temporaryChatFolderId` when initializing a temporary chat inside a folder; send it as `folder_id` in the chat completion request.
- **`backend/open_webui/main.py`**: Extract `folder_id` from the request payload into metadata.
- **`backend/open_webui/utils/middleware.py`**: Fall back to `metadata["folder_id"]` when `Chats.get_chat_folder_id()` returns nothing (as happens with temporary chats).
## Test plan
- [ ] Create a folder with a custom system prompt (e.g., "Always respond in pirate speak")
- [ ] Create a regular chat in that folder — verify the prompt is applied
- [ ] Create a temporary chat in that folder — verify the prompt is now also applied
- [ ] Create a temporary chat outside any folder — verify no regression (no folder prompt injected)
- [ ] Create a folder with knowledge files — verify temporary chats in that folder receive the files
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22858
Author: @gambletan
Created: 3/19/2026
Status: ❌ Closed
Base:
main← Head:fix/temporary-chat-folder-prompt📝 Commits (1)
dd592bbfix: pass folder prompt to temporary chats📊 Changes
3 files changed (+29 additions, -18 deletions)
View changed files
📝
backend/open_webui/main.py(+1 -0)📝
backend/open_webui/utils/middleware.py(+22 -18)📝
src/lib/components/chat/Chat.svelte(+6 -0)📄 Description
Summary
chat_idreturned nothing. The fix captures thefolder_idon the frontend when a temporary chat starts and passes it in the request payload. The backend falls back to this client-suppliedfolder_idwhen the DB lookup finds no result.Changes
src/lib/components/chat/Chat.svelte: StoretemporaryChatFolderIdwhen initializing a temporary chat inside a folder; send it asfolder_idin the chat completion request.backend/open_webui/main.py: Extractfolder_idfrom the request payload into metadata.backend/open_webui/utils/middleware.py: Fall back tometadata["folder_id"]whenChats.get_chat_folder_id()returns nothing (as happens with temporary chats).Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.