From 504e724fde849befedb2fad755f915599d20ed9c Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 24 Jul 2026 05:33:35 +0200 Subject: [PATCH] fix: detect bare pipe alternation as regex in grep_knowledge_files (#26795) is_regex_pattern only recognized the BRE-escaped form \| and not a bare |, so a pattern like "Jornak|Silverlake|Orissa" was treated as one literal string (including the pipe characters) and silently returned no matches. This contradicted the tool docstring, which explicitly advertises "error|warn" as an auto-detected regex example, and misled models into concluding the searched terms were absent from the file. Checking for a bare | also covers the escaped form, since \| contains |, and normalize_regex already converts escaped pipes before compilation. Literal patterns without regex metacharacters are unaffected. Fixes #26781 --- backend/open_webui/tools/knowledge_fs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/tools/knowledge_fs.py b/backend/open_webui/tools/knowledge_fs.py index 01026af470..704ea45b1f 100644 --- a/backend/open_webui/tools/knowledge_fs.py +++ b/backend/open_webui/tools/knowledge_fs.py @@ -33,9 +33,9 @@ MAX_GREP_MATCHES = 50 def is_regex_pattern(pattern: str) -> bool: - """Detect if a pattern looks like regex (\|, .*, .+, \d, \w, \s, [...]).""" + """Detect if a pattern looks like regex (|, .*, .+, \d, \w, \s, [...]).""" return ( - '\|' in pattern + '|' in pattern or '.*' in pattern or '.+' in pattern or '.?' in pattern