Skip to content

[#181]: Compat: parse rate_limits credit type and expiration (Codex v0.144.0)#187

Merged
delexw merged 3 commits into
mainfrom
fix-issue-181
Jul 14, 2026
Merged

[#181]: Compat: parse rate_limits credit type and expiration (Codex v0.144.0)#187
delexw merged 3 commits into
mainfrom
fix-issue-181

Conversation

@delexw

@delexw delexw commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Codex v0.144.0 (PR #30488) extended the rate_limits field on token_count event payloads with typed, expiring reset credits and a selectable credit list. Previously codex-trace ignored the rate_limits sibling field entirely — this PR adds full parsing and type support.

Changes

src-tauri/src/parser/turn.rs

  • Added ResetCredit struct with credit_type (#[serde(rename = "type")] since type is a Rust keyword) and expiration fields — both Option<String> for backward compat
  • Added RateLimitInfo struct with reset_at, reset_credits: Vec<ResetCredit> (#[serde(default)] so absent array defaults to empty), and selected_reset_credit: Option<ResetCredit>
  • Added rate_limit_info: Option<RateLimitInfo> field to CodexTurn
  • Updated token_count handler in handle_event_msg to extract the rate_limits sibling from the payload; rate_limits: null and absent rate_limits are both silently skipped (backward compat with pre-v0.144.0 sessions)
  • Added 4 new unit tests covering: rate_limits: null, absent rate_limits, full v0.144.0 payload with typed/expiring credits and a selected credit, and minimal payload with only reset_at

shared/types.ts

  • Added ResetCredit and RateLimitInfo TypeScript interfaces matching the Rust structs
  • Added rate_limit_info?: RateLimitInfo | null to CodexTurn (optional, matching the versioned field pattern used by memories? and tool_call_orders?)

Backward compatibility

Pre-v0.144.0 sessions emit rate_limits: null or omit the field entirely. Both cases produce rate_limit_info: None / undefined in serialized output — no change to existing session data.

Fixes #181

delexw added 2 commits July 12, 2026 11:08
…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
@delexw
delexw merged commit 00d65f0 into main Jul 14, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compat] Codex v0.144.0: usage-limit reset credits gain type/expiration fields in rate-limit data

2 participants