fix(anthropic_adapter): preserve thinking content on MiniMax /anthropic endpoint (#75725) - #75748
Conversation
|
Thanks for tracing the replay path. The current-main premise is real: Problems
Suggested changes
Automated hermes-sweeper review. |
|
Thanks for taking the signed-to-unsigned replay direction here. I independently reproduced the current-main replay path and tested a local consolidation patch instead of opening another overlapping PR. The core policy in this PR is sound: keep the
The combined local patch passed 189 focused MiniMax/Anthropic/Kimi/DeepSeek/Portal/contributor tests, plus I am intentionally not opening another competing PR. I can provide the small hardening patch or adapt it onto this branch after maintainer direction on consolidation. |
…ic endpoint (NousResearch#75725) MiniMax's /anthropic endpoint returns signed thinking blocks but validates signatures against the originating turn context. The generic third-party branch in _manage_thinking_signatures stripped ALL thinking blocks (assuming third-party endpoints cannot validate Anthropic-proprietary signatures), which killed interleaved reasoning on turn 2+ — the wire request carried [tool_use] only, no chain-of-thought context. MiniMax accepts unsigned thinking blocks on replay (verified by the reporter's live API tests). Add a MiniMax-specific branch that strips the signature (signed→unsigned) while preserving the thinking content, distinct from DeepSeek's policy (which strips signed blocks entirely because DeepSeek only replays unsigned synthesised blocks).
adbe9ac to
9a6564a
Compare
What
MiniMax's
/anthropicendpoint returns signed thinking blocks but validates signatures against the originating turn context. The generic third-party branch in_manage_thinking_signaturesstripped ALL thinking blocks (signed or unsigned), which killed interleaved reasoning on turn 2+ — the wire request carried[tool_use]only, no chain-of-thought context.MiniMax accepts unsigned thinking blocks on replay and uses them for interleaved reasoning across tool-call turns (verified by the reporter's live API tests). This adds a MiniMax-specific branch that strips the
signature(signed → unsigned) while preserving thethinkingcontent. This is distinct from DeepSeek's policy (which strips signed blocks entirely because DeepSeek only replays unsigned blocks synthesised fromreasoning_content).How
New
elif _is_minimax_anthropic_endpoint(base_url):branch in_manage_thinking_signatures, placed before the generic_is_third_partystrip:thinkingblocks: stripsignature+cache_control, keepthinkingtext → block becomes unsigned.redacted_thinkingblocks: the opaquedatapayload is signature-equivalent and MiniMax cannot validate it → replaced with a text placeholder to preserve block position for interleaved reasoning.Other endpoints (DeepSeek, Kimi, native Anthropic, Nous Portal, generic third-party) are unaffected — the MiniMax branch only matches
api.minimax.io/anthropic/api.minimaxi.com/anthropic.Verification
RED phase — 4 regression tests fail on
upstream/main(thinking stripped on MiniMax):GREEN phase — all 8 new tests pass with the fix:
Nearby suite — 167 total tests pass (zero failures):
tests/agent/test_minimax_anthropic_thinking.py: 8 passedtests/agent/test_nous_portal_anthropic_wire.py: 26 passed (incl. newtest_minimax_demotes_signed_thinking_to_unsigned)tests/agent/test_anthropic_adapter.py: 84 passedtests/agent/test_deepseek_anthropic_thinking.py+ kimi + minimax provider: 49 passedExisting test updated:
test_other_third_party_gateways_still_strip_thinkingwas repointed to a generic third-party proxy URL (it previously used the MiniMax URL and asserted all thinking stripped, which is now incorrect since MiniMax has its own carve-out). A newtest_minimax_demotes_signed_thinking_to_unsignedtest was added in the same Portal test class to verify MiniMax's signed→unsigned demotion.Closes #75725.
Auto-published by Moonsong via Path B automated pipeline.