Skip to content

fix(minimax): correct context lengths, model catalog, thinking guard, aux model, and config base_url#6046

Closed
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/minimax-provider-hardening
Closed

fix(minimax): correct context lengths, model catalog, thinking guard, aux model, and config base_url#6046
kshitijk4poor wants to merge 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/minimax-provider-hardening

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Hardens the MiniMax provider implementation by fixing 5 bugs identified through comparison with OpenCode's provider patterns and MiniMax's official API documentation.

Changes

1. Context lengths corrected (critical)
MiniMax models were mapped to 204,800 tokens. Official API docs:

  • M1 family: 1,000,000 context window
  • M2.5/M2.7: 1,048,576 context window

This caused premature context compression, wasting user tokens. Added per-model context entries and a get_minimax_max_output() helper for per-model output token limits.

2. Model catalog updated

  • Added M1 family: MiniMax-M1, M1-40k, M1-80k, M1-128k, M1-256k
  • Removed deprecated MiniMax-M2.1 (not in official docs)
  • Removed undocumented highspeed variants (same model at 2x price)
  • Updated _PROVIDER_MODELS, _DEFAULT_PROVIDER_MODELS, and test fixtures

3. Thinking parameter guard (fixes crash)
build_anthropic_kwargs() was sending thinking to MiniMax's Anthropic-compatible endpoint. MiniMax doesn't support it, causing TypeError: Messages.create() got an unexpected keyword argument 'thinking'. Added 'minimax' not in model.lower() guard alongside the existing Haiku guard.

4. Auxiliary model pricing
Default aux model was MiniMax-M2.7-highspeed (2x price, same quality). Changed to standard MiniMax-M2.7.

5. Config base_url ignored for API-key providers
model.base_url from config.yaml was ignored for API-key providers (MiniMax, ZAI, Kimi, etc.). The code always used the hardcoded inference_base_url from the provider registry. China MiniMax users setting model.base_url: https://api.minimaxi.com/anthropic still got routed to api.minimax.io, causing 401 errors.

Fixed by checking model.base_url from config when the configured provider matches, in both the credential pool path and the direct resolution path. Env var MINIMAX_BASE_URL takes priority over config.

Research methodology

Compared against OpenCode's provider system (per-model context windows, per-model max output tokens, per-provider error handling) and verified all model specs against MiniMax's official documentation at minimaxi.com (extracted from JS bundles since it's a SPA).

Related Issues

Fixes #5777 (thinking parameter crash)
Fixes #4082 (highspeed aux model pricing)
Fixes #6039 (config base_url ignored)
Closes #3895 (model catalog update — superset of that PR)
Related: #5781 (aux URL routing — fixed in #5983)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

How to Test

python -m pytest tests/agent/test_minimax_provider.py -v
python -m pytest tests/hermes_cli/test_setup_model_selection.py -k minimax -v
python -m pytest tests/hermes_cli/test_runtime_provider_resolution.py -k minimax -v
python -m pytest tests/agent/test_anthropic_adapter.py -k thinking -v

24 new test assertions covering context lengths, max output lookup, thinking guard, aux model, catalog correctness, and config base_url override.

Checklist

@kshitijk4poor kshitijk4poor force-pushed the fix/minimax-provider-hardening branch from 9f9a197 to b2dcf8e Compare April 8, 2026 06:15
@kshitijk4poor kshitijk4poor changed the title fix(minimax): correct context lengths, model catalog, thinking guard, and aux model fix(minimax): correct context lengths, model catalog, thinking guard, aux model, and config base_url Apr 8, 2026
… aux model, and config base_url

Context lengths were 204K — actual MiniMax API docs show 1M (M1) and
1,048,576 (M2.5/M2.7). Premature context compression was wasting tokens.

Model catalog listed deprecated M2.1 and undocumented highspeed variants.
Updated to match official MiniMax API: M1 family (M1, M1-40k, M1-80k,
M1-128k, M1-256k), M2.5, M2.7.

build_anthropic_kwargs() was sending the 'thinking' parameter to MiniMax's
Anthropic-compatible endpoint — MiniMax doesn't support it, causing
TypeError crashes (Messages.create() got an unexpected keyword argument).

Default auxiliary model was M2.7-highspeed (2x price, same quality).
Changed to standard M2.7.

API-key providers (MiniMax, ZAI, Kimi, etc.) ignored model.base_url from
config.yaml, always using the hardcoded inference_base_url. China MiniMax
users setting model.base_url to api.minimaxi.com/anthropic still got
routed to api.minimax.io, causing 401. Now honours config.yaml base_url
when the configured provider matches, with env var taking priority.

Added get_minimax_max_output() for per-model output token limits and
comprehensive test coverage (24 new tests).

Fixes NousResearch#5777, fixes NousResearch#4082, fixes NousResearch#6039.
Closes NousResearch#3895.
@kshitijk4poor kshitijk4poor force-pushed the fix/minimax-provider-hardening branch from b2dcf8e to 87dfaff Compare April 8, 2026 06:51
teknium1 pushed a commit that referenced this pull request Apr 8, 2026
… aux model, and config base_url

Cherry-picked from PR #6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes #5777, #4082, #6039. Closes #3895.
teknium1 pushed a commit that referenced this pull request Apr 8, 2026
… aux model, and config base_url

Cherry-picked from PR #6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes #5777, #4082, #6039. Closes #3895.
@teknium1

teknium1 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #6082. Your commit was cherry-picked onto current main with authorship preserved in git log. Stripped the unused get_minimax_max_output() helper (no consumer yet), but kept all 5 substantive fixes. Thanks for the thorough research and clean implementation!

@teknium1 teknium1 closed this Apr 8, 2026
Tommyeds pushed a commit to Tommyeds/hermes-agent that referenced this pull request Apr 12, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 28, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
… aux model, and config base_url

Cherry-picked from PR NousResearch#6046 by kshitijk4poor with dead code stripped.

- Context lengths: 204800 → 1M (M1) / 1048576 (M2.5/M2.7) per official docs
- Model catalog: add M1 family, remove deprecated M2.1 and highspeed variants
- Thinking guard: skip extended thinking for MiniMax (Anthropic-compat endpoint)
- Aux model: MiniMax-M2.7-highspeed → MiniMax-M2.7 (same model, half price)
- Config base_url: honour model.base_url for API-key providers (fixes China users)
- Stripped unused get_minimax_max_output() / _MINIMAX_MAX_OUTPUT (no consumer)

Fixes NousResearch#5777, NousResearch#4082, NousResearch#6039. Closes NousResearch#3895.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants