Skip to content

fix(thinking): replay MiniMax reasoning inline as <think> tags in content - #264

Merged
ltmoerdani merged 1 commit into
mainfrom
fix/minimax-interleaved-thinking-replay
Oct 20, 2026
Merged

ltmoerdani merged 1 commit into
mainfrom
fix/minimax-interleaved-thinking-replay

Conversation

@ltmoerdani

Copy link
Copy Markdown
Owner

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> inside content — the upstream silently drops a separate reasoning_content field on replay. We replayed MiniMax thinking history as reasoning_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 returns false for /^minimax-/i
  • New isMiniMaxModel() + inlineThinkingForHistory() helpers (src/reasoningHistory.ts)
  • convertMessage() replays thinking (plain + tool-call branches, per-tool reasoning via reasoningForToolCalls) as a <think> prefix on content; reasoning_content omitted for MiniMax
  • Receive-side think-tag filtering (thinkTags.ts) unchanged

Blast 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): passed
  • Live E2E (multi-tool-call chat with minimax-m3.1, thinking on): pending — tracked as Open Risk in the feature doc

Docs

  • 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 in docs/issues/55-...

…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.
@ltmoerdani
ltmoerdani merged commit 5115bef into main Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant