Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aider/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ def get_parser(default_config_files, git_root):
group.add_argument(
"--git-commit-verify",
action=argparse.BooleanOptionalAction,
default=False,
help="Enable/disable git pre-commit hooks with --no-verify (default: False)",
default=True,
help="Enable/disable git pre-commit hooks with --no-verify (default: True)",
)
group.add_argument(
"--commit",
Expand Down
23 changes: 23 additions & 0 deletions aider/coders/base_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,11 @@ def show_send_output(self, completion):
self.io.tool_error(show_content_err)
raise Exception("No data found in LLM response!")

# Normalize <think> tags from models that embed reasoning in content
self.partial_response_content = self._normalize_think_tags(
self.partial_response_content
)

show_resp = self.render_incremental_response(True)

if reasoning_content:
Expand Down Expand Up @@ -1953,6 +1958,9 @@ def show_send_output_stream(self, completion):

if received_content:
self._stop_waiting_spinner()

# Normalize <think> tags from models that embed reasoning in content
text = self._normalize_think_tags(text)
self.partial_response_content += text

if self.show_pretty():
Expand Down Expand Up @@ -1983,8 +1991,23 @@ def live_incremental_response(self, final):
def render_incremental_response(self, final):
return self.get_multi_response_content_in_progress()

def _normalize_think_tags(self, text):
"""
Convert raw <think> tags to the internal reasoning tag format.
Many Ollama/OpenAI-compatible models embed reasoning in the content
as <think> tags rather than using the reasoning_content field.
"""
if self.reasoning_tag_name != "think":
text = re.sub(r"<think>", f"<{REASONING_TAG}>", text)
text = re.sub(r"</think>", f"</{REASONING_TAG}>", text)
return text

def remove_reasoning_content(self):
"""Remove reasoning content from the model's response."""
# Normalize <think> tags from models that embed reasoning in content
self.partial_response_content = self._normalize_think_tags(
self.partial_response_content
)

self.partial_response_content = remove_reasoning_content(
self.partial_response_content,
Expand Down
Loading