Repository navigation
Keep Grok weekly credits window on zero-usage weeks #998
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -273,6 +273,37 @@ impl GrokProvider { | |
| } | ||
| } | ||
|
|
||
| /// Bounded grok.com percent for a wallet-only ACP answer (upstream #4679). | ||
| /// The ACP period, plan and prepaid balance stay authoritative. Only a | ||
| /// wire-published percent or a validated implicit zero is adopted. Expired | ||
| /// credentials and failed or slow enrichment keep the wallet with usage unknown. | ||
| pub(super) async fn resolve_cli_unknown_usage( | ||
| &self, | ||
| answer: BearerBilling, | ||
| credentials: &GrokCredentials, | ||
| ) -> BearerBilling { | ||
| if answer.billing.used_percent.is_some() || credentials.is_expired(Utc::now()) { | ||
| return answer; | ||
| } | ||
| let authorization = format!("Bearer {}", credentials.access_token); | ||
| match tokio::time::timeout( | ||
| PERCENT_RETRY_TIMEOUT, | ||
| self.fetch_billing(Some(authorization), None), | ||
| ) | ||
| .await | ||
| { | ||
| Ok(Ok(grpc)) => adopt_grpc_percent(answer, grpc), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis
Require an active, matching period before adopting an implicit zero.
🤖 Prompt for AI Agents
|
||
| Ok(Err(error)) => { | ||
| tracing::debug!("Grok ACP percent enrichment failed: {error}"); | ||
| answer | ||
| } | ||
| Err(_) => { | ||
| tracing::debug!("Grok ACP percent enrichment timed out"); | ||
| answer | ||
| } | ||
| } | ||
| } | ||
|
|
||
| async fn fetch_credits_proxy( | ||
| &self, | ||
| authorization: &str, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.