diff --git a/backend/open_webui/utils/tool_calling.py b/backend/open_webui/utils/tool_calling.py index 7a7bb9d6f1..5001a52baf 100644 --- a/backend/open_webui/utils/tool_calling.py +++ b/backend/open_webui/utils/tool_calling.py @@ -90,7 +90,11 @@ _TOOL_APPROVAL_PROMPT_RE = re.compile(r'\n?\n.*?') + return _TOOL_APPROVAL_PROMPT_RE.sub('', head + tag) + tail def set_tool_call_metadata(item, tools): diff --git a/backend/open_webui/utils/tool_search.py b/backend/open_webui/utils/tool_search.py index 3edbc5126a..8526fac27a 100644 --- a/backend/open_webui/utils/tool_search.py +++ b/backend/open_webui/utils/tool_search.py @@ -239,7 +239,10 @@ def resolve_tool_call(tool_call: dict, tools: dict[str, dict]) -> str | None: def strip_deferred_tools_manifest(system_prompt: str | None) -> str | None: """Remove the manifest from a system prompt that is reused by a request which builds its own.""" - return _MANIFEST_RE.sub('', system_prompt) if system_prompt else system_prompt + if not system_prompt: + return system_prompt + head, tag, tail = system_prompt.rpartition('') + return _MANIFEST_RE.sub('', head + tag) + tail # Letters, digits and combining marks, so vowel signs in scripts like Devanagari stay attached to their word.