Skip to content

Provider usage: show and spend Codex and Claude usage-limit resets #6153

Description

@lanjak

The workflow

Codex (ChatGPT) and Claude subscriptions now come with usage-limit resets, even on a single account. When I hit a limit I want to see that I have a reset and spend it from bb's Provider usage card, the same place that already shows the limit I just hit.

Today I have to leave bb and redeem it in the provider's own client (Codex CLI /status → Redeem reset, Claude Code /limit-reset). bb never shows that a reset exists, so they can expire unused.

What happens today

  • Provider usage shows windows (percent, reset time, plan) only. The usage-source contract (provider-usage.v1.listResources / getResource) has no field for resets and no action.
  • provider-codex already fetches chatgpt.com/backend-api/wham/usage, whose response includes rate_limit_reset_credits: { available_count, applicable_available_count }, but only plan_type and rate_limit are parsed.
  • provider-claude-code already fetches api.anthropic.com/api/oauth/usage, but without cedar_ember=1, so the reset grants block is never returned.
  • Observed on bb 0.46.1 (Linux server host). A read-only check of my own Codex Pro login shows available_count: 2, and bb shows nothing.

What you would expect

Scoped to the base Provider usage plugin and the two provider plugins, not the Account Pooler (#4157 covers that):

  1. Contract. An optional resetCredits on a measurement: { available, usableNow, nextExpiresAt? }, plus an optional provider-usage.v1.consumeReset({ resourceId, requestId }) method returning reset | nothing_to_reset | no_credit | already_redeemed. Sources that do not implement it are unchanged.
  2. provider-codex. Read rate_limit_reset_credits from the existing /wham/usage call. Spend with POST /wham/rate-limit-reset-credits/consume { redeem_request_id }, the same endpoint the open-source Codex CLI uses.
  3. provider-claude-code. Add cedar_ember=1&skip_spend=1 to the existing usage request and read grants[].resets_left, grants[].ends_at, next_grant_id. Spend with POST /api/organizations/{org}/reset_rate_limits { program: "cedar_ember", grant_id, request_id }, the call Claude Code's /limit-reset makes.
  4. Usage card. A small "N resets" line on the provider row (with expiry when known) and a Use reset… action, enabled only when usableNow > 0, behind a confirmation because a spent reset cannot be restored. Afterwards it refreshes that resource.

Each attempt sends a fresh idempotency key. nothing_to_reset keeps the credit.

I'd like to build this myself: the contract change, both provider plugins, and the card UI, with tests. I'll link a prototype branch from my fork here before opening a PR, and open the PR once this is signed off (I'm not in APPROVED_CONTRIBUTORS yet).

Context and alternatives

  • Related: Account Pooler: show and spend Claude and Codex usage-limit resets per account #4157 (the same capability for pooled accounts; its prototype already maps both provider APIs, and it lists Provider usage as a follow-up). This issue is that follow-up, for everyone with one account per provider.

  • Claude user agent. Grants are only returned to Claude Code clients. provider-claude-code runs next to the user's own installed Claude Code and already reads its version, so it can send claude-cli/<installed version> (external, cli) with that install's own OAuth token, rather than a hard-coded string. If that is not acceptable, Codex could ship alone first.

  • Stability. The ChatGPT endpoints are visible in the open-source Codex client. The Claude ones are undocumented and may change, so failures there should just hide the reset line.

  • I searched open and closed issues for the same request.

  • If an agent wrote this, the body ends with > AGENT GENERATED.

AGENT GENERATED

Activity

  1. added
    providers
    provider-codex
    provider-claude-code
    on Oct 23, 2026
  2. bb-slop-cop commented on Oct 23, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied the missing classification:

    • Type: Feature
    • Priority: Medium — meaningful provider functionality with a workaround in the providers’ own clients.
    • Effort: High — requires extending the usage-source contract, two provider integrations, and the shared UI with a confirmed redemption action.
    • Labels: providers, provider-codex, provider-claude-code.

    No existing classifications needed preservation; all applied values were verified. No reproduction report or pull request: this adds functionality rather than fixing unexpected existing behavior.

  3. lanjak commented on Oct 23, 2026

    @lanjak
    ContributorAuthor

    Prototype: main...lanjak:bb:provider-usage-reset-credits (one commit on 1e80ca7).

    What it does:

    • Contract. resetCredits: { available, usableNow, nextExpiresAt } | null on an ok measurement (defaults to null, so existing sources are unchanged), plus an optional provider-usage.v1.consumeReset({ resourceId, requestId }) that returns reset | nothing_to_reset | no_credit | already_redeemed | failed. All five contract copies are updated identically.
    • Bridge schema. resetCredits is optional on the ok usage object. The schemas are already .passthrough(), so older daemons keep working without a HOST_DAEMON_PROTOCOL_VERSION bump.
    • provider-codex. Reads rate_limit_reset_credits from the existing /wham/usage response, and calls GET /wham/rate-limit-reset-credits for the expiry only when the count is above 0. It spends a reset with POST /wham/rate-limit-reset-credits/consume through a new host RPC on the machine that holds the login.
    • provider-claude-code. Adds cedar_ember=1&skip_spend=1 to the existing usage request and spends a reset with POST /api/organizations/{org}/reset_rate_limits through a host RPC. The organization UUID comes from ~/.claude.json.
    • Provider usage. A "N resets · next expires …" line under the account's windows, and Use reset… with an inline confirmation (no modal). It is enabled only when the source implements consumeReset and usableNow > 0, and the account is refreshed afterwards. A useReset RPC backs the button and is callable with bb plugin rpc call.

    On the Claude user agent question: bb currently sends claude-code/2.1.0, and against a real Max account that gets {"eligible": false, "ineligible_reason": "surface"}. Sending claude-cli/<installed version> (external, cli), with the version read from the user's own Claude Code install (cached for 10 minutes), gets ineligible_reason: "no_grant" instead: the surface is accepted and that account simply has no grant at the moment.

    Verified:

    • Typecheck, lint, and tests pass for provider-usage, provider-codex, provider-claude-code, account-pool, provider-acp and provider-bridge-protocol. New tests cover the parsers, outcome mapping, the server's canUseReset/useReset flow, and the card's confirm-before-spend step.
    • I ran the new Codex usage code read-only against a live Pro login. It reported { available: 2, usableNow: 0, nextExpiresAt: "2026-10-29T18:45:52.547Z" }, which matches the account. Nothing was spent.

    Not done yet: a dedicated CLI command (today the only path is bb plugin rpc call bb--provider-usage useReset), and a live redeem, because my account has no eligible window. Happy to add the CLI command if you want it before a PR.

    AGENT GENERATED

  4. lanjak commented on Oct 23, 2026

    @lanjak
    ContributorAuthor

    Update: I added the CLI command to the prototype branch (d5ab7d441).

    • bb usage list [--refresh] [--json] prints every account the Provider usage card shows, with its ID, usage windows and reset credits.
    • bb usage reset <id> --yes [--json] spends one reset. It refuses to run without --yes, and exits 1 when the provider rejects the reset.

    They are documented in plugins/provider-usage/skills/provider-usage/SKILL.md and the README. useReset also relists sources when it does not know an ID yet, so a reset works right after a server restart. Tests cover the --yes refusal (nothing is spent), the list text and JSON output, and a confirmed reset. Happy to rename the command if you would rather it live somewhere else.

    AGENT GENERATED

  5. lanjak commented on Oct 30, 2026

    @lanjak
    ContributorAuthor

    Update: I rebased the prototype onto current main. It is now two commits on abcff9f: c5d2b05d2 (Provider usage resets) and d7ee56816 (the bb usage CLI). Same link: main...lanjak:bb:provider-usage-reset-credits

    • The rebase had no conflicts, and the code is unchanged. The commit IDs in my earlier comments (1e80ca7 as the base, d5ab7d441 as the tip) are out of date.
    • It also applies cleanly to the newest main (a1bf55b6a).

    Verified:

    • Typecheck and tests pass for provider-usage, provider-codex, provider-claude-code, account-pool and provider-acp. That includes 25 provider-usage tests and 552 provider-codex tests.

    AGENT GENERATED

  6. lanjak commented on Nov 4, 2026

    @lanjak
    ContributorAuthor

    #6688 raises a concern that applies here: the prototype reads reset credits from wham/usage and oauth/usage with the CLI's token, and sends a claude-cli/... User-Agent to get past the surface check on Claude.

    I checked the supported interfaces instead:

    Proposal: rebuild this on codex app-server for Codex (show and spend), drop the Claude part and the User-Agent change, and keep the resetCredits / consumeReset contract provider-neutral so Claude can follow when Claude Code supports it.

    I'm an approved contributor now. Does this direction work for you? If so I'll rework the prototype and open the PR.

    AGENT GENERATED

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

    provider-claude-codeprovider-codexproviders

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions