Skip to content

Display workspace usage limit error copy from response header#24114

Merged
dhruvgupta-oai merged 4 commits into
mainfrom
dev/dhruvgupta/usage-limit-type-error-copy
May 22, 2026
Merged

Display workspace usage limit error copy from response header#24114
dhruvgupta-oai merged 4 commits into
mainfrom
dev/dhruvgupta/usage-limit-type-error-copy

Conversation

@dhruvgupta-oai
Copy link
Copy Markdown
Contributor

@dhruvgupta-oai dhruvgupta-oai commented May 22, 2026

Why

openai/openai#947613 adds X-Codex-Rate-Limit-Reached-Type for Codex workspace credit-depletion and spend-cap responses. The CLI currently reads the adjacent promo header but otherwise renders generic usage-limit copy, so those responses do not explain the workspace-specific action the user needs to take.

Backend dependency: https://github.com/openai/openai/pull/947613

What Changed

  • Parse X-Codex-Rate-Limit-Reached-Type in the usage-limit error handling path alongside x-codex-promo-message.
  • Keep the header value parsing with the shared RateLimitReachedType enum.
  • Carry the parsed type on UsageLimitReachedError and render client-owned copy for the four workspace owner/member credit and spend-cap values.
  • Preserve existing promo and plan-based text for absent, generic, or unknown header values.
  • Keep the existing TUI workspace-owner nudge state path unchanged; the response header only selects the displayed error string.
  • Add focused display coverage for all specific type values and the generic fallback case.

Test Plan

  • Added usage_limit_reached_error_formats_rate_limit_reached_types coverage.
  • Not run manually, per request; CI runs validation on the pushed commit.

Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

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

Reviewed only the code, didn't run any smoke tests.

The code looks good, but added 2 nitpicks and one request for additional test coverage, but not blockers.

Comment thread codex-rs/protocol/src/error.rs Outdated
Comment thread codex-rs/codex-api/src/rate_limits.rs Outdated
Comment thread codex-rs/protocol/src/error_tests.rs
@dhruvgupta-oai dhruvgupta-oai enabled auto-merge (squash) May 22, 2026 23:19
@dhruvgupta-oai dhruvgupta-oai merged commit 4bcabbf into main May 22, 2026
46 of 47 checks passed
@dhruvgupta-oai dhruvgupta-oai deleted the dev/dhruvgupta/usage-limit-type-error-copy branch May 22, 2026 23:58
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
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