Skip to content

Improve Claude OAuth 429 rate limit handling#1179

Merged
steipete merged 3 commits into
steipete:mainfrom
LeoLin990405:fix/claude-oauth-rate-limit-guidance
May 28, 2026
Merged

Improve Claude OAuth 429 rate limit handling#1179
steipete merged 3 commits into
steipete:mainfrom
LeoLin990405:fix/claude-oauth-rate-limit-guidance

Conversation

@LeoLin990405
Copy link
Copy Markdown
Contributor

Summary

  • handle Claude OAuth usage HTTP 429 as a dedicated rate-limit error with actionable guidance instead of surfacing the raw JSON body
  • add a small background backoff gate that respects Retry-After and lets user-initiated refreshes bypass stale cooldowns
  • avoid invalidating cached Claude OAuth credentials on usage rate limits, while preserving existing auth invalidation for real auth errors

Related: #575

Testing

  • swift build --target CodexBarCore
  • swift build --product CodexBarCLI
  • swift build --target CodexBarWidget
  • git diff --check
  • swift test --filter ClaudeOAuthTests (blocked before project tests run: local toolchain fails compiling KeyboardShortcuts #Preview macros with missing PreviewsMacros.SwiftUIView plugin)

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 27, 2026

Codex review: needs real behavior proof before merge. Reviewed May 27, 2026, 3:02 AM ET / 07:02 UTC.

Summary
The PR adds dedicated Claude OAuth HTTP 429 handling, Retry-After-backed background cooldown state, cache-preserving rate-limit errors, and focused Claude OAuth tests.

Reproducibility: yes. Source inspection shows a high-confidence current-main path where a 429 from the Claude OAuth usage endpoint falls through to generic serverError handling and then invalidates the OAuth cache; I did not run a live Anthropic 429 reproduction.

Review metrics: 3 noteworthy metrics.

  • Diff size: 4 files changed, +173/-2. The diff is compact but touches the core Claude OAuth fetch path and provider tests.
  • Persisted state: 1 UserDefaults key added. The new cooldown key can affect runtime behavior across app launches and upgrades.
  • Latest checks: 3 in progress, 1 passed, 0 failed observed. Maintainers should wait for the latest pushed head to finish validation before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Add redacted runtime proof showing the OAuth 429 guidance, cooldown behavior, credential preservation, and user refresh bypass after the fix.
  • Let the latest-head checks finish and fix any failure they report.
  • Have a maintainer confirm the persisted cooldown and cache-preservation policy before merge.

Proof guidance:
Needs real behavior proof before merge: The PR body lists builds and a blocked focused test run, but no after-fix app, CLI, terminal, log, recording, or linked artifact proof for the OAuth 429 path; the contributor should add redacted proof and update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review if it does not rerun.

Risk before merge

  • The PR intentionally changes Claude OAuth auth behavior by preserving cached credentials on 429 and adding a persisted global UserDefaults cooldown gate; maintainers should confirm that policy and scope before merge.
  • The latest head was not fully validated at review time because three GitHub Actions checks were still in progress.
  • The contributor has not added after-fix real behavior proof showing the 429 guidance, cooldown behavior, credential preservation, and user refresh bypass path in a real or controlled runtime setup.

Maintainer options:

  1. Require latest-head OAuth proof (recommended)
    Ask for redacted app, CLI, terminal, log, recording, or linked artifact proof showing a Claude OAuth 429 now surfaces guidance, records or bypasses cooldown as intended, preserves credentials, and recovers on user refresh.
  2. Accept the auth policy deliberately
    Maintainers can land the persisted cooldown and cache-preservation behavior if they explicitly confirm this is the intended Claude OAuth provider policy.
  3. Narrow the cooldown scope first
    If the global persisted gate is too broad, revise it to a shorter-lived or more narrowly scoped cooldown before merging.

Next step before merge
Human-only: the remaining blockers are contributor-supplied real behavior proof, unsettled latest-head checks, and maintainer acceptance of the auth-cache/cooldown policy; no narrow code repair was found.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds no dependencies, scripts, secret handling, or broader permissions.

Review details

Best possible solution:

Merge a narrow Claude OAuth 429 fix after maintainers accept the cache/cooldown policy, the latest-head checks are green, and the PR includes redacted runtime proof of the changed behavior.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows a high-confidence current-main path where a 429 from the Claude OAuth usage endpoint falls through to generic serverError handling and then invalidates the OAuth cache; I did not run a live Anthropic 429 reproduction.

Is this the best way to solve the issue?

Yes, the proposed direction is narrow: classify 429 separately, show actionable guidance, preserve credentials, and back off background retries. The persisted cooldown scope still needs maintainer acceptance, real behavior proof, and green latest-head validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 79f61e63ac2d.

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority Claude OAuth usability/auth handling fix with provider-specific blast radius.
  • merge-risk: 🚨 auth-provider: The PR changes OAuth 429 classification, credential-cache invalidation behavior, and provider refresh cooldown behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists builds and a blocked focused test run, but no after-fix app, CLI, terminal, log, recording, or linked artifact proof for the OAuth 429 path; the contributor should add redacted proof and update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review if it does not rerun.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Recent path history shows repeated Claude OAuth/provider HTTP work, including provider HTTP centralization, OAuth scope handling, Admin API usage, and quota/usage fixes. (role: feature owner and recent area contributor; confidence: high; commits: ad33b32773bd, d0a79d9855d0, aa8977ef994d; files: Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthCredentials.swift)
  • ratulsarna: Path history shows prior Claude OAuth usage and source-selection work adjacent to the OAuth usage and error-handling path changed here. (role: adjacent OAuth contributor; confidence: medium; commits: 4f2656b74c5c, 5f9b46df8fa6; files: Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift)
  • Yuxin-Qiao: Recent ClaudeUsageFetcher history includes Claude CLI subscription usage handling and OAuth extra usage normalization near the usage-loading behavior affected by this PR. (role: recent area contributor; confidence: medium; commits: 126dc9238715, 11f920652804; files: Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift, Tests/CodexBarTests/ClaudeOAuthTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels May 27, 2026
@LeoLin990405 LeoLin990405 force-pushed the fix/claude-oauth-rate-limit-guidance branch from 1dd800e to 7df2fd3 Compare May 27, 2026 06:52
@LeoLin990405 LeoLin990405 force-pushed the fix/claude-oauth-rate-limit-guidance branch from 7df2fd3 to 539f3c4 Compare May 27, 2026 06:57
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 27, 2026
@steipete steipete merged commit 0a0e8ca into steipete:main May 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants