diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 719c5af69..8e4404395 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1381,11 +1381,7 @@ class Coder: self.mdstream = None self.partial_response_content = self.get_multi_response_content_in_progress(True) - - self.partial_response_content = self.remove_reasoning_content( - self.partial_response_content, - self.reasoning_tag_name, - ) + self.remove_reasoning_content() self.multi_response_content = "" ### @@ -1833,9 +1829,13 @@ class Coder: def render_incremental_response(self, final): return self.get_multi_response_content_in_progress() - def remove_reasoning_content(self, content, reasoning_tag_name): + def remove_reasoning_content(self): """Remove reasoning content from the model's response.""" - return self.main_model.remove_reasoning_content(content, reasoning_tag_name) + + self.partial_response_content = self.main_model.remove_reasoning_content( + self.partial_response_content, + self.reasoning_tag_name, + ) def calculate_and_show_tokens_and_cost(self, messages, completion=None): prompt_tokens = 0 diff --git a/tests/basic/test_reasoning.py b/tests/basic/test_reasoning.py index aa6c71f74..fd44af80d 100644 --- a/tests/basic/test_reasoning.py +++ b/tests/basic/test_reasoning.py @@ -59,6 +59,7 @@ class TestReasoning(unittest.TestCase): self.assertIn(main_content, output) # Verify that partial_response_content only contains the main content + coder.remove_reasoning_content() self.assertEqual(coder.partial_response_content.strip(), main_content.strip()) # Ensure proper order: reasoning first, then main content @@ -168,12 +169,10 @@ class TestReasoning(unittest.TestCase): ) # Verify that partial_response_content only contains the main content + coder.remove_reasoning_content() expected_content = "Final answer after reasoning" self.assertEqual(coder.partial_response_content.strip(), expected_content) - # Verify that partial_response_content only contains the main content - self.assertEqual(coder.partial_response_content.strip(), "Final answer after reasoning") - def test_send_with_think_tags(self): """Test that tags are properly processed and formatted.""" # Setup IO with no pretty @@ -240,6 +239,7 @@ class TestReasoning(unittest.TestCase): ) # Verify that partial_response_content only contains the main content + coder.remove_reasoning_content() self.assertEqual(coder.partial_response_content.strip(), main_content.strip()) def test_send_with_think_tags_stream(self):