Skip to content

fix(agent): add Chinese reasoning tags to think-block filter for MiniMax M3 - #43836

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/chinese-think-tags
Closed

fix(agent): add Chinese reasoning tags to think-block filter for MiniMax M3#43836
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/chinese-think-tags

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Problem

MiniMax M3 emits Chinese-language reasoning tags ( 思考, 反思, 推理, 推敲) instead of the English <think> family. The three filter sites that strip reasoning content only handle English tags, causing raw Chinese reasoning to leak into user-visible output on Telegram, Discord, and CLI.

Observed symptom: users see fragments like 思考\n...raw reasoning... in the middle of assistant responses.

Solution

Add the four Chinese reasoning tag pairs to all three filter sites:

# File Symbol Change
1 gateway/stream_consumer.py _OPEN_THINK_TAGS / _CLOSE_THINK_TAGS +4 tags each
2 cli.py _stream_delta local _OPEN_TAGS / _CLOSE_TAGS +4 tags each
3 agent/agent_runtime_helpers.py strip_think_blocks() +4 closed-pair regexes, +1 unterminated-block regex, +1 stray-orphan regex

Testing

  • 12/12 new regression tests pass (test_stream_consumer_chinese_think_tags.py)
  • 93/93 existing stream_consumer tests pass (no regression)
  • Tests cover: closed pairs for all 4 tag types, unterminated blocks, stray orphans, mixed English+Chinese, prose mentions not over-stripped

Related Issues

…Max M3

MiniMax M3 emits Chinese-language reasoning tags ( 思考,  反思,
 推理,  推敲) instead of the English <think> family. The three
filter sites — GatewayStreamConsumer streaming state machine, CLI
_stream_delta, and strip_think_blocks() post-processing — only
handled English tags, causing raw Chinese reasoning to leak into
user-visible output on Telegram/Discord/CLI.

Add the four Chinese tag pairs to all three filter sites and add
corresponding unterminated-block and stray-orphan regexes in
strip_think_blocks().

Fixes NousResearch#43827
Related: NousResearch#17924 (English tags), NousResearch#27288 (mixed-case tags)
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard provider/minimax MiniMax (Anthropic transport) P2 Medium — degraded but workaround exists labels Jun 10, 2026
@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, and for the detailed analysis in the linked issue. We're going to close it though — it runs against a standing design line: Hermes does not add parsing/scrubbing layers to strip a given model's bespoke raw reasoning delimiters.

The existing English <think> family scrubbers are the boundary we hold; we don't extend that surface to chase each model's custom reasoning markers (思考/反思/推理/推敲, mm:think, and whatever the next model emits). That set grows without end, and it masks the real issue: reasoning that leaks inline is a reasoning-routing / endpoint problem, not a missing-filter problem.

Concretely for MiniMax-M3: our provider plugin already sends reasoning_split: True to the api.minimax.io/v1 OpenAI-compatible route, so the model returns reasoning in a separate reasoning_content field rather than inline. If reasoning is still reaching delta.content, that points at the reasoning-split routing for that deployment, not at a tag the scrubber should learn.

There's also a correctness hazard specific to this fix: 思考/推理/反思 are ordinary Chinese words, not XML-shaped sentinels. Stripping everything from a bare 思考 (or between two occurrences of it) would corrupt legitimate Chinese-language answers — a fix that damages the feature it's meant to protect.

Not a knock on the work — the leak you saw is real to you. But the right fix lives in reasoning routing, not in a new raw-reasoning parser. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists provider/minimax MiniMax (Anthropic transport) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Chinese reasoning tags ( 思考 / 反思 / 推理 / 推敲) from MiniMax-M3 leak to user output in streaming + final response

3 participants