From 4e7a8e67984eb1e7fff5a314d164e65d03c6b221 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 10 Apr 2026 17:06:13 +0800 Subject: [PATCH] fix(ai_auto_response): clean think noise from parsed fields --- plugins/ai_auto_response/core/llm_result_parser.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/ai_auto_response/core/llm_result_parser.py b/plugins/ai_auto_response/core/llm_result_parser.py index b90a3d9..b372aac 100644 --- a/plugins/ai_auto_response/core/llm_result_parser.py +++ b/plugins/ai_auto_response/core/llm_result_parser.py @@ -75,12 +75,12 @@ class LLMResultParser: data = cls.extract_json_object(response) if isinstance(data, dict): should_reply = cls.coerce_bool(data.get("should_reply", True), default=True) - reply_mode = str(data.get("reply_mode", fallback_reply_mode) or fallback_reply_mode) + reply_mode = cls._clean_text_field(data.get("reply_mode", fallback_reply_mode)) if reply_mode not in {"social_short", "qa_fast", "qa_with_context"}: - reply_mode = fallback_reply_mode - reply = str(data.get("reply", "") or "").strip() + reply_mode = fallback_reply_mode if fallback_reply_mode in {"social_short", "qa_fast", "qa_with_context"} else "social_short" + reply = cls._clean_text_field(data.get("reply", "")) topic_id = str(data.get("topic_id", "") or "latest:0").strip() or "latest:0" - topic_summary = str(data.get("topic_summary", "") or fallback_topic).strip() + topic_summary = cls._clean_text_field(data.get("topic_summary", "") or fallback_topic) if current_content and cls.looks_like_prompt_echo(reply, current_content): should_reply = False reply = "" @@ -154,6 +154,12 @@ class LLMResultParser: value = re.sub(r".*?", "", value, flags=re.IGNORECASE | re.DOTALL) return value + @classmethod + def _clean_text_field(cls, value: Any) -> str: + text = str(value or "") + text = cls._strip_think_blocks(text) + return text.strip() + @staticmethod def _unwrap_result_payload(text: str) -> str: raw = str(text or "").strip()