Skip to content

Add Reset in for rate limits - #4111

Merged
aibrahim-oai merged 4 commits into
mainfrom
reset-in
Sep 24, 2025
Merged

aibrahim-oai merged 4 commits into
mainfrom
reset-in

Conversation

@aibrahim-oai

@aibrahim-oai aibrahim-oai commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor
  • Parse the headers
  • Reorganize the struct because it's getting too long
  • show the resets at in the tui
image

@aibrahim-oai aibrahim-oai changed the title reset-in Add Reset in for rate limits Sep 23, 2025
@aibrahim-oai
aibrahim-oai marked this pull request as ready for review September 24, 2025 04:18
@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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.

let rate_limit_json = serde_json::to_value(&rate_limit_only).unwrap();
pretty_assertions::assert_eq!(
rate_limit_json,
json!({
"info": null,
"rate_limits": {
"primary_used_percent": 12.5,
"secondary_used_percent": 40.0,
"primary_to_secondary_ratio_percent": 75.0,
"primary_window_minutes": 10,
"secondary_window_minutes": 60
}

[P1] Update rate-limit event JSON expectation for new schema

The protocol changed RateLimitSnapshot to expose primary/secondary windows, but the first assertion in token_count_includes_rate_limits_snapshot still expects the old flat fields (primary_used_percent, primary_window_minutes, etc.). With the new struct, serde_json::to_value produces nested objects, so this assertion will now fail and the test suite will be red until it is updated to check the new shape.


let expected_limits = json!({
"primary_used_percent": 100.0,
"secondary_used_percent": 87.5,
"primary_to_secondary_ratio_percent": 95.0,
"primary_window_minutes": 15,
"secondary_window_minutes": 60

[P1] Adjust usage-limit error test fixture to nested rate-limit schema

The mock expected_limits JSON still uses the removed top-level keys such as primary_used_percent and primary_to_secondary_ratio_percent. After the protocol change these keys are no longer emitted; rate limits are now nested under primary/secondary windows with used_percent, window_minutes, and resets_in_seconds. Leaving the fixture unchanged will cause the usage-limit test to compare against a shape the code no longer produces.


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".

@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

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 thread codex-rs/core/src/client.rs Outdated
primary_window_minutes,
secondary_window_minutes,
})
let primary_used_percent = parse_header_f64(headers, "x-codex-primary-used-percent");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: you can make a function that takes 3 header names and parses a window

@aibrahim-oai
aibrahim-oai enabled auto-merge (squash) September 24, 2025 15:22
@aibrahim-oai
aibrahim-oai merged commit cb96f4f into main Sep 24, 2025
@aibrahim-oai
aibrahim-oai deleted the reset-in branch September 24, 2025 15:31
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 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