[PR #22674] [CLOSED] fix: bypass RAG retrieval when all files are in full context mode #26808

Closed
opened 2026-04-20 06:43:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22674
Author: @a86582751
Created: 3/14/2026
Status: Closed

Base: devHead: fix-full-context-bypass-rag


📝 Commits (10+)

📊 Changes

1 file changed (+51 additions, -30 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+51 -30)

📄 Description

Pull Request Checklist

Before submitting, ensure you have:

  • Read the Contributing Guidelines
  • Read the CLA
  • Tested the changes locally
  • Followed the PR template

Description

Fixes the issue where 'Full Context' mode and 'Bypass Embedding and Retrieval' setting still triggered unnecessary RAG processing.

Problem

When either:

  1. All uploaded files have context="full" (Full Context mode), OR
  2. BYPASS_EMBEDDING_AND_RETRIEVAL is enabled (Admin Settings → Documents)

The code was still:

  1. Generating queries (possibly empty)
  2. Calling get_sources_from_items with full_context=True
  3. Emitting queries_generated status

This caused unnecessary retrieval processing and UI delays even when users explicitly expected direct file content injection without RAG.

Bug Manifestation

现象 1: "检索中"状态依然存在(完整文档模式)

  • 用户勾选 "完整上下文"(聊天文件模态框右上角),上传文档
  • UI 仍然显示 "检索中..." 和 "搜索到 X 个引用来源"
  • 有明显的延迟感

现象 2: "检索中"状态依然存在(全局绕过设置)

  • 管理员在 Admin Settings → Documents 中启用 "绕过嵌入和检索"
  • 用户上传文件后,仍然看到检索状态
  • 设置未生效

现象 3: 角色扮演场景性能灾难

  • 上传 50KB+ 的剧情文档
  • RAG 提取的片段破坏时间线连续性
  • AI "失忆"或���淆剧情顺序
  • 超过 3 轮对话后因上下文过大卡死

Affected Settings

| 设置位置 | 设置名称 | 问题 ||---------|---------|------|| 聊天文件模态框 | 完整文档 (Full Context) | 勾选后仍触发检索流程 || Admin → Documents | 绕过嵌入和检索 (Bypass Embedding) | 启用后仍触发检索流程 |

Solution

When all_full_context is True OR bypass_embedding is True:

  • Skip query generation entirely
  • Skip queries_generated status emission
  • Call get_sources_from_items with minimal parameters
  • Directly use file content without embedding/retrieval

Changes

  • Modified chat_completion_files_handler in backend/open_webui/utils/middleware.py
  • Added check for request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL
  • Split logic into two paths: bypass mode vs normal RAG
  • When bypass conditions are met, skip all retrieval-related processing

Testing

  • Upload files with Full Context mode enabled
  • Enable Bypass Embedding and Retrieval in admin settings
  • Verify no "Retrieving..." status appears in both cases
  • Verify file content is directly injected into prompt
  • Verify normal RAG mode still works when not in bypass mode

Screenshots / Evidence

N/A - Backend logic change


Changelog Entry

Fixed

  • Fixed Full Context mode still triggering RAG processing (#22674)
  • Fixed Bypass Embedding and Retrieval setting not fully bypassing RAG

Additional Information

CLA

I have read the CLA Document and I hereby sign the CLA

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing Environment

  • OS: Ubuntu 22.04
  • Python: 3.11
  • Docker: 24.0

Signed-off-by: Pyrite Prof pyrite@example.com


🔄 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/22674 **Author:** [@a86582751](https://github.com/a86582751) **Created:** 3/14/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-full-context-bypass-rag` --- ### 📝 Commits (10+) - [`fe6783c`](https://github.com/open-webui/open-webui/commit/fe6783c16699911c7be17392596d579333fb110c) Merge pull request #19030 from open-webui/dev - [`fc05e0a`](https://github.com/open-webui/open-webui/commit/fc05e0a6c5d39da60b603b4d520f800d6e36f748) Merge pull request #19405 from open-webui/dev - [`e3faec6`](https://github.com/open-webui/open-webui/commit/e3faec62c58e3a83d89aa3df539feacefa125e0c) Merge pull request #19416 from open-webui/dev - [`9899293`](https://github.com/open-webui/open-webui/commit/9899293f050ad50ae12024cbebee7e018acd851e) Merge pull request #19448 from open-webui/dev - [`140605e`](https://github.com/open-webui/open-webui/commit/140605e660b8186a7d5c79fb3be6ffb147a2f498) Merge pull request #19462 from open-webui/dev - [`6f1486f`](https://github.com/open-webui/open-webui/commit/6f1486ffd0cb288d0e21f41845361924e0d742b3) Merge pull request #19466 from open-webui/dev - [`d95f533`](https://github.com/open-webui/open-webui/commit/d95f533214e3fe5beb5e41ec1f349940bc4c7043) Merge pull request #19729 from open-webui/dev - [`a727153`](https://github.com/open-webui/open-webui/commit/a7271532f8a38da46785afcaa7e65f9a45e7d753) 0.6.43 (#20093) - [`6adde20`](https://github.com/open-webui/open-webui/commit/6adde203cd292a9e3af9c64a2ae36b603fed096a) Merge pull request #20394 from open-webui/dev - [`f9b0534`](https://github.com/open-webui/open-webui/commit/f9b0534e0c442631d1cb7205169588b9b6204179) Merge pull request #20522 from open-webui/dev ### 📊 Changes **1 file changed** (+51 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+51 -30) </details> ### 📄 Description # Pull Request Checklist ### **Before submitting, ensure you have:** - [x] Read the Contributing Guidelines - [x] Read the CLA - [x] Tested the changes locally - [x] Followed the PR template --- ## Description Fixes the issue where 'Full Context' mode and 'Bypass Embedding and Retrieval' setting still triggered unnecessary RAG processing. ### Problem When either: 1. All uploaded files have `context="full"` (Full Context mode), OR 2. `BYPASS_EMBEDDING_AND_RETRIEVAL` is enabled (Admin Settings → Documents) The code was still: 1. Generating queries (possibly empty) 2. Calling `get_sources_from_items` with `full_context=True` 3. Emitting `queries_generated` status This caused unnecessary retrieval processing and UI delays even when users explicitly expected direct file content injection without RAG. ### Bug Manifestation **现象 1: "检索中"状态依然存在(完整文档模式)** - 用户勾选 "完整上下文"(聊天文件模态框右上角),上传文档 - UI 仍然显示 "检索中..." 和 "搜索到 X 个引用来源" - 有明显的延迟感 **现象 2: "检索中"状态依然存在(全局绕过设置)** - 管理员在 Admin Settings → Documents 中启用 "绕过嵌入和检索" - 用户上传文件后,仍然看到检索状态 - 设置未生效 **现象 3: 角色扮演场景性能灾难** - 上传 50KB+ 的剧情文档 - RAG 提取的片段破坏时间线连续性 - AI "失忆"或���淆剧情顺序 - 超过 3 轮对话后因上下文过大卡死 ### Affected Settings | 设置位置 | 设置名称 | 问题 ||---------|---------|------|| 聊天文件模态框 | 完整文档 (Full Context) | 勾选后仍触发检索流程 || Admin → Documents | 绕过嵌入和检索 (Bypass Embedding) | 启用后仍触发检索流程 | ### Solution When `all_full_context` is `True` OR `bypass_embedding` is `True`: - **Skip query generation entirely** - **Skip `queries_generated` status emission** - **Call `get_sources_from_items` with minimal parameters** - **Directly use file content without embedding/retrieval** ### Changes - Modified `chat_completion_files_handler` in `backend/open_webui/utils/middleware.py` - Added check for `request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL` - Split logic into two paths: bypass mode vs normal RAG - When bypass conditions are met, skip all retrieval-related processing ### Testing - [x] Upload files with Full Context mode enabled - [x] Enable Bypass Embedding and Retrieval in admin settings - [x] Verify no "Retrieving..." status appears in both cases - [x] Verify file content is directly injected into prompt - [x] Verify normal RAG mode still works when not in bypass mode ### Screenshots / Evidence N/A - Backend logic change --- ## Changelog Entry ### Fixed - Fixed Full Context mode still triggering RAG processing (#22674) - Fixed Bypass Embedding and Retrieval setting not fully bypassing RAG --- ## Additional Information ### CLA I have read the CLA Document and I hereby sign the CLA ### Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update ### Testing Environment - OS: Ubuntu 22.04 - Python: 3.11 - Docker: 24.0 --- **Signed-off-by:** Pyrite Prof <pyrite@example.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:43:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26808