[#181]: Compat: parse rate_limits credit type and expiration (Codex v0.144.0)#187
Merged
Conversation
…en_count events Codex v0.144.0 (PR #30488) extended the rate_limits field on token_count event payloads with per-credit type and expiration information, and a selectable credit list. Add ResetCredit and RateLimitInfo structs and populate a new rate_limit_info field on CodexTurn from the rate_limits sibling field. Null/absent rate_limits are silently skipped for backward compatibility with pre-v0.144.0 sessions. Fixes #181
….144.0 Codex v0.144.0 (PR #30488) added type and expiration fields to the rate-limit reset credits array in token_count event payloads. Previously codex-trace parsed the token_count event but silently dropped rate_limits. Changes: - Add RateLimitCredit and RateLimitsInfo structs to turn.rs with serde support for the reserved-keyword 'type' field via #[serde(rename)] - Add rate_limits: Option<RateLimitsInfo> to TokenInfo struct - Parse rate_limits from token_count payload; null stays None (pre-v0.144.0 sessions remain fully compatible) - Add RateLimitCredit / RateLimitsInfo interfaces to shared/types.ts and add rate_limits: RateLimitsInfo | null to TokenInfo - Add 3 Rust tests: null rate_limits, two typed credits with expiration, and forward-compat tolerance of unknown extra fields - Fix TOKEN_INFO test fixtures in 3 frontend test files Fixes #181
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codex v0.144.0 (PR #30488) extended the
rate_limitsfield ontoken_countevent payloads with typed, expiring reset credits and a selectable credit list. Previously codex-trace ignored therate_limitssibling field entirely — this PR adds full parsing and type support.Changes
src-tauri/src/parser/turn.rsResetCreditstruct withcredit_type(#[serde(rename = "type")]sincetypeis a Rust keyword) andexpirationfields — bothOption<String>for backward compatRateLimitInfostruct withreset_at,reset_credits: Vec<ResetCredit>(#[serde(default)]so absent array defaults to empty), andselected_reset_credit: Option<ResetCredit>rate_limit_info: Option<RateLimitInfo>field toCodexTurntoken_counthandler inhandle_event_msgto extract therate_limitssibling from the payload;rate_limits: nulland absentrate_limitsare both silently skipped (backward compat with pre-v0.144.0 sessions)rate_limits: null, absentrate_limits, full v0.144.0 payload with typed/expiring credits and a selected credit, and minimal payload with onlyreset_atshared/types.tsResetCreditandRateLimitInfoTypeScript interfaces matching the Rust structsrate_limit_info?: RateLimitInfo | nulltoCodexTurn(optional, matching the versioned field pattern used bymemories?andtool_call_orders?)Backward compatibility
Pre-v0.144.0 sessions emit
rate_limits: nullor omit the field entirely. Both cases producerate_limit_info: None/undefinedin serialized output — no change to existing session data.Fixes #181