Repository navigation
fix(thinking): replay MiniMax reasoning inline as <think> tags in content - #264
Merged
Merged
Conversation
…tent MiniMax is an interleaved thinking model: its upstream silently drops a separate reasoning_content field on replay, so prior thinking vanished from context and the model re-derived (and visibly repeated) the same reasoning preamble before every tool call in agent loops. shouldEchoThinkingHistory() now returns false for /^minimax-/i and convertMessage() replays thinking (plain + tool-call branches, per-tool reasoning included) as a <think> prefix on content. Receive-side think-tag filtering unchanged. Other families keep their contracts. Docs: docs/features/19-20261020-minimax-interleaved-thinking-replay.md, ARCHITECTURE-MAP.md, CHANGELOG.md (0.7.10), historical note in doc 55.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
MiniMax (m2.x / m3.x) with thinking on repeated an identical reasoning preamble before almost every tool call in long agent loops (15+ tool calls, same sentence verbatim each time).
Root cause
MiniMax is an interleaved thinking model. Its official contract (MiniMax-AI/MiniMax-M2 README, "Inference Parameters") requires assistant thinking to be replayed inline as
<think>...</think>insidecontent— the upstream silently drops a separatereasoning_contentfield on replay. We replayed MiniMax thinking history asreasoning_content(family-gated "tolerated" since #123), so prior thinking effectively vanished from context on every follow-up request; the model re-derived the same conclusion at each tool call, producing the identical preamble.Not an echo-loop class bug (#38/#244) — it's lost thinking continuity.
Fix
shouldEchoThinkingHistory()now returnsfalsefor/^minimax-/iisMiniMaxModel()+inlineThinkingForHistory()helpers (src/reasoningHistory.ts)convertMessage()replays thinking (plain + tool-call branches, per-tool reasoning viareasoningForToolCalls) as a<think>prefix oncontent;reasoning_contentomitted for MiniMaxthinkTags.ts) unchangedBlast radius
None for other families — DeepSeek (required echo), Kimi/GLM/Qwen/Gemini, MiMo (omitted), GPT/Claude keep their existing contracts. Per-family tests updated as guards.
Verification
npm run lint(7 checks incl. typecheck + unit tests): passedminimax-m3.1, thinking on): pending — tracked as Open Risk in the feature docDocs
docs/features/19-20261020-minimax-interleaved-thinking-replay.md(new, per-family replay contract table)ARCHITECTURE-MAP.md,CHANGELOG.md(0.7.10), historical note indocs/issues/55-...