Skip to content

feat: support kimi coding plan monthly quota (limit_month_total/code) parsing, display, and 429 cooldown - #7856

Open
Randark-JMT wants to merge 1 commit into
Wei-Shaw:mainfrom
CRONUS-Mirror:copilot/update-api-usages-response
Open

Randark-JMT wants to merge 1 commit into
Wei-Shaw:mainfrom
CRONUS-Mirror:copilot/update-api-usages-response

Conversation

@Randark-JMT

Copy link
Copy Markdown
Contributor

This pull request adds comprehensive support for Kimi's new monthly plan quota reporting, including backend logic for parsing, evaluating, and snapshotting monthly quota tiers, as well as frontend display and testing. The changes ensure that monthly quota limits are correctly handled for both logic and UI, alongside existing 5h and weekly windows.

Backend: Kimi monthly quota support

  • Added parsing logic for Kimi's new monthly quota plan, extracting limit_month_total and limit_month_code from API responses, taking the higher usage ratio and the earlier reset time.
  • Updated threshold candidate selection and quota snapshot reset logic to include the monthly window, ensuring correct scheduling and cooldowns for accounts with only monthly quotas. [1] [2] [3]

Backend: Tests

  • Added and extended tests to cover monthly plan parsing, evaluation, and snapshot reset scenarios, ensuring correct handling when only monthly quotas are present or when all three windows exist. [1] [2] [3] [4]

Frontend: UI and tests

  • Updated the quota cell component to display monthly quota tiers with a distinct color (purple), matching the new backend logic, and added tests to verify correct rendering and color coding for monthly plans. [1] [2] [3] [4]

Documentation and comments

  • Improved inline documentation and comments throughout the code to clarify the handling of Kimi's old and new quota plans, the logic for choosing quota tiers, and the rationale for window selection. [1] [2]

These changes ensure robust, accurate handling and display of Kimi's quota plans, especially for the new monthly-based limits.

… parsing, display, and 429 cooldown

Co-authored-by: Randark-JMT <56223739+Randark-JMT@users.noreply.github.com>
@Randark-JMT

Copy link
Copy Markdown
Contributor Author

经过检查,CI 测试失败并非代码问题,而是 DNS 解析超时问题

@goransh-walia

Copy link
Copy Markdown

This looks good to me at a glance — thanks for putting it together.

@Randark-JMT

Copy link
Copy Markdown
Contributor Author

@Wei-Shaw Could you take a quick look when you have a moment? Thanks!

@davidche1116

Copy link
Copy Markdown

Thanks for working on Kimi monthly quotas. I reproduced the underlying issue on v0.2.18: the upstream /coding/v1/usages response contains usages.limit_month_total and limit_month_code, while the quota probe returns only the 5h tier. Existing monthly values in account extra remain stale even as kimi_usage_updated_at advances; the monthly row disappears after a manual probe replaces the frontend snapshot.

I am preparing a focused follow-up against current main, with parser, snapshot, scheduling and frontend regression coverage, crediting this PR. I will link it here so the work can be reused or incorporated into this PR; I am not asking for this PR to be closed.

I also inspected the failed CI job: TestValidateCreateParams_CheckModeMatrix/probe_requires_api_key expected CHANNEL_MONITOR_MISSING_API_KEY but got CHANNEL_MONITOR_ENDPOINT_UNREACHABLE (endpoint hostname could not be resolved). That failure is outside the Kimi parser, although a fresh full CI run is still needed after resolving the current merge conflicts.

@davidche1116

Copy link
Copy Markdown

The current-main follow-up is now available as #8347 (draft while CI is running), with attribution to this PR. It adds per-window legacy fallbacks, preserves the selected monthly window reset, and tests snapshot persistence plus manual UI refresh. Happy for the patch to be incorporated here instead if preferred. No request to close this PR.

@Randark-JMT

Copy link
Copy Markdown
Contributor Author

@davidche1116 I'm glad you noticed this PR and are willing to credit my contribution in yours! Based on my observation, Wei-Shaw seems to be using an automated AI agent to review PRs, which tends to ignore older ones. For my PR that has been pending for a long time, there seems to be little hope of getting noticed and reviewed by Wei-Shaw. I really hope your PR gets noticed and merged into the main branch!

Thanks again for leaving a comment on this PR!🤗

@davidche1116

Copy link
Copy Markdown

Thank you for the kind words, and especially for doing the original work on Kimi monthly quotas! Your PR helped identify the missing support, so crediting your contribution was the right thing to do. 🤗

The follow-up in #8347 is now ready for review. The full CI and security checks have passed in my fork on the exact PR commit, including backend unit and integration tests, and the CLA check has passed too. The upstream workflows are still awaiting maintainer approval.

I hope the updated patch and regression tests make it easier to review and get this support into an official release. Thanks again for laying the groundwork—happy to collaborate on any feedback that comes back!

hjkl950217 pushed a commit to hjkl950217/sub2api that referenced this pull request Nov 6, 2026
Support current usage ratios alongside per-window legacy fallbacks, preserve monthly reset semantics, and include Kimi monthly snapshots in existing scheduling checks. Add quota persistence and manual-refresh regressions. Follow-up to Wei-Shaw#7856.
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.

3 participants