You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agent): treat a think-only turn as non-actionable - #2751
MiniMax M2 models (and GLM) return their reasoning inline as a leading <think>...</think> block in content on the OpenAI-compatible endpoint, unless the request sets reasoning_split: true (MiniMax docs). parseAssistantMessageV2 did not treat that block specially, which caused two problems:
A turn that only contained reasoning, with no answer and no tool call, was parsed as a normal text block. handleTextBlock then emitted it as completion_result, so the task stopped halfway and waited for the user. This matches the report: the agent stops after a few steps, and sometimes works in a new session.
Tool tags mentioned inside the reasoning (for example "I should call <execute_command>") were scanned as tool openers.
Changes in parse-assistant-message.ts:
Add LEADING_THINK_BLOCK, which matches a <think> or <thinking> block at the start of the message, including an unclosed block while the stream is still inside the reasoning. Only a leading block counts, which matches how markdownRenderer.vue already renders thinking content.
parseAssistantMessageV2 skips over that block without looking for tool tags. The block stays in the text content, so the UI display is unchanged.
hasUsableTextContent strips the leading block before deciding whether a turn is usable. A think-only turn now goes through the existing empty-response retry path (handleEmptyAssistantResponse + noToolsUsed), the same path used for markup-only residue in 873a6d8.
Not verified: I have not run this against a live MiniMax endpoint. The fix is checked at the parser level with constructed outputs.
Checklist
npm run lint && npm run format && npm run typecheck all pass; tests added/updated as needed.
Added 6 tests in parse-assistant-message.test.ts. 3 of them fail without the fix. Changed lines are fully covered.
Full vitest run: 4804 passed, 2 failed. The failures are in proxy/undici-dispatcher.test.ts and proxy/https-system-proxy.integration.test.ts. They also fail on main locally (Node 26 rejects an IP address as TLS ServerName, ERR_INVALID_ARG_VALUE) and are unrelated to this change.
If UI or user-visible change: i18n and README updated. (No new user-facing text.)
Summary by CodeRabbit
Bug Fixes
Improved handling of <think> and <thinking> blocks so content inside them is not mistaken for tool calls.
Reasoning-only turns are now correctly recognized as having no usable response, while turns with a subsequent answer or tool call remain usable.
Unclosed reasoning blocks and ordinary mentions of “think” in prose are handled without incorrectly parsing or rejecting the message.
Tests
Added coverage for reasoning blocks, tool-call parsing, and usable-response detection.
MiniMax and GLM models can return their reasoning inline as a leading
<think> block in the content stream. The parser scanned that block for
tool tags, so a tool name mentioned while thinking could start a tool
call, and a turn that only contained reasoning was treated as the final
answer, which stopped the task halfway.
Skip the leading reasoning block when parsing tool tags and ignore it
when deciding whether a turn is usable, so a think-only turn goes
through the existing empty-response retry path.
Refs: chaterm#2746
Reviewing files that changed from the base of the PR and between 43dbf2b and 49508e4.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Note
.coderabbit.yml has unrecognized properties
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 2
Validation error: Unrecognized keys: "walkthrough", "disable", "collapse_when_outdated", "collapse_when_resolved", "max_comments_per_review", "max_files_per_review" at "reviews"; Unrecognized key: "enabled" at "chat"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
Changes
The parser recognizes leading <think> and <thinking> blocks, including unclosed blocks. It retains the block in the text span and does not scan its contents for tool tags. The usability check removes a leading reasoning block before checking for remaining text.
Layer / File(s)
Summary
Parse reasoning blocks and check turn usability src/main/agent/core/assistant-message/parse-assistant-message.ts, src/main/agent/core/assistant-message/parse-assistant-message.test.ts
The parser skips tool-tag scanning inside a leading reasoning block. The usability check removes that block before checking for remaining text. Tests cover closed and unclosed blocks, tool calls after reasoning, reasoning-only turns, and ordinary prose that mentions <think>.
This change stops reasoning-only turns from being treated as final answers and stops tool names mentioned in reasoning from being parsed as tool calls. No merge-blocking risk was identified, and the new parser tests cover the changed behavior.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(agent): treat a think-only turn as non-actionable" names the main change. The PR makes parseAssistantMessageV2 skip a leading / block when scanning for tool tags, and m…
Description check
The description follows the repository template. It includes the related issue (Refs discussion #2746, not the template's 'Resolves #(issue_number)' form), a detailed Description section explaining th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(agent): treat a think-only turn as non-actionable" names the main change. The PR makes parseAssistantMessageV2 skip a leading <think>/<thinking> block when scanning for tool tags, and makes hasUsableTextContent strip that block so a reasoning-only turn goes through the empty-response retry path. The title is concise, specific, and follows a conventional commit style.
Full details: Description check
Explanation
The description follows the repository template. It includes the related issue (Refs discussion #2746, not the template's 'Resolves #(issue_number)' form), a detailed Description section explaining the root cause, the changes in parse-assistant-message.ts, and testing notes. The checklist is filled in. The lint/format/typecheck item is checked and the i18n item is marked not applicable with a reason. The related issue line uses 'Refs' rather than 'Resolves', which is a minor deviation and does not affect the check.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Refs #2746
Description
MiniMax M2 models (and GLM) return their reasoning inline as a leading
<think>...</think>block incontenton the OpenAI-compatible endpoint, unless the request setsreasoning_split: true(MiniMax docs).parseAssistantMessageV2did not treat that block specially, which caused two problems:handleTextBlockthen emitted it ascompletion_result, so the task stopped halfway and waited for the user. This matches the report: the agent stops after a few steps, and sometimes works in a new session.<execute_command>") were scanned as tool openers.Changes in
parse-assistant-message.ts:LEADING_THINK_BLOCK, which matches a<think>or<thinking>block at the start of the message, including an unclosed block while the stream is still inside the reasoning. Only a leading block counts, which matches howmarkdownRenderer.vuealready renders thinking content.parseAssistantMessageV2skips over that block without looking for tool tags. The block stays in the text content, so the UI display is unchanged.hasUsableTextContentstrips the leading block before deciding whether a turn is usable. A think-only turn now goes through the existing empty-response retry path (handleEmptyAssistantResponse+noToolsUsed), the same path used for markup-only residue in 873a6d8.Not verified: I have not run this against a live MiniMax endpoint. The fix is checked at the parser level with constructed outputs.
Checklist
npm run lint && npm run format && npm run typecheckall pass; tests added/updated as needed.parse-assistant-message.test.ts. 3 of them fail without the fix. Changed lines are fully covered.vitestrun: 4804 passed, 2 failed. The failures are inproxy/undici-dispatcher.test.tsandproxy/https-system-proxy.integration.test.ts. They also fail onmainlocally (Node 26 rejects an IP address as TLS ServerName,ERR_INVALID_ARG_VALUE) and are unrelated to this change.Summary by CodeRabbit
<think>and<thinking>blocks so content inside them is not mistaken for tool calls.