Skip to content

Conversation

aibrahim-oai
Copy link
Collaborator

Only show the highest warning rate.
Change the warning threshold

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines 127 to 152
) -> 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."
Copy link
Contributor

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 👍 / 👎.

@aibrahim-oai aibrahim-oai merged commit 664ee07 into main Sep 23, 2025
19 checks passed
@aibrahim-oai aibrahim-oai deleted the warning-edits branch September 23, 2025 16:15
@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants