Skip to content

Conversation

@owenlin0
Copy link
Contributor

@owenlin0 owenlin0 commented Oct 17, 2025

Adds a GET account/rateLimits/read API to app-server. This calls the codex backend to fetch the user's current rate limits.

This would be helpful in checking rate limits without having to send a message.

For calling the codex backend usage API, I generated the types and manually copied the relevant ones into codex-backend-openapi-types. It'll be nice to extend our internal openapi generator to support Rust so we don't have to run these manual steps.

External (non-OpenAI) Pull Request Requirements

Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed:
https://github.com/openai/codex/blob/main/docs/contributing.md

If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes.

@github-actions
Copy link

github-actions bot commented Oct 17, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@owenlin0
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@owenlin0 owenlin0 force-pushed the owen/rate_limit_api branch from b72858c to e19f662 Compare October 17, 2025 23:19
github-actions bot added a commit that referenced this pull request Oct 17, 2025
@owenlin0 owenlin0 force-pushed the owen/rate_limit_api branch 5 times, most recently from 20a6979 to 9665d21 Compare October 19, 2025 04:13
@owenlin0 owenlin0 marked this pull request as ready for review October 19, 2025 16:21
@owenlin0 owenlin0 force-pushed the owen/rate_limit_api branch from 9665d21 to b4aec26 Compare October 20, 2025 15:32
}

async fn fetch_account_rate_limits(&self) -> Result<RateLimitSnapshot, JSONRPCErrorError> {
let Some(auth) = self.auth_manager.auth() else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have some helper for internal errors? We use them quite a lot and they are verbose.

Copy link
Contributor Author

@owenlin0 owenlin0 Oct 20, 2025

Choose a reason for hiding this comment

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

Copy link
Collaborator

@pakrym-oai pakrym-oai left a comment

Choose a reason for hiding this comment

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

few nits, not blocking and some might be outside of this change's context

std::fs::write(config_toml, format!("chatgpt_base_url = \"{base_url}\"\n"))
}

fn write_chatgpt_auth(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a lot of boilerplate unrelated to the feature, can we bump it into a shared helper? Do other tests do the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created an auth_fixtures.rs helper file as an immediate step, but also will tackle a broader cleanup later: https://linear.app/openai/issue/CLI-862/app-server-fix-boilerplate-in-integration-tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems like integration tests in app-server are pretty boilerplatey in general, so will have a refactor-focused PR

@owenlin0 owenlin0 force-pushed the owen/rate_limit_api branch from e0700b4 to 93bf412 Compare October 20, 2025 19:30
@owenlin0 owenlin0 merged commit 5c680c6 into main Oct 20, 2025
20 checks passed
@owenlin0 owenlin0 deleted the owen/rate_limit_api branch October 20, 2025 21:11
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 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