From fe8b30438a1ddefcd9d1e446f56e8456c1b89561 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 26 Sep 2026 05:19:09 +0200 Subject: [PATCH] fix: stray <|end_of_solution|> marker left in the reply (#31436) When a model wraps its answer in <|begin_of_solution|> and <|end_of_solution|>, only the opening marker was removed. The closing marker stayed visible in the reply and was saved with the message, and anything the model wrote after it was glued onto the answer. Now both markers are removed and text after the answer shows up as a normal part of the reply. Fixes #31434 --- backend/open_webui/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index a4ddd71689..6378ad57b1 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4540,7 +4540,7 @@ async def streaming_chat_response_handler(response, ctx): last_type = output[-1].get('type', '') if output else '' - if last_type == 'message': + if last_type == 'message' and output[-1].get('_tag_type') != content_type: # Use the output item's own text for tag detection item = output[-1] item_text = get_last_text(output)