Skip to content

fix: improve MiniMax token plan inference#317

Open
FrankieeW wants to merge 5 commits intorobinebers:mainfrom
FrankieeW:feat/minimax-plugin-refresh
Open

fix: improve MiniMax token plan inference#317
FrankieeW wants to merge 5 commits intorobinebers:mainfrom
FrankieeW:feat/minimax-plugin-refresh

Conversation

@FrankieeW
Copy link
Copy Markdown
Contributor

@FrankieeW FrankieeW commented Mar 23, 2026

Description

  • align the MiniMax plugin with current Token Plan remains payloads for both Global and CN
  • infer exact Plus-High-Speed / Max-High-Speed plans from companion quotas like image-01 and speech-hd when present
  • remove prompt-based plan inference entirely and rely only on raw model-calls plus companion resource buckets
  • normalize CN extra resource buckets such as speech-hd, Text to Speech Turbo, and Image Generation
  • document the current MiniMax mapping and add regression coverage for the new inference paths

Related Issue

N/A

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I ran bun run test:coverage and coverage thresholds pass
  • I tested the change locally with bun tauri dev

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary by cubic

Fix MiniMax plan detection and usage display by showing raw model-calls and preferring session entries for GLOBAL. Also infer High-Speed tiers from companion quotas and render TTS/image resource buckets in both GLOBAL and CN.

  • Bug Fixes

    • Align to current remains payloads for GLOBAL and CN; switch CN primary endpoint to https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains with fallbacks.
    • Normalize plan names to six tiers (Starter, Plus, Max, Plus-High-Speed, Max-High-Speed, Ultra-High-Speed); infer Plus/Max High-Speed from image-01 and speech-hd quotas; fallback to Plus/Max on conflicts.
    • Show Session as model-calls; prefer the session entry in GLOBAL remains.
    • Render extra resource lines in both regions: Text to Speech HD, Text to Speech Turbo, Image Generation, and image-01; use daily windows when only remains_time is present.
    • Improve reset logic (prefer end_time, fallback to remains_time, handle ms/seconds, tolerate overflows); clamp used counts and accept camelCase fields; update plugin schema for new lines.
  • Documentation

    • Update MiniMax docs with model-calls display, region endpoints, six-tier plan mapping, companion resource lines for GLOBAL and CN, and overview-vs-detail window behavior; tweak README to reflect CN TTS/image buckets.
    • Add tests for plan inference (including High-Speed hints), GLOBAL companion resource lines and session selection, endpoint fallbacks, and time handling.

Written for commit 4ce20ed. Summary will update on new commits.

@FrankieeW
Copy link
Copy Markdown
Contributor Author

Screenshot

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Mar 23, 2026

🤖 Augment PR Summary

Summary: Updates the MiniMax provider to infer token-plan tiers from the latest remains payloads without relying on prompt-based heuristics.

Changes:

  • Aligns GLOBAL/CN endpoints with current docs and expands CN fallbacks
  • Switches the main Session metric to raw model-calls counts from the remains API
  • Infers exact Plus-High-Speed/Max-High-Speed tiers using companion quotas (e.g. image-01, speech-hd)
  • Normalizes plan labels (including CN “极速版”) to a shared six-plan naming scheme
  • Adds CN detail lines for TTS and image buckets and expands regression test coverage

Technical Notes: Parsing now supports multiple model_remains entries, clamps used/total, and derives resets from end_time or remains_time where available.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

if (seenLabels[entry.label]) continue
seenLabels[entry.label] = true
entries.push(entry)
if (endpointSelection !== "CN") break
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For GLOBAL, breaking after the first parsed model_remains entry can accidentally treat a companion bucket (e.g. image-01/speech) as the Session line if it appears first, which would display incorrect usage/limits. Consider selecting the session entry (via name classification) before falling back to “first usable entry”.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


const plugin = await loadPlugin()
const result = plugin.probe(ctx)
const line = result.lines[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test no longer asserts used/limit even though it’s meant to validate camelCase modelRemains plus explicit used-count fields; that reduces regression coverage for the parsing logic. Consider adding assertions for line.used and line.limit here as well.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97cfb6de65

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const endMs = epochToMs(item.end_time ?? item.endTime)
const remainsRaw = readNumber(item.remains_time ?? item.remainsTime)
const nowMs = Date.now()
const remainsMs = inferRemainsMs(remainsRaw, endMs, nowMs)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Infer CN resource remains_time with a daily window

For non-session CN resource lines, periodDurationMs is set to 24h, but resetsAt still uses inferRemainsMs’s 5-hour coding-plan heuristic. When the API returns only remains_time (for example 86400 seconds on speech-hd/image-01) and omits end_time, this path interprets the value as milliseconds and sets reset ~86 seconds ahead instead of ~24 hours, which breaks reset display and pace calculations for those lines.

Useful? React with 👍 / 👎.

Comment on lines +229 to +230
if (endpointSelection !== "CN") {
return { label: "Session", suffix: MODEL_CALLS_SUFFIX, isSession: true }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Select GLOBAL session bucket before labeling as Session

In GLOBAL mode, every usage entry is unconditionally classified as Session, and parsing stops after the first valid entry. If companion quotas (like speech-hd or image-01) appear before the actual text-session quota in model_remains, the plugin reports the companion bucket as the Session progress line, producing incorrect usage/limit values and potentially conflicting with plan inference.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/minimax/plugin.js">

<violation number="1" location="plugins/minimax/plugin.js:502">
P2: For GLOBAL mode, the loop breaks after the first valid `model_remains` entry, and `classifyUsageEntry` unconditionally labels every GLOBAL entry as `"Session"`. If the API returns a companion bucket (e.g. `image-01` with limit 100) before the actual text-model entry (limit 4500), it will be displayed as the Session line with wrong usage/limits. Consider selecting the entry whose name matches a session classifier (e.g. `isSessionUsageName`) before falling back to the first usable entry.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@FrankieeW
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ce20ed9ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the MiniMax provider plugin to align with current “Token Plan remains” payloads (GLOBAL + CN), removing prompt-based inference and improving plan/usage rendering based on raw model_remains plus companion resource buckets.

Changes:

  • Refactors MiniMax usage parsing to display raw model-calls, infer the 6-tier plan naming (including High-Speed tiers) using companion quotas (e.g., image-01, speech-hd), and normalize CN resource buckets.
  • Updates the MiniMax manifest to declare new detail lines (TTS HD/Turbo, Image Generation, image-01).
  • Expands MiniMax regression tests and updates provider documentation/README to reflect the new mapping and endpoints.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md Updates the MiniMax supported-provider summary text to reflect model-calls + CN buckets.
plugins/minimax/plugin.js Implements new endpoint fallbacks, raw model-call display, multi-line resource parsing, and plan inference using companion quota signals.
plugins/minimax/plugin.json Adds detail line definitions for TTS/image companion buckets.
plugins/minimax/plugin.test.js Adds extensive coverage for new inference, endpoint fallback order, resource lines, and time handling.
docs/providers/minimax.md Documents updated endpoints, raw model-call display, 6-tier normalization, and companion bucket behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- [**JetBrains AI Assistant**](docs/providers/jetbrains-ai-assistant.md) / quota, remaining
- [**Kimi Code**](docs/providers/kimi.md) / session, weekly
- [**MiniMax**](docs/providers/minimax.md) / coding plan session
- [**MiniMax**](docs/providers/minimax.md) / coding plan session model-calls, CN TTS/image buckets
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The provider summary text reads a bit ambiguously (“coding plan session model-calls…”). Consider adding punctuation (e.g., a comma after “session”) so the list of metrics matches the style of the other provider entries and is easier to scan.

Suggested change
- [**MiniMax**](docs/providers/minimax.md) / coding plan session model-calls, CN TTS/image buckets
- [**MiniMax**](docs/providers/minimax.md) / coding plan session, model-calls, CN TTS/image buckets

Copilot uses AI. Check for mistakes.
@@ -99,7 +274,8 @@
}

// Coding Plan resets every 5h. Use that constraint before defaulting.
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The comment above this logic still says the Coding Plan resets every 5h, but inferRemainsMs is now also used for daily companion buckets via expectedWindowMs. Update the comment to reflect that the window is parameterized (coding-plan vs daily) to avoid misleading future maintenance.

Suggested change
// Coding Plan resets every 5h. Use that constraint before defaulting.
// Use the expected window (e.g. daily or Coding Plan's 5h default) as a constraint before defaulting.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants