-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Rate limits warning #4075
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
Rate limits warning #4075
Conversation
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.
Codex Review: Here are some suggestions.
Reply with @codex fix comments
to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
) -> Vec<String> { | ||
let mut warnings = Vec::new(); | ||
|
||
let mut highest_secondary: Option<f64> = None; | ||
while self.secondary_index < RATE_LIMIT_WARNING_THRESHOLDS.len() | ||
&& secondary_used_percent >= RATE_LIMIT_WARNING_THRESHOLDS[self.secondary_index] | ||
{ | ||
let threshold = RATE_LIMIT_WARNING_THRESHOLDS[self.secondary_index]; | ||
highest_secondary = Some(RATE_LIMIT_WARNING_THRESHOLDS[self.secondary_index]); | ||
self.secondary_index += 1; | ||
} | ||
if let Some(threshold) = highest_secondary { | ||
warnings.push(format!( | ||
"Heads up, you've used over {threshold:.0}% of your weekly limit. Run /status for a breakdown." | ||
)); | ||
self.secondary_index += 1; | ||
} | ||
|
||
let mut highest_primary: Option<f64> = None; | ||
while self.primary_index < RATE_LIMIT_WARNING_THRESHOLDS.len() | ||
&& primary_used_percent >= RATE_LIMIT_WARNING_THRESHOLDS[self.primary_index] | ||
{ | ||
let threshold = RATE_LIMIT_WARNING_THRESHOLDS[self.primary_index]; | ||
highest_primary = Some(RATE_LIMIT_WARNING_THRESHOLDS[self.primary_index]); | ||
self.primary_index += 1; | ||
} | ||
if let Some(threshold) = highest_primary { | ||
warnings.push(format!( | ||
"Heads up, you've used over {threshold:.0}% of your 5h limit. Run /status for a breakdown." |
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.
[P1] Update rate limit tests for new thresholds
The new thresholds [75.0, 90.0, 95.0]
and the logic that emits only the highest crossed threshold mean RateLimitWarningState::take_warnings
will now generate at most four warnings for the sequence used in rate_limit_warnings_emit_thresholds
, and none will mention 50%. That test still asserts six warnings and checks for messages containing "over 50%", so it will fail after this change. Please update the test expectations to match the new thresholds and one‑per‑call behaviour, otherwise CI will remain red.
Useful? React with 👍 / 👎.
Only show the highest warning rate.
Change the warning threshold