-
-
Notifications
You must be signed in to change notification settings - Fork 626
Background Quota Refresh & Automated Token Management #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…viders - Added quota fetching endpoints in management handler. - Introduced quota manager to orchestrate fetching and caching of quota data. - Implemented Antigravity and Codex quota fetchers to retrieve usage information. - Created caching mechanism for quota data to improve performance. - Added types and structures for handling quota responses and subscription information. - Implemented refresh functionality for quota data to ensure up-to-date information.
…viders in quota management
…lity for Antigravity and Codex providers
… timestamps for quota responses
Summary of ChangesHello @dacsang97, 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 significantly enhances the quota management system by introducing automation for both data refreshing and authentication. It establishes a background worker to periodically update quota information across all providers, ensuring data is always current without manual intervention. Concurrently, it implements an intelligent OAuth token refresh mechanism for Antigravity and Codex providers, preventing service disruptions caused by expired access tokens. These changes aim to improve the reliability and efficiency of quota reporting, providing users with up-to-date and accurate usage statistics. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 introduces a significant and well-structured feature for background quota refreshing and automated token management. The implementation of the background worker, caching layer, and provider-specific fetchers is robust. The automatic token refresh for expired OAuth credentials is a great enhancement that will improve reliability.
My review includes a few key points:
- A critical security concern regarding hardcoded OAuth client secrets.
- A high-severity issue with a hardcoded client ID.
- A few medium-severity issues related to API correctness and potential bugs in the caching and request handling logic.
Overall, this is a solid contribution. Addressing the feedback will further improve the security and correctness of the new quota management system.
…gic to track latest timestamps
Overview
This pull request introduces a robust background worker for periodic quota refreshing and enhances the authentication handling within the quota management system. These changes eliminate the need for manual API calls to update quota data and resolve authentication failures caused by expired OAuth tokens. It also exposes several management API endpoints for monitoring and controlling quotas.
Key Changes
1. Quota Management API (
internal/api/handlers/management/quota_fetchers.go)Exposed new management endpoints to interact with the quota system:
GET /v0/management/quotas: Retrieves quota data for all connected accounts across all providers.GET /v0/management/quotas/:provider: Filters and returns quota data for a specific provider.GET /v0/management/quotas/:provider/:account: Fetches detailed quota information for a specific account identifier (e.g., email).POST /v0/management/quotas/refresh: Invalidate cache and force an immediate refresh of quota data. Supports an optional JSON body{"providers": ["antigravity"]}to limit the scope.GET /v0/management/subscription-info: Provides subscription tier and project details for supported providers (Antigravity/Gemini-CLI).2. Background Quota Refresh Worker
Workersystem ininternal/quota/worker.gothat periodically fetches quota data for all configured providers in the background.quota-refresh-interval(seconds) setting inconfig.yaml.3. Automated OAuth Token Refresh
antigravity.goandcodex.goto proactively check for token expiration.refresh_tokencredentials before attempting to fetch quota data, resolving previous 401 UNAUTHENTICATED errors.4. Cache & Timestamp Consistency
QuotaCacheTTL is now automatically adjusted to match the background refresh interval (plus a 10% safety buffer).last_updated: Refactored the response logic to ensure thelast_updatedtimestamp reflects the time the data was actually fetched from the upstream provider (the cached time) rather than the timestamp of the API request.Verification
last_updatedtimestamps.