DanielWalnut 3b105d1e5f
fix(suggestions): strip inline <think> reasoning before parsing follow-up questions (#3435)
Reasoning models such as MiniMax-M3 inline their chain-of-thought into the
message content as <think>...</think> (reasoning_split defaults to false)
instead of a separate reasoning_content field. The follow-up-suggestions
endpoint extracted the JSON array via find('[') / rfind(']'), which silently
broke whenever the reasoning text contained '[' or ']' — or when long thinking
hit max_tokens and truncated before the array was emitted — returning empty
suggestions.

- Add _strip_think_blocks() and apply it before JSON extraction; it removes
  complete <think>...</think> blocks (case-insensitive) and drops an unclosed
  <think> left by max_tokens truncation.
- Document the MiniMax thinking toggle in config.example.yaml
  (when_thinking_enabled: adaptive / when_thinking_disabled: disabled) so
  thinking_enabled=False actually disables reasoning on M3; note that M2.x
  models always think and rely on the defensive strip above.
- Tests cover complete/unclosed think blocks, brackets-inside-think, think +
  code-fence, and an end-to-end suggestions case reproducing the empty-result
  bug.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 15:48:00 +08:00
..