fix: improve MiniMax token plan inference#317
fix: improve MiniMax token plan inference#317FrankieeW wants to merge 5 commits intorobinebers:mainfrom
Conversation
🤖 Augment PR SummarySummary: Updates the MiniMax provider to infer token-plan tiers from the latest remains payloads without relying on prompt-based heuristics. Changes:
Technical Notes: Parsing now supports multiple 🤖 Was this summary useful? React with 👍 or 👎 |
plugins/minimax/plugin.js
Outdated
| if (seenLabels[entry.label]) continue | ||
| seenLabels[entry.label] = true | ||
| entries.push(entry) | ||
| if (endpointSelection !== "CN") break |
There was a problem hiding this comment.
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
🤖 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] |
There was a problem hiding this comment.
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
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
💡 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".
plugins/minimax/plugin.js
Outdated
| 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) |
There was a problem hiding this comment.
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 👍 / 👎.
plugins/minimax/plugin.js
Outdated
| if (endpointSelection !== "CN") { | ||
| return { label: "Session", suffix: MODEL_CALLS_SUFFIX, isSession: true } |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| - [**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 |
| @@ -99,7 +274,8 @@ | |||
| } | |||
|
|
|||
| // Coding Plan resets every 5h. Use that constraint before defaulting. | |||
There was a problem hiding this comment.
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.
| // 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. |

Description
Plus-High-Speed/Max-High-Speedplans from companion quotas likeimage-01andspeech-hdwhen presentmodel-callsplus companion resource bucketsspeech-hd,Text to Speech Turbo, andImage GenerationRelated Issue
N/A
Type of Change
Testing
bun run buildand it succeededbun run testand all tests passbun run test:coverageand coverage thresholds passbun tauri devChecklist
mainbranchSummary 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
image-01andspeech-hdquotas; fallback to Plus/Max on conflicts.Sessionasmodel-calls; prefer the session entry in GLOBAL remains.Text to Speech HD,Text to Speech Turbo,Image Generation, andimage-01; use daily windows when onlyremains_timeis present.end_time, fallback toremains_time, handle ms/seconds, tolerate overflows); clamp used counts and accept camelCase fields; update plugin schema for new lines.Documentation
Written for commit 4ce20ed. Summary will update on new commits.