diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 3dcc78a98..6f2f64e9f 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -2454,9 +2454,9 @@ def extract_content_or_reasoning(response) -> str: if content: # Strip inline think/reasoning blocks (mirrors _strip_think_blocks) cleaned = re.sub( - r"<(?:think|thinking|reasoning|REASONING_SCRATCHPAD)>" + r"<(?:think|thinking|reasoning|thought|REASONING_SCRATCHPAD)>" r".*?" - r"", + r"", "", content, flags=re.DOTALL | re.IGNORECASE, ).strip() if cleaned: diff --git a/tests/run_agent/test_run_agent.py b/tests/run_agent/test_run_agent.py index d716b59b2..e4ae10f20 100644 --- a/tests/run_agent/test_run_agent.py +++ b/tests/run_agent/test_run_agent.py @@ -302,6 +302,17 @@ class TestStripThinkBlocks: assert "" not in result assert "visible" in result + def test_thought_block_removed(self, agent): + """Gemma 4 uses tags for inline reasoning.""" + result = agent._strip_think_blocks("internal reasoning answer") + assert "internal reasoning" not in result + assert "" not in result + assert "answer" in result + + def test_orphaned_thought_tag(self, agent): + result = agent._strip_think_blocks("orphaned reasoning without close") + assert "" not in result + class TestExtractReasoning: def test_reasoning_field(self, agent):