fix(minimax): handle CN percent-only quotas#531
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR extends the MiniMax provider to support percent-based usage reporting. When API responses lack count totals but provide a remaining-percentage field, the plugin converts that into used/total values and formats the output as a percent-based session line. ChangesMiniMax percent-based usage fallback
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/minimax/plugin.js (1)
247-257:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSelection can still pick a CN entry that formats to
limit: 0.Because
chosenstarts asmodelRemains[0], a first CN entry liketotal=3can survive selection even when it failsMath.round(total / 15) > 0. That bypasses percent fallback and later yieldslimit: 0in Line 397. Please avoid defaulting to the first row; select only a displayable-count candidate or a valid percent candidate.Proposed fix
- let chosen = modelRemains[0] + let chosen = null + let percentFallbackCandidate = null for (let i = 0; i < modelRemains.length; i += 1) { const item = modelRemains[i] if (!item || typeof item !== "object") continue const total = readNumber(item.current_interval_total_count ?? item.currentIntervalTotalCount) - if (total !== null && total > 0 && Math.round(total * displayMultiplierForSelection) > 0) { + if (total !== null && total > 0 && Math.round(total * displayMultiplierForSelection) > 0) { chosen = item break } + if (percentFallbackCandidate === null && (total === null || total <= 0)) { + const rp = readNumber( + item.current_interval_remaining_percent ?? item.currentIntervalRemainingPercent + ) + if (rp !== null && rp >= 0 && rp <= 100) percentFallbackCandidate = item + } } + if (!chosen) chosen = percentFallbackCandidate🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/minimax/plugin.js` around lines 247 - 257, The current selection logic defaults chosen to modelRemains[0], which can pick a CN entry that formats to limit: 0; change the algorithm in the block using displayMultiplierForSelection, modelRemains and readNumber so that chosen is not pre-seeded (initialize chosen = null) and only assigned when an item passes the displayable-count check (total !== null && Math.round(total * displayMultiplierForSelection) > 0); after the loop, if chosen is still null, fall back to the existing percent-selection path (the percent candidate logic) instead of using the first element, ensuring any chosen candidate yields a positive displayable count or a valid percent before it is used to compute limit.
🧹 Nitpick comments (1)
plugins/minimax/plugin.test.js (1)
928-962: ⚡ Quick winAdd a reversed-order variant to lock the selection behavior.
This test is good, but it only passes with the percent-capable row first. Add a sibling case with the
video(total=3) row first and percent row second to prevent reintroducinglimit: 0regressions from entry ordering.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/minimax/plugin.test.js` around lines 928 - 962, Add a sibling test that mirrors the existing "falls back to CN remaining percent when count totals are unavailable" case but with the model_remains array order reversed (place the "video" entry with total=3 first and the "general" percent-capable entry second) so selection logic is locked to content, not entry order; duplicate the existing it(...) test as a new it(...) with the same assertions (expect result.plan, lines[0].used, lines[0].limit, lines[0].format) and only change the mocked ctx.host.http.request.mockReturnValue bodyText to provide the reversed array to ensure the plugin.probe function (used via loadPlugin and plugin.probe(ctx)) still picks the percent-capable row and sets limit to 100.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/providers/minimax.md`:
- Line 68: Update the Output section in docs/providers/minimax.md to document
the percent-based Session format variant alongside the existing count-only
contract: describe the shape for the percent variant as format: { kind:
"percent" } with limit: 100, explain that progress lines may emit a percent when
totals are unavailable, and show how this maps to the Session output contract
(in addition to the existing count-based format) so readers can see both
formats.
---
Outside diff comments:
In `@plugins/minimax/plugin.js`:
- Around line 247-257: The current selection logic defaults chosen to
modelRemains[0], which can pick a CN entry that formats to limit: 0; change the
algorithm in the block using displayMultiplierForSelection, modelRemains and
readNumber so that chosen is not pre-seeded (initialize chosen = null) and only
assigned when an item passes the displayable-count check (total !== null &&
Math.round(total * displayMultiplierForSelection) > 0); after the loop, if
chosen is still null, fall back to the existing percent-selection path (the
percent candidate logic) instead of using the first element, ensuring any chosen
candidate yields a positive displayable count or a valid percent before it is
used to compute limit.
---
Nitpick comments:
In `@plugins/minimax/plugin.test.js`:
- Around line 928-962: Add a sibling test that mirrors the existing "falls back
to CN remaining percent when count totals are unavailable" case but with the
model_remains array order reversed (place the "video" entry with total=3 first
and the "general" percent-capable entry second) so selection logic is locked to
content, not entry order; duplicate the existing it(...) test as a new it(...)
with the same assertions (expect result.plan, lines[0].used, lines[0].limit,
lines[0].format) and only change the mocked
ctx.host.http.request.mockReturnValue bodyText to provide the reversed array to
ensure the plugin.probe function (used via loadPlugin and plugin.probe(ctx))
still picks the percent-capable row and sets limit to 100.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: eec562b1-5913-419e-b8a5-a9dd96b39a62
📒 Files selected for processing (3)
docs/providers/minimax.mdplugins/minimax/plugin.jsplugins/minimax/plugin.test.js
Summary
current_interval_total_countis0butcurrent_interval_remaining_percentis present0prompts after the model-call-to-prompt conversionProblem
Some MiniMax CN Coding Plan accounts return a usable percentage quota but no count total for the
generalmodel, for example:The existing plugin expects a positive
current_interval_total_count. For CN, small model-call totals can also round down to0prompts after dividing by 15. That produces a progress line withlimit: 0, which the runtime rejects with:Fix
When counts are unavailable but
current_interval_remaining_percentis valid, the MiniMax plugin now returns a percent progress line withlimit: 100. For the example above, the line renders asused: 6,limit: 100,format: { kind: "percent" }.Testing
npm install --no-package-locknpm exec vitest -- run plugins/minimax/plugin.test.jsSummary by cubic
Adds a percent-based fallback to the MiniMax CN plugin and avoids zero-limit progress lines by skipping CN totals that round to 0 prompts. This fixes rejected progress lines and shows accurate usage when only percentages are provided.
current_interval_total_countis0butcurrent_interval_remaining_percentexists.0prompts after the model-call→prompt conversion and prefer thegeneralmodel when only percent data is available.Written for commit ea42413. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation
Tests