Skip to content

Fix persistent 429 on usage endpoint by sending claude-code User-Agent - #34

Open
bubbabright wants to merge 1 commit into
Haletran:mainfrom
bubbabright:fix/oauth-usage-429-user-agent
Open

Fix persistent 429 on usage endpoint by sending claude-code User-Agent#34
bubbabright wants to merge 1 commit into
Haletran:mainfrom
bubbabright:fix/oauth-usage-429-user-agent

Conversation

@bubbabright

Copy link
Copy Markdown

Problem

The /api/oauth/usage endpoint places requests without a claude-code User-Agent into an aggressively rate-limited bucket that returns HTTP 429 regardless of poll interval, and does not recover for the rest of the session. In this extension that surfaces as a permanent Error / HTTP 429 in the panel, making usage monitoring unusable.

This is a known upstream issue affecting every third-party tool that polls this endpoint:

Fix

Add a User-Agent: claude-code/<version> header to the usage request. This moves the request into the normal rate-limit bucket and the endpoint returns usage data as expected.

Testing

Verified directly against the live endpoint:

# Without User-Agent → HTTP 429 (retry-after up to ~1600s), persists
# With    User-Agent → HTTP 200 + usage JSON (or a real 401 if the token
#                       is genuinely expired, instead of a masked 429)

Single-line behavioral change plus an explanatory comment; no other files touched.

🤖 Generated with Claude Code

The /api/oauth/usage endpoint places requests without a claude-code
User-Agent into an aggressively rate-limited bucket that returns HTTP 429
regardless of poll interval, and does not recover for the rest of the
session. This makes the extension show "Error / HTTP 429" indefinitely.

Adding a `User-Agent: claude-code/<version>` header moves requests into
the normal bucket and the endpoint returns usage data as expected.

Refs: anthropics/claude-code#31021, #30930, #31637

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sbglasius

Copy link
Copy Markdown

Need this!

@bubbabright

Copy link
Copy Markdown
Author

Need this!

I made a similar change, plus added a few features that could benefit from another pair of eyes: https://github.com/bubbabright/claude-usage-extension

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