From a372c14fc50b0bbaf1fea2f5d3c729adf74e6d59 Mon Sep 17 00:00:00 2001 From: Chen Chia Yang Date: Wed, 8 Apr 2026 20:26:05 +0800 Subject: [PATCH] fix: strip tags from Gemma 4 responses in _strip_think_blocks Gemma 4 (26B/31B) uses ... to wrap its reasoning output. This tag was not included in the existing list of reasoning tag variants stripped by _strip_think_blocks(), causing raw thinking blocks to leak into the visible response. Added a new re.sub() line for and extended the cleanup regex to include 'thought' alongside the existing variants. Fixes #6148 --- run_agent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run_agent.py b/run_agent.py index 333dda392..2fd73160d 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1872,12 +1872,13 @@ class AIAgent: if not content: return "" # Strip all reasoning tag variants: , , , - # , + # , , (Gemma 4) content = re.sub(r'.*?', '', content, flags=re.DOTALL) content = re.sub(r'.*?', '', content, flags=re.DOTALL | re.IGNORECASE) content = re.sub(r'.*?', '', content, flags=re.DOTALL) content = re.sub(r'.*?', '', content, flags=re.DOTALL) - content = re.sub(r'\s*', '', content, flags=re.IGNORECASE) + content = re.sub(r'.*?', '', content, flags=re.DOTALL | re.IGNORECASE) + content = re.sub(r'\s*', '', content, flags=re.IGNORECASE) return content def _looks_like_codex_intermediate_ack(