← reports

#7453 · Provider billing rejection investigation

BugHighEffort: Mediumproviders · provider-claude-code · provider-codex

GitHub issue · 2026-11-12 · base 030b1b729f28acedc6f86cd65a71cb3678da8124

Verdict: NOT REPRODUCED · Root-cause confidence: low · reproduction label: no-repro

1. TL;DR

The reporter cannot use Claude Code and associates a billing rejection with depleted Codex allowance. The available text does not identify the selected provider, the account used by the failing process, its authentication mode, or the raw provider response. Two clean trusted checkouts pass the same three synthetic Claude-boundary probes plus 56 existing translation tests. These probes demonstrate that the inspected Claude path relays its own upstream billing failures and accepts successful results; they do not recreate the reporter's account state or establish a cross-provider defect. No product root cause is established, and no production patch is justified.

2. Claims vs findings

ClaimStatusEvidence
The reporter's Codex allowance is depleted while Claude allowance is available.UnverifiedNo live account was inspected and no paid provider call was made.
Claude Code is the process producing the failure.UnverifiedIssue text does not include a selected-provider identifier or raw provider event. Linked screenshots were not fetched under the automation trust policy.
Codex depletion prevents otherwise successful Claude operation.UnverifiedNo exhausted Codex account was available for an end-to-end experiment. Synthetic successful Claude messages produce completed turns, not billing failures.
A Claude upstream billing rejection can appear as a failed bb turn.Verified at the synthetic provider boundary onlyThe HTTP 402 result probe preserves the supplied detail and emits a billing-classified provider error and failed completion.
A billing failure globally poisons subsequent thread translation.Not observed in the probed boundaryA second Claude thread succeeds on the same translator/assembler after the first thread's rejection. This does not exercise Codex dispatch or account selection.

3. Environment

4. Minimal reproduction attempt

This is a repeatable negative investigation probe, not a regression test that reproduces the claimed bug. It exercises the real Claude translator and SDK delta assembler; only upstream event inputs are synthetic. It does not simulate billing policy or bypass the translator with a fake implementation.

  1. Obtain the trusted source and pinned base:
    git clone https://github.com/get-bb/bb.git bb-7453
    cd bb-7453
    git checkout --detach 030b1b729f28acedc6f86cd65a71cb3678da8124
    pnpm install --frozen-lockfile --prefer-offline
  2. Save the probe file as plugins/provider-claude-code/src/issue-7453.repro.test.ts.
  3. Build the SDK before consuming it, then run only the relevant tests:
    pnpm exec turbo run build:types build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run test --force --filter=bb-plugin-provider-claude-code -- src/issue-7453.repro.test.ts src/delta-translation.test.ts
  4. Expected: a success completes without an error; a synthetic upstream 402 failure preserves its detail and fails the turn; a new thread succeeds after that failure. Actual in both checkouts:
    Test Files  2 passed (2)
         Tests  59 passed (59)

Full probe source:

import { describe, expect, it } from "vitest";
import { createClaudeDeltaHarness } from "./delta-test-harness.js";

function startTurn(
  harness: ReturnType<typeof createClaudeDeltaHarness>,
  threadId: string,
) {
  harness.translate(
    {
      jsonrpc: "2.0",
      method: "sdk/message",
      params: {
        threadId,
        message: {
          type: "assistant",
          message: { id: threadId, content: [] },
        },
      },
    },
    { threadId },
  );
}

function resultEvent(threadId: string, failed: boolean) {
  return {
    jsonrpc: "2.0",
    method: "sdk/message",
    params: {
      threadId,
      message: {
        type: "result",
        subtype: failed ? "error_during_execution" : "success",
        is_error: failed,
        ...(failed ? { api_error_status: 402 } : {}),
        result: failed ? "Synthetic Claude billing rejection" : "ok",
        usage: {},
        modelUsage: {},
      },
    },
  };
}

describe("issue 7453 provider-boundary investigation", () => {
  it("accepts a successful Claude result without a billing error", () => {
    const harness = createClaudeDeltaHarness();
    startTurn(harness, "claude-success");
    const events = harness.translate(resultEvent("claude-success", false), {
      threadId: "claude-success",
    });
    expect(events.filter((event) => event.type === "provider/error")).toEqual([]);
    expect(events).toContainEqual(
      expect.objectContaining({ type: "turn/completed", status: "completed" }),
    );
  });

  it("surfaces the Claude upstream billing rejection verbatim", () => {
    const harness = createClaudeDeltaHarness();
    startTurn(harness, "claude-billing");
    const events = harness.translate(resultEvent("claude-billing", true), {
      threadId: "claude-billing",
    });
    expect(events.filter((event) => event.type === "provider/error")).toEqual([
      expect.objectContaining({
        detail: "Synthetic Claude billing rejection",
        errorInfo: {
          category: "billing",
          providerCode: "error_during_execution",
          httpStatusCode: 402,
        },
      }),
    ]);
    expect(events).toContainEqual(
      expect.objectContaining({ type: "turn/completed", status: "failed" }),
    );
  });

  it("does not carry a billing failure into another Claude thread", () => {
    const harness = createClaudeDeltaHarness();
    startTurn(harness, "claude-billing");
    harness.translate(resultEvent("claude-billing", true), {
      threadId: "claude-billing",
    });
    startTurn(harness, "claude-other");
    const events = harness.translate(resultEvent("claude-other", false), {
      threadId: "claude-other",
    });
    expect(events.filter((event) => event.type === "provider/error")).toEqual([]);
    expect(events).toContainEqual(
      expect.objectContaining({ type: "turn/completed", status: "completed" }),
    );
  });
});

5. Root cause and limits

Root cause of the reported failure: unknown. The evidence does not show that bb incorrectly uses Codex balance for Claude. It is also insufficient to conclude that the user's authentication is incorrect or that a subscription or API balance is exhausted. Do not mistake an upstream error propagation test for proof that the upstream service caused this specific incident.

function isClaudeResultFailure(message: ClaudeResultMessage): boolean {
  return message.is_error === true || message.subtype.startsWith("error");
}

if (message.is_error && typeof message.result === "string") {
  return message.result;
}

6. Proposed next experiment / safe-fix decision

No safe production fix is supported. First identify the affected thread's provider, selected machine/model/service tier, bb and native Claude versions, and whether Claude uses an interactive subscription login, an API key, or Account Pooler. Compare a minimal Claude request in bb with the native Claude CLI on the same machine and project, preserving the raw error category/status while redacting all tokens and private prompts. Record only whether provider-specific environment overrides exist, never their secret values. Then vary Codex availability while keeping the Claude account and request constant.

The simple-fix gate is not met because the bug was not reproduced on trusted main and there is no pre-fix failing regression for the reported behavior. No branch, production change, commit, push, or pull request was created for bb. Issue timeline metadata and an open-PR search for issue 7453 found no linked open pull request at investigation time.

7. Verification

The same agent repeated the corrected probe in a second clean detached worktree at the identical trusted base. git status --porcelain was empty before copying the probe; dependency installation was frozen. The verification run used --force to avoid replaying cached test results. There were no live processes or ports to reuse.

RunResultEvidence
First corrected run, base worktree3 probes + 56 existing tests passed; 59 totalSanitized first log
Second clean run, verify worktree3 probes + 56 existing tests passed; 59 total, uncachedSanitized second log

Probe SHA-256 in both worktrees: bb25e1f305bd77582087c1a78f48fe5afec3aee62d28c9e79cd7dac39884e4c4. The first draft omitted the assistant turn-start event and therefore failed on empty result-only output. The fixture was corrected to match the existing production event lifecycle; production code did not change. That draft failure is not a reproduction of the issue. The second run required no further report or probe correction.

8. Related issues

#4533 discusses Codex credit fallback within Account Pooler, not a demonstrated effect on Claude. #7404 concerns Claude environment variables under Account Pooler. Neither is established as the same root cause; no duplicate label is applied.

9. Appendix

Repository visibility was verified as public before publication. Issue text and the one image-only comment were treated as untrusted evidence; no attachment URL was fetched and no issue-provided code was executed. No linked PR code, live user state, or secrets were accessed.

Setup ran a normal frozen install and full Turbo build. The first full build hit a clean-checkout SDK build-order error in the unrelated GitHub plugin (missing SDK runtime dist). Explicitly building SDK runtime and types resolved that prerequisite; see build summary. This tooling failure is unrelated to billing. The second checkout built the relevant SDK dependency chain before repeating the tests.

Investigation commands included trusted-main fetch/revision/status checks, GitHub issue/property/label/comment/timeline reads, a search of open PRs for numeric issue 7453, repository source searches and line inspection, frozen installs, SDK builds, full first-checkout build, and the focused Turbo test commands above. No screenshot is supplied because this investigation concerns error provenance, not a rendering defect, and the reporter's screenshots were not fetched.

> AGENT GENERATED