From d46a4f6006f78ea1e0a052973a35d99f6d73c93f Mon Sep 17 00:00:00 2001 From: Brad Shannon Date: Wed, 17 Jun 2026 17:56:12 -0400 Subject: [PATCH] fix(llm/openai): strip tags against the original chunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reasoning models often emit both and in a single streamed chunk. The previous code truncated `content` at first, then tested the already-truncated string for . The closing tag was gone, so `is_active` was never restored to True and the entire post- answer was dropped — the user received silence. Snapshot the chunk as `original_content` and test both tags against the snapshot so the closing tag is still detectable after truncation. --- main/xiaozhi-server/core/providers/llm/openai/openai.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index ed0b5e978..eb6b62a94 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -123,12 +123,13 @@ class LLMProvider(LLMProviderBase): except IndexError: content = "" if content: - if "" in content: + original_content = content + if "" in original_content: is_active = False - content = content.split("")[0] - if "" in content: + content = original_content.split("")[0] + if "" in original_content: is_active = True - content = content.split("")[-1] + content = original_content.split("")[-1] if is_active: yield content finally: