Skip to content

fix(provider): update MiniMax Token Plan defaults and model discovery - #11638

Open
wcqqq1214 wants to merge 1 commit into
AstrBotDevs:masterfrom
wcqqq1214:feat/minimax-m4-default
Open

wcqqq1214 wants to merge 1 commit into
AstrBotDevs:masterfrom
wcqqq1214:feat/minimax-m4-default

Conversation

@wcqqq1214

@wcqqq1214 wcqqq1214 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Update ProviderMiniMaxTokenPlan to default to MiniMax-M4 and align with the current MiniMax Anthropic-compatible API docs. Supersedes #10648.

Modifications / 改动点

  • Update the default model in ProviderMiniMaxTokenPlan from MiniMax-M3 to MiniMax-M4 (also handling blank model values) and avoid mutating caller config dicts.

  • Update the default China Anthropic endpoint to https://api.minimax.cn/anthropic in minimax_token_plan_source.py and default.py, while preserving configured custom/international api_base values (e.g., https://api.minimax.io/anthropic).

  • Safely handle empty key lists (key: []) so missing keys raise ValueError from ProviderAnthropic instead of IndexError.

  • Inherit ProviderAnthropic.get_models() (GET {base_url}/v1/models) instead of hardcoding https://api.minimaxi.com/v1/models with a separate httpx client.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

  • uv run ruff format --check . and uv run ruff check . passed.
  • uv run pytest tests/test_anthropic_kimi_code_provider.py tests/test_provider_user_agent.py -q passed.
  • Verified live against https://api.minimax.cn/anthropic: get_models() returned the model list including MiniMax-M4, and text_chat() succeeded using the default MiniMax-M4 model.
  • No WebUI navigation, page structure, or labels changed, so no documentation update is needed.

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。

  • 📚 I checked the affected WebUI instructions and screenshots in docs/zh and docs/en against the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog.
    / 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新 docs/zh 和 docs/en 的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Align MiniMax Token Plan defaults and model discovery with the current Anthropic-compatible API.

Bug Fixes:

  • Use the MiniMax China Anthropic endpoint as the default and retain explicitly configured API bases.
  • Avoid an IndexError when the API key list is empty, allowing missing-key validation to be handled by the Anthropic provider.

Enhancements:

  • Default blank or unspecified MiniMax Token Plan models to MiniMax-M4 without modifying the caller’s provider configuration.
  • Use the Anthropic provider’s model discovery for the configured endpoint instead of a hardcoded MiniMax URL.

@wcqqq1214 wcqqq1214 changed the title feat: update MiniMax Token Plan default model to MiniMax-M4 fix(provider): update MiniMax Token Plan defaults and model discovery Dec 3, 2026
@wcqqq1214
wcqqq1214 force-pushed the feat/minimax-m4-default branch from 63efd78 to 57a8a51 Compare December 3, 2026 18:34
@wcqqq1214
wcqqq1214 marked this pull request as ready for review December 3, 2026 18:37

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and the provider now sends its Bearer token to api.minimax.cn by default and honors a configured api_base; if that host is wrong or untrusted, the token can be exposed externally. Reverting stops future requests but cannot undo exposure of a token already sent.

Blocking findings: astrbot/core/provider/sources/minimax_token_plan_source.py:33, astrbot/core/provider/sources/minimax_token_plan_source.py:43


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

provider_settings: Global provider settings mapping.
"""
merged_provider_config = dict(provider_config)
if not str(merged_provider_config.get("api_base") or "").strip():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Upgraded providers keep stale endpoint

When an existing installation has the previous default API base saved, the nonblank-value check preserves the saved https://api.minimaxi.com/anthropic value, so merged_provider_config and ProviderAnthropic keep sending chat and model-list requests to the old endpoint instead of the updated China endpoint; upgraded users do not receive the endpoint update.

Replace the saved value with the new endpoint when it matches the former default, while preserving custom API bases.

Also at astrbot/core/provider/sources/minimax_token_plan_source.py:34, astrbot/core/config/default.py:1423.

configured_model = provider_config.get("model", "MiniMax-M3")
self.set_model(configured_model)

async def get_models(self) -> list[str]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Model discovery stalls during outages

When the MiniMax model-list endpoint is slow or repeatedly times out, ProviderAnthropic.get_models() uses the SDK client timeout (120 seconds by default) and retries up to five times, so repeated timeouts can keep the model-list request waiting for over ten minutes before failing; the dashboard awaits this call without local timeout handling, leaving model discovery stalled instead of returning promptly.

Use a shorter model-discovery timeout or a smaller retry budget for this endpoint.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant