Skip to content

Support additional rate limit categories in Codex usage#269

Merged
AnnatarHe merged 1 commit intomainfrom
claude/fix-codex-data-sync-RY5FY
Apr 7, 2026
Merged

Support additional rate limit categories in Codex usage#269
AnnatarHe merged 1 commit intomainfrom
claude/fix-codex-data-sync-RY5FY

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

@AnnatarHe AnnatarHe commented Apr 7, 2026

Summary

Extended the Codex rate limit handling to support additional rate limit categories beyond the primary rate_limit and code_review_rate_limit fields.

Key Changes

  • Added AdditionalRateLimits field to whamUsageResponse struct to capture additional rate limit categories from the backend API response
  • Updated struct field alignment for consistency
  • Extended fetchCodexUsage() to iterate through and process additional rate limit categories, mapping both primary and secondary windows for each category

Implementation Details

The new AdditionalRateLimits field is a map that allows the API response to include arbitrary additional rate limit categories. The code processes each category similarly to the existing rate limit categories, extracting primary and secondary windows and converting them to the internal CodexRateLimitData format using the existing mapWhamWindow() function.

https://claude.ai/code/session_017aLMXajKTAGqTgYimP7UXk


Open with Devin

The wham usage API can return additional rate limit categories via
the additional_rate_limits field which was previously ignored, causing
data loss during sync.

https://claude.ai/code/session_017aLMXajKTAGqTgYimP7UXk
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
daemon/codex_ratelimit.go 0.00% 7 Missing ⚠️
Flag Coverage Δ
unittests 40.04% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
daemon/codex_ratelimit.go 24.19% <0.00%> (-1.45%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the whamUsageResponse struct to include a map for additional rate limits and implements logic to process these limits in fetchCodexUsage. Feedback was provided to filter out keys that are already explicitly handled to prevent duplicate entries in the results and to note the non-deterministic nature of map iteration.

Comment thread daemon/codex_ratelimit.go
Comment on lines +234 to +244
for name, cat := range usage.AdditionalRateLimits {
if cat == nil {
continue
}
if w := cat.PrimaryWindow; w != nil {
windows = append(windows, mapWhamWindow(name, "primary", w))
}
if w := cat.SecondaryWindow; w != nil {
windows = append(windows, mapWhamWindow(name, "secondary", w))
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The iteration over AdditionalRateLimits does not check for potential key collisions with the explicitly handled fields (rate_limit and code_review_rate_limit). If the backend returns these keys within the additional_rate_limits map, it will result in duplicate entries in the windows slice with identical LimitIDs. Consider skipping these keys to ensure uniqueness. Additionally, note that map iteration in Go is non-deterministic, so the order of these additional windows in the slice will vary between calls.

	for name, cat := range usage.AdditionalRateLimits {
		if name == "rate_limit" || name == "code_review_rate_limit" {
			continue
		}
		if cat == nil {
			continue
		}
		if w := cat.PrimaryWindow; w != nil {
			windows = append(windows, mapWhamWindow(name, "primary", w))
		}
		if w := cat.SecondaryWindow; w != nil {
			windows = append(windows, mapWhamWindow(name, "secondary", w))
		}
	}

@AnnatarHe AnnatarHe merged commit be7aff6 into main Apr 7, 2026
5 of 6 checks passed
@AnnatarHe AnnatarHe deleted the claude/fix-codex-data-sync-RY5FY branch April 7, 2026 01:42
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.

2 participants