Skip to content

Use regular Claude and Codex interfaces for status and usage, and identify bb as its own client #6688

Open

Description

@parabolaalt

The workflow

I want to run Claude Code and Codex threads from bb on my own subscription logins, with bb's sign-in status, plan usage and generated titles working, and stay within Anthropic's and OpenAI's terms. Step by step:

  1. Sign in to claude (claude.ai) and codex (ChatGPT) on the machine.
  2. Start a thread from the bb UI. This works and stays as it is: bb drives the user's own, unmodified claude through the Agent SDK and the user's own codex app-server. Anthropic does not stop an end user "signing in to the unmodified Claude Code binary with their own Claude subscription, including where a platform hosts Claude Code" (A2), and its Help Center says the Agent SDK, claude -p and third-party apps can use subscription limits (not re-read for this issue). For Codex, OpenAI's open-source app docs name codex app-server as the route (also not re-read).
  3. Open the provider usage card (Settings, or bb settings usage). bb shows sign-in status and plan usage.
  4. Let bb write thread titles and commit messages with the Codex login (Settings → AI services → Automatic).

Where bb makes this awkward or goes beyond what the vendors allow:

Each conflicts with a specific clause of Anthropic's or OpenAI's terms (keys A1 to O5 below). This is an engineering reading of those terms, not legal advice.

What happens today

Versions and environment

  • bb at 1a4a1d254c7b1f70d340ef9c800dad77dbeb8e66 (desktop-v0.48.0); permalinks use this commit. Every path cited was re-checked on main at 9662c45478f4a74f33f11b70187657d97f1e14a7 (2026-10-30); two anchors moved, noted below.
  • Node v24.14.1, Linux (Debian 12). Claude Code 2.1.295 signed in with claude.ai. Codex CLI signed in with ChatGPT.

C1. bb reads Claude's stored token and calls Anthropic with it

Health and usage read the Keychain item (provider-maintenance.ts L30, L257-L295) or ~/.claude/.credentials.json (L305), then call https://api.anthropic.com/api/oauth/usage with User-Agent: claude-code/2.1.0 (L29, L536-L537), about every 2 minutes while the usage card is visible.

As a user-visible bug (#3607): sign Claude Code in with a non-default CLAUDE_CONFIG_DIR and nothing in ~/.claude, run bb with that environment, then bb settings usage --refresh --json. At main 9937c46f5 bb reported unauthenticated for health and usage while claude auth status --json reported loggedIn: true. I did not re-run this on 9662c45478.

C2. bb hides that its Claude sessions come from an Agent SDK app

The bridge sets CLAUDE_CODE_ENTRYPOINT=cli and deletes CLAUDE_AGENT_SDK_CLIENT_APP (bridge.ts L1735-L1737; L1781 on main). PR #84 (merged 2026-06-11, commit 882b1fe6b7) did this so SDK traffic is "byte-identical to headless claude -p" instead of carrying client-app/bb/1.0.0. In 0.48 the model-list and slash-command catalog probe (probeClaudeInitialization) passes the bridge environment through unchanged, so it reports the SDK's default entrypoint or one inherited from a parent process.

X1. bb calls a private ChatGPT endpoint with the Codex token

getCodexProviderUsage reads ~/.codex/auth.json and calls https://chatgpt.com/backend-api/wham/usage with the CLI's token (provider-maintenance.ts L30, L362). bb already calls account/rateLimits/read for rate-limit recovery (bridge.ts L758).

X2. The Codex AI service uses the ChatGPT login outside Codex

The service (server.ts L1) writes titles and commit messages through chatgpt.com/backend-api/codex/responses and transcribes through chatgpt.com/backend-api/transcribe, with the token read from auth.json (chatgpt-client.ts L22-L23, codex-auth.ts L171).

Docs and retries

  • SKILL.md (L47; L52 on main) says bb passes only BB_CLAUDE_CODE_EXECUTABLE and CLAUDE_CODE_OAUTH_TOKEN to Claude Code. The bridge inherits the daemon's environment except BB_* and NODE_ENV, so an inherited ANTHROPIC_API_KEY also reaches it and moves threads from subscription limits to API billing with no sign in the UI.
  • Automatic retries after a limit (provider-retry) re-send a turn without the user acting and are on by default.

Steps to reproduce the code paths

No vendor-side repro is possible for a terms conflict. Each code path exists at main:

git clone https://github.com/get-bb/bb.git && cd bb
git checkout 9662c45478f4a74f33f11b70187657d97f1e14a7
git grep -n 'oauth/usage\|claude-code/2.1.0\|Claude Code-credentials\|\.credentials\.json' -- plugins/provider-claude-code/src
git grep -n 'CLAUDE_CODE_ENTRYPOINT\|CLAUDE_AGENT_SDK_CLIENT_APP' -- plugins/provider-claude-code/src
git grep -n 'wham/usage\|backend-api' -- plugins/provider-codex/src

Output (file:line):

plugins/provider-claude-code/src/bridge/provider-maintenance.ts:29   CLAUDE_USAGE_URL = "https://api.anthropic.com/api/oauth/usage"
plugins/provider-claude-code/src/bridge/provider-maintenance.ts:30   CLAUDE_KEYCHAIN_SERVICE = "Claude Code-credentials"
plugins/provider-claude-code/src/bridge/provider-maintenance.ts:537  "User-Agent": "claude-code/2.1.0"
plugins/provider-claude-code/src/bridge/bridge.ts:1781               CLAUDE_CODE_ENTRYPOINT: "cli"
plugins/provider-codex/src/bridge/provider-maintenance.ts:30         CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage"
plugins/provider-codex/src/ai/chatgpt-client.ts:22-23                chatgpt.com/backend-api/codex/responses, /backend-api/transcribe

What you would expect

bb gets Claude and Codex sign-in status and usage only through the interfaces below, identifies itself to Anthropic as a bb Agent SDK client, and does not read either vendor's stored subscription credentials.

What bb may use instead

Use Remove
Claude threads and probes The official claude binary, driven by the Agent SDK query(), on the user's own login or API key Nothing; this is unchanged
Claude sign-in status claude auth status --json Reads of the macOS Keychain item Claude Code-credentials, ~/.claude/.credentials.json, ~/.claude.json
Claude plan usage The Agent SDK usage request query().usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET() from a session that gets no prompt, plus the stream's rate_limit_event Calls to api.anthropic.com/api/oauth/usage with the OAuth token
Claude identity CLAUDE_AGENT_SDK_CLIENT_APP=bb/<version>, no CLAUDE_CODE_ENTRYPOINT override CLAUDE_CODE_ENTRYPOINT=cli, deleting CLAUDE_AGENT_SDK_CLIENT_APP
Codex threads The user's codex app-server, clientInfo.name bb Nothing; unchanged
Codex sign-in status and usage App-server account/read, account/rateLimits/read, and the account/rateLimits/updated notification Reads of ~/.codex/auth.json, calls to chatgpt.com/backend-api/wham/usage
Codex titles and commit messages api.openai.com with the user's API key chatgpt.com/backend-api/codex/responses and /transcribe with the CLI's token

C1. Read Claude's sign-in status and usage through Claude Code

  • Change: use the interfaces in the table, keep the ProviderUsageResult shape, and delete the token reads, the direct call and the fake User-Agent. The usage probe sets settingSources: [] and strictMcpConfig: true, so it does not start user-scope MCP servers (the problem in claude-code: the context-usage and initialization probes connect to every user-scope MCP server, then abort it (every turn) #6655).
  • Why: A1. A token taken from Claude Code's store and sent by bb is bb collecting and intermediating a claude.ai credential, and the request claims to come from Claude Code.
  • Also fixes Claude usage check ignores CLAUDE_CONFIG_DIR, reporting expired for a signed-in account #3607: Claude Code resolves CLAUDE_CONFIG_DIR, the Keychain service name, API keys and gateways itself, so bb no longer mirrors those rules.
  • With an API key or a third-party provider there are no plan limits; the usage result then carries no plan windows instead of asking the user to sign in.
  • Accepted losses: the Max 5x/20x label, the "expired" state (Claude Code refreshes its own tokens), and an account key on usage (one account on two machines shows two cards). The usage method is experimental, so validate its result and re-check it on SDK upgrades.

C2. Identify Claude sessions as a bb Agent SDK client

  • Change: remove the override, set CLAUDE_AGENT_SDK_CLIENT_APP=bb/<version>, and build the environment for the model-list and slash-command catalog probes the same way, without bb's bridge runtime variables.
  • Why: A3. The product should not "appear to be Claude Code", and the stated purpose of the override is that Anthropic cannot tell a third-party SDK app from claude -p. No clause forbids setting the entrypoint by name, so this is the weakest of the legal links; it also removes an avoidable risk if Anthropic ever bills SDK and CLI traffic differently.

X1. Read Codex sign-in status and usage through codex app-server

  • Change: ask a fresh codex app-server for account/read and account/rateLimits/read and map into the existing ProviderUsageResult, so the usage card, bb settings usage and bb.sdk.system.usageLimits() keep working. Delete the auth.json read and the wham/usage call. For an API-key login there are no plan limits, so the usage result says that instead of failing.
  • Why: O1 (tokens only through OpenAI's supported flow) and O5 (no programmatic extraction); the endpoint is private and bb reaches it with a token it took from the CLI.

X2. Stop using the Codex login for bb's own AI service

  • Change: remove the ChatGPT-login paths, the service registration and the codex.ai.* host handlers that serve them (host.ts), so "Automatic" in Settings → AI services falls back to bb cloud or an API key. Keep the api.openai.com API-key paths. Delete the unreachable ChatGPT client modules with them.
  • Why: O1 and O5, same as X1. OpenAI's developer docs also list transcription as unsupported on plan usage (not re-read).

D1. Decision: express consent for background use of a ChatGPT login

O4 requires express consent before background use. User-created automations are expressly authorized. Automatic retries after a limit re-send a turn without the user acting and are on by default. Decide whether the current setting and notice count as consent for ChatGPT logins. No code change is proposed until that is decided.

Docs

  • Correct the SKILL.md sentence and the matching docs/configuration.md text about which environment variables reach Claude Code (an inherited ANTHROPIC_API_KEY does), and describe the new status and usage sources.
  • plugins/provider-codex/PLUGIN_OVERVIEW.md and its skill: each machine uses its own codex login; for unattended work an API key is the supported route.

Terms relied on

Pages read on 2026-10-30. Only the sentences used above are quoted.

  • A1: Claude Code legal and compliance, "Authentication and credential use": "developers may not collect, store, or intermediate Claude.ai credentials or session tokens — sign-in to a Claude account must complete through Anthropic's own flow."
  • A2: same section: this "does not prevent an end user from signing in to the unmodified Claude Code binary with their own Claude subscription, including where a platform hosts Claude Code".
  • A3: Agent SDK overview, "Branding guidelines": "Your product should maintain its own branding and not appear to be Claude Code or any Anthropic product."
  • O1: Sign in with ChatGPT Terms §1 (no effective date is shown on the page): "Obtain and use SIWC access and refresh tokens… only through OpenAI's supported sign-in flow" and "Do not impersonate OpenAI, another application, or another open-source project."
  • O4: same, §2: "Obtain express consent before background use."
  • O5: Terms of Use (effective 2026-01-01): you may not "Automatically or programmatically extract data or Output".

Scope: the Sign in with ChatGPT Terms (Service Terms §15) apply to an app that "use[s] SIWC". bb's threads run the user's own codex login, so how far O1 and O4 bind bb is a reading, not a given. They show where OpenAI draws the line for apps that handle plan tokens. The Terms of Use (O5) apply to every account holder.

Compatibility and prototypes

provider/health and provider/usage keep their result shapes, so HOST_DAEMON_PROTOCOL_VERSION does not need a bump. Prototype changes for C1, C2, X1 and X2 exist and will be linked from the PRs.

Context and alternatives

Related issues and PRs

What I ruled out

  • Not a duplicate: Claude usage check ignores CLAUDE_CONFIG_DIR, reporting expired for a signed-in account #3607 is the only existing issue for C1. I searched open and closed issues and PRs on 2026-10-30 for claude config dir, claude usage credentials, codex usage, wham, CLAUDE_CODE_ENTRYPOINT, agent sdk client, anthropic terms, openai terms, compliance, subscription rules, keychain and ANTHROPIC_API_KEY and found nothing for the other items. That is a keyword search and could miss a differently worded issue.
  • Thread launch and automatic retries are not findings: threads use the user's own binary and login, and retries wait for the reset time the provider reports without touching credentials. D1 is the only open question about them.
  • Configuration alone is not a fix: the credential reads and the direct calls are in code that runs by default.
  • Not confirmed: whether the Sign in with ChatGPT Terms formally bind bb, and whether Anthropic's "unless previously approved" route applies to bb (none recorded in the repo).

Verification: I checked the code paths above by reading and grep, not by running the proposed changes. Treat the prototypes as unverified until their PRs run CI.

Priority and effort: High for C1, X1 and X2: they run by default and each is a contained change to one plugin with tests. C2 and Docs are small. D1 is a product decision. No data or work is lost by waiting.

Proposed split into PRs: C1; C2 and the Claude docs; X1 and the Codex docs; X2; D1 as a decision.

AGENT GENERATED

Checks

  • I searched open and closed issues for the same request.
  • If an agent wrote this, the body ends with > AGENT GENERATED.

Activity

  1. added theissue type on Oct 30, 2026
  2. added
    providers
    provider-claude-code
    provider-codex
    on Oct 30, 2026
  3. bb-slop-cop commented on Oct 30, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied missing classification: Type: Task · Priority: Medium · Effort: High.
    Labels: providers, provider-claude-code, provider-codex. No existing classifications or labels were replaced; final Type re-read and verified.

    This is a cross-provider integration and authentication rework with policy decisions, rather than a standalone unexpected behavior. Medium priority reflects no demonstrated outage or data loss; High effort reflects the multi-plugin scope and authentication changes. Vendor-terms claims were not independently adjudicated.

    No reproduction report or pull request: the verified Type is Task, so bug-only reproduction and simple-fix steps do not apply.

  4. lanjak commented on Nov 4, 2026

    @lanjak
    Contributor

    For X1: codex app-server (0.163.0) also has rateLimitResetCredits on account/rateLimits/read and an account/rateLimitResetCredit/consume method. I've proposed rebuilding #6153 (usage-limit resets) on that instead of wham/usage, and dropping its Claude part and the claude-cli User-Agent until Claude Code has a supported route: #6153 (comment)

    If X1 maps account/rateLimits/read into ProviderUsageResult, it would help to keep the reset-credit fields in that mapping so #6153 can build on it.

    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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions