[codex] Thread backend-selected near-limit prompt payload through rate limits#20937
[codex] Thread backend-selected near-limit prompt payload through rate limits#20937jchu-oai wants to merge 2 commits into
Conversation
dhruvgupta-oai
left a comment
There was a problem hiding this comment.
itd be good to put this behind a gate just in case
| credits, | ||
| plan_type: None, | ||
| rate_limit_reached_type: None, | ||
| current_usage_limit_nudge: None, |
There was a problem hiding this comment.
Codex review: The notification path is still fed by token-count rate-limit snapshots from response headers/SSE events, and those parsers explicitly set current_usage_limit_nudge: None. account/rateLimits/read fetches /wham/usage and returns the nudge directly, but it does not update the session state used by AccountRateLimitsUpdatedNotification, so the new notification field will remain null in normal backend-selected nudge flow.
There was a problem hiding this comment.
Yep, that’s intentional in the final shape. Live rate-limit notifications are only a coarse freshness signal - /usage is the authoritative source for current_usage_limit_nudge. The stacked TUI PR uses the live update to trigger a bounded /usage refresh rather than reading prompt state from the notification itself. This matches the existing partial-snapshot pattern for fields like rate_limit_reached_type.
| #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] | ||
| pub enum UsageLimitNudgeAction { | ||
| #[serde(rename = "add_credits")] | ||
| AddCredits, | ||
| #[serde(rename = "upgrade")] | ||
| Upgrade, |
There was a problem hiding this comment.
Codex review: The PR says unsupported prompt payloads fail closed, but this generated enum has no #[serde(other)]/unknown variant. If the backend returns a new current_usage_limit_nudge.action, serde_json::from_str::<RateLimitStatusPayload> fails in get_rate_limits_many, so account/rateLimits/read returns an error instead of dropping only the unsupported nudge. Make the backend model/action mapping tolerate unknown actions and map them to None.
Summary