Skip to content

fix(gateway): skip reasoning_content replay for MiniMax models - #27253

Closed
venyon2k wants to merge 1 commit into
NousResearch:mainfrom
venyon2k:fix/minimax-bloat-clean
Closed

fix(gateway): skip reasoning_content replay for MiniMax models#27253
venyon2k wants to merge 1 commit into
NousResearch:mainfrom
venyon2k:fix/minimax-bloat-clean

Conversation

@venyon2k

Copy link
Copy Markdown

Problem

MiniMax models generate per-turn-independent reasoning_content. Unlike DeepSeek/Kimi which require it preserved in replay to avoid HTTP 400, MiniMax's reasoning is fresh each turn and adds only context bloat when replayed.

Fix

  • _REASONING_BLOAT_PROVIDERS: minimax, minimax-cn, minimax-oauth
  • Host-based detection for custom endpoints at api.minimax.io / api.minimaxi.com
  • _is_reasoning_content_replay_bloat_model() — returns True for affected models
  • _build_replay_entry() gets reasoning_bloat_model=True kwarg — skips reasoning/reasoning_content/reasoning_details when True
  • DeepSeek/Kimi/Anthropic are explicitly NOT affected

Tests

  • TestReasoningBloatModel: 10 cases (provider slugs, host detection, negative cases)
  • TestBuildReplayEntryWithBloatModel: 4 cases (field suppression, non-reasoning field preservation)

Files

  • gateway/run.py (+57/-2)
  • tests/gateway/test_replay_entry_fields.py (+128/-2)

@daimon-nous daimon-nous Bot added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery provider/minimax MiniMax (Anthropic transport) labels May 17, 2026
@daimon-nous

daimon-nous Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Looks like a resubmission of #24958 (same author, same title, closed 2026-05-17). Keeping open for review — verify what changed from the prior version.

Related: reasoning_content cluster — #16500, #16892, #22839.

@venyon2k

Copy link
Copy Markdown
Author

Problem

MiniMax models generate per-turn-independent reasoning_content — each turn produces fresh reasoning with no semantic dependency on prior turns. Unlike DeepSeek/Kimi which require reasoning_content preserved in replay to avoid HTTP 400, MiniMax's reasoning is stateless.

Without this fix, reasoning_content accumulates across turns in replay history and is re-sent on every API call. Since MiniMax reasoning output can be substantial, this causes:

  • O(n²) token growth: each turn replayed includes all prior reasoning blobs, compounding with session length
  • Accelerated context window exhaustion: session dies faster on longer tasks
  • Wasted token budget: paying for reasoning content that serves no downstream purpose

Fix

  • _REASONING_BLOAT_PROVIDERS: minimax, minimax-cn, minimax-oauth
  • Host-based detection for custom endpoints at api.minimax.io / api.minimaxi.com
  • _is_reasoning_content_replay_bloat_model() — returns True for affected models
  • _build_replay_entry() accepts reasoning_bloat_model=True — skips reasoning, reasoning_content, reasoning_details when True
  • Non-reasoning fields (finish_reason, codex_reasoning_items, codex_message_items) are preserved
  • DeepSeek/Kimi/Anthropic are explicitly NOT affected

Tests

  • TestReasoningBloatModel: 10 cases covering provider slugs, host detection, and negative cases for DeepSeek/Kimi/Anthropic
  • TestBuildReplayEntryWithBloatModel: 4 cases covering field suppression and non-reasoning field preservation

Files

  • gateway/run.py (+57/-2)
  • tests/gateway/test_replay_entry_fields.py (+128/-2)

@venyon2k

Copy link
Copy Markdown
Author

@teknium1 Hey — this is a clean single-commit PR. Happy to address any feedback. The O(n²) token growth issue is specific to MiniMax; DeepSeek/Kimi/Anthropic are completely unaffected.

@cardtest15-coder

This comment was marked as spam.

@venyon2k venyon2k closed this May 17, 2026
@venyon2k
venyon2k deleted the fix/minimax-bloat-clean branch May 17, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have provider/minimax MiniMax (Anthropic transport) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants