Skip to content

Comments

fix(nanogpt): track monthly requests + weekly input tokens, drop daily quota#35

Merged
b3nw merged 2 commits intodevfrom
fix/nanogpt-weekly-token-quota
Feb 18, 2026
Merged

fix(nanogpt): track monthly requests + weekly input tokens, drop daily quota#35
b3nw merged 2 commits intodevfrom
fix/nanogpt-weekly-token-quota

Conversation

@b3nw
Copy link
Owner

@b3nw b3nw commented Feb 18, 2026

  • Parse new weeklyInputTokens quota from /api/subscription/v1/usage response
  • Add weekly_tokens quota group replacing the old daily group
  • Background job now pushes baselines for _monthly and _weekly_tokens
  • Fix get_remaining_fraction to use monthly as primary axis (daily was never enforced for this account: enforceDailyLimit=false)
  • Add get_weekly_token_reset_timestamp() helper on the tracker mixin
  • Parse new allowOverage field from API response

…y quota

- Parse new weeklyInputTokens quota from /api/subscription/v1/usage response
- Add weekly_tokens quota group replacing the old daily group
- Background job now pushes baselines for _monthly and _weekly_tokens
- Fix get_remaining_fraction to use monthly as primary axis (daily was
  never enforced for this account: enforceDailyLimit=false)
- Add get_weekly_token_reset_timestamp() helper on the tracker mixin
- Parse new allowOverage field from API response
@gemini-code-assist
Copy link

Summary of Changes

Hello @b3nw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the NanoGPT quota tracking system to align with recent changes in the subscription usage API. It shifts the focus from daily request limits to a more relevant weekly input token limit, while also clarifying the enforcement of monthly request limits. These changes improve the accuracy and flexibility of quota management by incorporating new API data points and refining how remaining quota fractions are calculated and reported.

Highlights

  • Quota Group Update: The daily quota group has been removed and a new weekly_tokens quota group has been introduced to track weekly input tokens for NanoGPT.
  • API Response Parsing: The system now parses new fields from the /api/subscription/v1/usage response, specifically weeklyInputTokens and allowOverage.
  • Quota Baseline Tracking: The background job responsible for updating quota baselines now pushes data for _monthly requests and the new _weekly_tokens, discontinuing _daily tracking.
  • Remaining Quota Calculation Logic: The get_remaining_fraction function has been refactored to use the monthly limit as the primary enforcement axis, with daily limits only considered if enforceDailyLimit is true.
  • Weekly Token Reset Timestamp: A new helper function, get_weekly_token_reset_timestamp(), has been added to retrieve the reset time for the weekly token quota.
Changelog
  • src/rotator_library/providers/nanogpt_provider.py
    • Removed the 'daily' quota group and added 'weekly_tokens' to model_quota_groups.
    • Updated comments to reflect the new quota types: monthly requests and weekly input tokens.
    • Modified get_model_quota_group to return 'weekly_tokens' for _weekly_tokens and clarified that real models belong to 'monthly'.
    • Adjusted get_models_in_quota_group to return _weekly_tokens for the 'weekly_tokens' group and updated comments for 'monthly'.
    • Updated get_quota_groups to list 'monthly' and 'weekly_tokens'.
    • Refactored refresh_single_credential to remove daily quota processing, calculate and store weekly token quota baselines, and update debug logging.
  • src/rotator_library/providers/utilities/nanogpt_quota_tracker.py
    • Updated the fetch_subscription_usage return type schema to include allow_overage, enforce_daily_limit, and weekly_input_tokens.
    • Added logic to parse weeklyInputTokens from the raw API response and include it in the structured output.
    • Modified the error return structures to include default values for allow_overage, enforce_daily_limit, and weekly_input_tokens.
    • Revised get_remaining_fraction to calculate the minimum remaining fraction based on monthly limits (always enforced) and daily limits (conditionally enforced).
    • Changed get_reset_timestamp to return the monthly reset timestamp instead of daily.
    • Introduced get_weekly_token_reset_timestamp to retrieve the reset time for the weekly token quota.
Activity
  • No human activity has been recorded for this pull request since its creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the NanoGPT provider to align with new API quota changes, replacing the daily quota with a weekly input token quota and tracking monthly requests. The changes are well-implemented across the provider and its utility tracker, including updates to quota groups, API response parsing, and quota calculation logic. I've suggested a couple of minor simplifications to the quota usage calculation for improved readability. Overall, this is a solid update that correctly reflects the new quota system.

@b3nw b3nw merged commit 3a0fc80 into dev Feb 18, 2026
@kiloconnect
Copy link

kiloconnect bot commented Feb 18, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0

Notes

The existing inline comments from the previous review (suggesting simplifications to monthly_used and weekly_token_used calculations) have already been addressed in the current code - the calculations are now using the simplified direct subtraction approach.

Files Reviewed (2 files)
  • src/rotator_library/providers/nanogpt_provider.py
  • src/rotator_library/providers/utilities/nanogpt_quota_tracker.py
Other Observations (not in diff)

The following issues exist in unchanged code and cannot receive inline comments:

File Line Issue
src/rotator_library/providers/nanogpt_provider.py 18 Module docstring still references "daily/monthly usage pool" - should be updated to reflect new weekly tokens tracking
src/rotator_library/providers/nanogpt_provider.py 326-331 _refresh_tier_from_api method still logs daily quota data - should be updated to reflect new monthly/weekly_tokens tracking

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