Files
open-webui/backend/open_webui/utils
Classic298 d3cfcd801e fix: preserve system prompt across tool calls when memories are enabled (#26857)
* fix: preserve system prompt across tool calls when memories are enabled

The native tool-call loop runs generate_chat_completion with
bypass_system_prompt=True, so the provider layer does not re-apply the
model's default system prompt on tool-call iterations. It relies instead
on metadata['system_prompt'], captured in process_chat_payload, to carry
the full system prompt forward and restore it after RAG injection.

That capture read the model default system prompt from
form_data['params']['system'], but apply_params_to_form_data had already
popped 'params' from form_data, so model_system_prompt was always empty.
metadata['system_prompt'] therefore only captured whatever was already
materialized in the messages. With memories enabled, that is the injected
<memory_context> system message, so tool-call requests were restored with
memory-only system content and the model's system prompt was dropped.
Without memories there was no system message to capture at all.

Capture the model default system prompt from form_data['params'] before
apply_params_to_form_data pops it, and use that value when building
metadata['system_prompt'].

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Z4L51mvxDJCx1EDxP2vFN

* refactor: condense system prompt capture comment to a single line

Replace the four-line explanation above the model_system_prompt capture with a one-line note. The variable name and the surrounding code already convey what happens; the comment only needs to state why the capture sits before apply_params_to_form_data.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-27 02:13:28 -04:00
..
2026-07-27 00:12:47 -04:00
2026-07-01 02:48:29 -05:00
2026-06-29 11:56:00 -05:00
2026-07-26 18:46:39 -04:00
2026-07-23 22:52:23 -04:00
2026-07-27 00:12:47 -04:00
2026-03-17 17:58:01 -05:00
2026-07-23 02:54:56 -04:00
2026-07-26 21:12:14 -04:00
2026-07-24 01:44:30 -04:00
2026-07-27 01:13:09 -04:00
2026-07-23 21:29:33 -04:00
2026-07-23 12:48:14 -04:00
2026-07-27 00:12:47 -04:00
2026-06-01 13:56:55 -07:00
2026-07-01 03:35:46 -05:00
2026-07-27 00:55:16 -04:00
2026-07-26 23:09:22 -04:00
2026-07-16 01:37:21 -04:00
2026-07-23 19:17:19 -04:00
2026-07-26 18:54:07 -04:00
2026-03-17 17:58:01 -05:00
2026-07-20 22:11:42 -04:00
2026-06-19 00:16:06 +02:00
2026-07-10 18:32:21 -05:00
2026-07-27 00:34:25 -04:00
2026-06-01 13:56:55 -07:00
2026-06-29 12:29:10 -05:00
2026-07-26 17:58:01 -04:00