Skip to content

feat(anthropic-adapter): preserve unsigned thinking blocks on MiniMax round-trip - #24494

Open
nagyminyo-cmyk wants to merge 1 commit into
NousResearch:mainfrom
nagyminyo-cmyk:feat/minimax-preserve-unsigned-thinking
Open

feat(anthropic-adapter): preserve unsigned thinking blocks on MiniMax round-trip#24494
nagyminyo-cmyk wants to merge 1 commit into
NousResearch:mainfrom
nagyminyo-cmyk:feat/minimax-preserve-unsigned-thinking

Conversation

@nagyminyo-cmyk

@nagyminyo-cmyk nagyminyo-cmyk commented May 12, 2026

Copy link
Copy Markdown

Summary

MiniMax's Anthropic-compatible endpoints require unsigned thinking blocks derived from reasoning_content to round-trip in replayed assistant tool-call history. Hermes already synthesizes those blocks, but the generic third-party signature-management path removed them on subsequent turns.

This PR updates _manage_thinking_signatures to reuse the existing _is_minimax_anthropic_endpoint predicate. For both supported MiniMax Anthropic endpoints, Hermes now:

  • preserves unsigned thinking blocks synthesized from reasoning_content;
  • strips Anthropic-signed thinking blocks that MiniMax cannot validate; and
  • continues stripping cache_control from retained thinking blocks through the shared cleanup path.

Azure remains on the generic third-party strip-all path, preventing the broader Bearer-auth matcher from accidentally opting Azure into MiniMax behavior.

Endpoints covered

  • https://api.minimax.io/anthropic
  • https://api.minimaxi.com/anthropic

Tests

Added direct regression coverage showing that both MiniMax hosts:

  • preserve unsigned thinking blocks during replay; and
  • strip Anthropic-signed thinking blocks.

The previous MiniMax strip-all assertion was replaced with an Azure negative case.

Validation completed:

  • scripts/run_tests.sh -j 2 tests/agent/test_minimax_anthropic_thinking.py tests/agent/test_deepseek_anthropic_thinking.py — 13 passed
  • ruff check agent/anthropic_adapter.py tests/agent/test_deepseek_anthropic_thinking.py tests/agent/test_minimax_anthropic_thinking.py — passed
  • python -m py_compile agent/anthropic_adapter.py tests/agent/test_deepseek_anthropic_thinking.py tests/agent/test_minimax_anthropic_thinking.py — passed

Review note

The branch has been rebased onto current main. The upstream CI workflow is awaiting maintainer approval before jobs can start.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/minimax MiniMax (Anthropic transport) labels May 12, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the MiniMax replay path. Current main still strips its unsigned thinking blocks, but this stale patch needs a narrow rework before salvage.

Problems

  • agent/anthropic_adapter.py:557-569 already defines _is_minimax_anthropic_endpoint; the PR adds the same symbol, so it will conflict on current main.
  • The PR’s proposed _requires_bearer_auth delegation is now too broad: that matcher also recognizes Azure at agent/anthropic_adapter.py:531-546. The existing MiniMax-only helper should remain the predicate.
  • No regression test accompanies the change. Current tests/agent/test_deepseek_anthropic_thinking.py:210-241 explicitly expects MiniMax to strip unsigned blocks, so the changed provider contract needs direct coverage.

Suggested changes

  • Reuse the existing MiniMax-only helper in the preserve gate at agent/anthropic_adapter.py:2275-2278.
  • Add tests for both MiniMax hosts preserving unsigned blocks while stripping signed blocks, and retain a negative Azure case.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 13, 2026

Copy link
Copy Markdown
Author

Thanks for the detailed review. You're right that the branch is stale. I'll rework it against current main, reuse the existing MiniMax-only helper in the preserve gate, and add regression coverage for both MiniMax hosts plus a negative Azure case before requesting another review.

@nagyminyo-cmyk
nagyminyo-cmyk force-pushed the feat/minimax-preserve-unsigned-thinking branch 2 times, most recently from 2c8c44e to 75bf4d8 Compare July 19, 2026 20:57
Reuse the existing MiniMax-only endpoint predicate in thinking signature management so both global and China endpoints preserve unsigned reasoning_content-derived blocks while stripping Anthropic-signed blocks.

Replace the outdated MiniMax strip-all regression with an Azure negative case and add direct coverage for both MiniMax hosts.
@nagyminyo-cmyk
nagyminyo-cmyk force-pushed the feat/minimax-preserve-unsigned-thinking branch from 75bf4d8 to 04aab97 Compare July 19, 2026 20:57
@nagyminyo-cmyk

Copy link
Copy Markdown
Author

Reworked and pushed in 04aab9700. The branch is now rebased on current main, reuses the existing MiniMax-only endpoint helper, preserves unsigned and strips signed thinking blocks for both MiniMax hosts, and keeps Azure on the generic strip-all path. The repository’s canonical focused test run passes all 13 tests, and Ruff plus py_compile pass. CI is currently awaiting maintainer approval to start. Could you take another look when convenient?

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 P3 Low — cosmetic, nice to have provider/minimax MiniMax (Anthropic transport) sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants