Skip to content

Claude quota polling ignores the Retry-After header and retries failures at 30s, causing sustained 429s on /api/oauth/usage #701

Closed

Description

@avs-io

Problem

On a real v0.9.15 session (macOS menubar), the Plan section gets stuck on "Couldn't load plan data — Anthropic rate-limited the quota endpoint. Retrying in 1 min." CodexBar polling the same endpoint with the same account and credentials on the same machine is never rate-limited, so this is our request pattern, not the account.

Evidence

  • org.agentseal.codeburn-menubar defaults on the affected machine show a persisted block (codeburn.claude.usage.blockedUntil = 2026-07-16 20:07:47 +0000) with the cadence at the 2-minute default.
  • mac/Sources/CodeBurnMenubar/Data/ClaudeSubscriptionService.swift:154-158,182-189 — 429 handling parses retry_after from the JSON body only; the standard Retry-After response header is never read, so we nearly always fall back to a flat 300s and re-probe into a still-open server window (no escalation: the block is overwritten, not maxed).
  • mac/Sources/CodeBurnMenubar/CodeBurnApp.swift:441-467 — lastSubscriptionRefreshAt only advances on success while the loop ticks every 30s (CodeBurnApp.swift:5), so any transient failure escalates polling from the 2-minute cadence to one request per 30s until a success — the burst that trips the limit in the first place.
  • CodeBurnApp.swift:501-512 — the popover-open 30s floor is an OR across providers, force-fetching Claude even when it was fetched seconds ago; SettingsView.swift:276 and HeatmapSection.swift:1727,1734 bypass the single-flight in CodeBurnApp.swift:472-487.
  • Comparison: CodexBar honors Retry-After (both delta-seconds and HTTP-date), escalates its block with max(existing, candidate), and uses an adaptive cadence — same endpoint, no 429s.

Proposed fix

  1. Parse the Retry-After header on 429 (fallback: body retry_after, then 300s) and record max(existing, new) so repeated 429s escalate instead of resetting.
  2. Anchor refresh cadence on attempt time, with exponential backoff + jitter for failures capped at the configured cadence — never retry hotter than steady state.
  3. Make the popover-open floor per-provider.
  4. Route the Settings/Plan-tab retry buttons through the AppDelegate single-flight.

Activity

  1. avs-io commented on Jul 16, 2026

    @avs-io
    CollaboratorAuthor

    Working on this. Approach as proposed: header-first Retry-After parsing with max-escalation on the persisted block, attempt-anchored cadence with capped backoff for failures, per-provider popover floor, and interactive retries routed through the single-flight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions