From 30a630412db5c3162149cf7b1cfc8e040a6d9dc2 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 7 Mar 2025 15:57:16 -0800 Subject: [PATCH] refactor: Improve reasoning tag handling in base_coder.py --- aider/coders/base_coder.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index ad076007a..3906f4509 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1758,12 +1758,9 @@ class Coder: if reasoning_content: formatted_reasoning = ( - self.replace_reasoning_tags( - f"<{REASONING_TAG}>\n\n" + reasoning_content + f"\n\n", - REASONING_TAG, - ) - + "\n\n" + f"<{REASONING_TAG}>\n\n" + reasoning_content + f"\n\n" ) + formatted_reasoning = self.replace_reasoning_tags(formatted_reasoning, REASONING_TAG) + "\n\n" show_resp = formatted_reasoning + show_resp self.io.assistant_output(show_resp, pretty=self.show_pretty()) @@ -1844,7 +1841,9 @@ class Coder: def live_incremental_response(self, final): show_resp = self.render_incremental_response(final) - # convert the tags to START/END ai! + # Apply any reasoning tag formatting + if self.got_reasoning_content: + show_resp = self.replace_reasoning_tags(show_resp, REASONING_TAG) self.mdstream.update(show_resp, final=final) def render_incremental_response(self, final):