From ebd4d9c6cccc0440c816ff6b117cac06f547ac8a Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 19 Aug 2026 20:08:02 +0200 Subject: [PATCH] fix: honor bypass_system_prompt on the pipe route (#28739) The tool-call continuation re-submits with bypass_system_prompt=True, but only routers/openai.py and routers/ollama.py checked it, so pipe and manifold models had the system prompt applied again on every continuation. Since add_or_update_system_message() prepends rather than replaces, N tool-call rounds left N+1 copies of the system prompt in the payload. --- backend/open_webui/functions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/functions.py b/backend/open_webui/functions.py index b45c7c2f5f..41e1a42d9e 100644 --- a/backend/open_webui/functions.py +++ b/backend/open_webui/functions.py @@ -212,6 +212,9 @@ async def generate_function_chat_completion(request, form_data, user, models: di return params + # Set server-side by utils/chat.py, never by client input. Mirrors the routers. + bypass_system_prompt = getattr(request.state, 'bypass_system_prompt', False) + # Copy so the base-model substitution below doesn't leak into the caller's # payload, which the tool-call continuation re-submits. Mirrors the routers. form_data = {**form_data} @@ -291,7 +294,8 @@ async def generate_function_chat_completion(request, form_data, user, models: di if params: system = params.pop('system', None) form_data = apply_model_params_to_body_openai(params, form_data) - form_data = await apply_system_prompt_to_body(system, form_data, metadata, user) + if not bypass_system_prompt: + form_data = await apply_system_prompt_to_body(system, form_data, metadata, user) pipe_id = get_pipe_id(form_data) function_module = await get_function_module_by_id(request, pipe_id)