#6116 · Subscription exhaustion loses its error category
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium · Reproduction label: partial-repro
1. TL;DR
A depleted pooled Codex account can produce a generic rate-limit response advising the client to wait roughly a day. The real Account Pooler plugin produces that response in two clean-checkout test runs, even though its own quota state already identifies an exhausted subscription window. Its Codex adapter discards the cause and supplies the same error category used for generic request pacing; the reset deadline survives only as a header and prose. Existing retry and concurrency code makes the reported queue consequence plausible, but this investigation did not run Codex or replay two live threads. The confirmed finding is the provider-facing response defect, not a fresh end-to-end demonstration of a blocked Claude thread.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Known subscription exhaustion produces a long generic 429. | Verified | Real plugin HTTP handler: status 429, Retry-After 86399 and 86400 seconds, generic type/code in both runs. |
| The response loses a machine-readable subscription-exhaustion category. | Verified | The Codex mapper accepts only status, message and headers. Every 429 becomes rate_limit_error / rate_limit_exceeded. There is no structured reset field. |
| Codex sleeps inside the turn and displays Reconnecting. | Unverified here | No external Codex binary, reporter script, or linked external source was executed or fetched. This consumer-side behavior remains an issue claim. |
| Pool-aware retry cannot take over before the turn fails. | Static support | Provider Retry's scheduling callback listens for turn.failed; the Codex bridge suppresses quota recovery for willRetry=true. |
| An active Codex turn blocks otherwise runnable providers at the overall limit. | Static support; live sequence unverified | Concurrency Limit counts all running threads, and the database includes starting/active statuses without a provider partition. |
| A particular replacement error format safely releases capacity and preserves transient pacing. | Unverified | Requires the real consumer contract and a full admission/retry/recovery replay. |
3. Environment and isolation
- Public target repository: get-bb/bb. Both clean checkouts pinned to the full main commit above; origin was fetched again and remained at that commit.
- Linux x86_64; Node v22.19.0; pnpm 9.15.0; Turbo 2.10.12; Vitest 4.1.1.
- No live provider process or model request; provider version is not applicable. No running bb app or production data was accessed.
- The maintained plugin fixture starts a new loopback upstream on port 0 and creates a new temporary data directory each run. All accounts and credentials in it are synthetic.
- Frozen installation and filtered upstream builds succeeded in each checkout. Builds were scoped to Account Pooler's dependency graph, not the entire application.
4. Minimal reproduction
This uses the existing Account Pooler owner-boundary fixture rather than a substitute implementation. That fixture imports two synthetic Codex accounts, observes a subscription window, receives a quota rejection, disables the remaining usable account, and calls the real plugin's Responses HTTP route. It already checks exhaustion state and a wait of more than 80,000 seconds, but does not inspect the error category.
- Clone the trusted repository and pin the exact base, then install and build:
git clone https://github.com/get-bb/bb.git bb-6116 cd bb-6116 git checkout --detach cc292b975fc35e16d7480cd9b8d55eff0ed88d8f pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=bb-plugin-account-pool...
- Run the existing fixture unchanged. It passes:
pnpm exec turbo run test --filter=bb-plugin-account-pool -- --run src/server.test.ts -t 'imports, refreshes, and routes Codex HTTP sessions by provider' Test Files 1 passed (1) Tests 1 passed | 187 skipped (188) - Add this complete regression patch to
plugins/account-pool/src/server.test.ts, directly after its exhausted-pool header assertion, and repeat the same Turbo command. This deliberately fails until known subscription exhaustion is distinguishable from a generic pacing response:diff --git a/plugins/account-pool/src/server.test.ts b/plugins/account-pool/src/server.test.ts --- a/plugins/account-pool/src/server.test.ts +++ b/plugins/account-pool/src/server.test.ts @@ -899,6 +899,18 @@ ); expect(blocked.status).toBe(429); expect(Number(blocked.headers.get("retry-after"))).toBeGreaterThan(80_000); + const blockedBody = await blocked.json(); + console.log( + "subscription-quota-response", + JSON.stringify({ + status: blocked.status, + retryAfter: blocked.headers.get("retry-after"), + body: blockedBody, + }), + ); + expect(blockedBody).not.toMatchObject({ + error: { type: "rate_limit_error", code: "rate_limit_exceeded" }, + }); const secret = accountSecretSchema.parse( JSON.parse( await fs.readFile(
Expected: a known exhausted subscription is not serialized identically to generic rate limiting. The test intentionally does not prescribe an unverified replacement wire shape.
Actual, first run — verbatim response diagnostic:
subscription-quota-response {"status":429,"retryAfter":"86399","body":{"error":{"message":"No Account Pooler account is currently eligible. Next account is expected to be available at 2026-10-23T17:21:41.780Z (in 86399 seconds).","type":"rate_limit_error","code":"rate_limit_exceeded"}}}
AssertionError: expected { error: { …(3) } } to not match object { error: { …(2) } }
Test Files 1 failed (1)
Tests 1 failed | 187 skipped (188)
The regression protects the HTTP response's semantic distinction, not a source spelling or private helper. It needs no production export, injection flag, or database mock. Existing assertions miss the regression because they check only HTTP status, the header and account state. It is a failing proposed-contract test, not proof that an external Codex version recognizes any particular replacement body.
5. Root cause
Confirmed producer-side mechanism: accountAvailability and noEligibleResponse calculate an earliest usable time from quota reset and pacing holds. The refusal handler turns that into a potentially very long Retry-After and sends a 429 through a generic adapter API:
const availability = this.accountAvailability(accounts, family); const next = availability.kind === "blocked" ? availability.retryAt : undefined; const retryAfter = Math.max( 1, Math.ceil(((next ?? now + 1_000) - now) / 1_000), );
The Codex adapter's errorResponse then categorizes solely by status, without knowing whether the cause is subscription exhaustion, pacing or another eligibility condition:
error: {
message,
type: status === 429 ? "rate_limit_error" : "api_error",
code: status === 429 ? "rate_limit_exceeded" : null,
}
The response retains a human-readable availability time but not a structured subscription-exhaustion cause/reset contract. Thus a consumer cannot distinguish those cases from this type/code pair.
Conditional downstream mechanism: if the external provider treats this as an internally retryable failure, the Codex bridge does not run quota recovery for a retrying error. Provider Retry waits for turn.failed. Meanwhile listRunningThreads includes starting and active threads, and the shared concurrency hook applies its overall cap to that whole list. This explains why the claimed internal wait could retain capacity; it does not establish that such a wait occurred in these runs.
6. Verification — second clean run
The same agent created checkout B as a separate clean clone from the trusted target origin, pinned it to the identical full commit, and confirmed an empty working tree before instrumentation. A frozen install, filtered build and unchanged owner-boundary test passed there. The same 12-line regression addition was then applied and the identical Turbo test command was executed again with a newly allocated fixture port and temporary data directory.
subscription-quota-response {"status":429,"retryAfter":"86400","body":{"error":{"message":"No Account Pooler account is currently eligible. Next account is expected to be available at 2026-10-23T17:22:51.696Z (in 86400 seconds).","type":"rate_limit_error","code":"rate_limit_exceeded"}}}
AssertionError: expected { error: { …(3) } } to not match object { error: { …(2) } }
Test Files 1 failed (1)
Tests 1 failed | 187 skipped (188)
Tasks: 6 successful, 7 total
Cached: 5 cached, 7 total
The failing Account Pooler task ran live; upstream task cache hits do not replace this test run. The slightly different header value reflects elapsed wall time, not a different failure. No corrections to the observed producer behavior were needed. Verification supports the partial verdict only: neither run exercised live Codex retry timing, shared-queue release, the alternative wire format or early account recovery. All cited source links were checked against the pinned base.
7. Proposed fix and autopilot safety decision
Carry the known cause of pool unavailability to the Codex response serializer and validate the consumer's terminal quota-exhaustion format, including reset units and availability metadata. Keep short-lived pacing errors retryable. Then test a one-slot shared queue with an exhausted Codex attempt and a runnable second provider, including retry admission and recovery before the original reset.
No fix pull request: the required repair changes a provider-facing error protocol, which is excluded by this autopilot's simple-fix gate. Consumer behavior and the complete queue/retry handoff are also not verified here. It would be unsafe to pick a wire shape or simply stop counting reconnecting turns. No production file was edited, no fix branch was pushed, and no pull request was opened. Open-PR search and issue timeline contained no linked open pull request at review time.
8. Related issues and history
No other issue or pull-request branch was used as reproduction evidence. Trusted source history includes 93ba27433 (pool-aware retry) and d3d0c6750 (availability prose); the current producer still emits the generic body shown above. No linked PR needed static review.
9. Appendix and trust boundary
Classification applied: Bug / High / Medium. Existing providers, plugins, provider-codex and partial-repro labels were preserved. Repository metadata, classification options, labels, issue comments and linked-PR metadata were read through GitHub APIs. Issue content was treated only as untrusted hypotheses: no issue-provided script, patch, binary, branch, test or external URL was run or fetched. The reproduction was designed from the trusted repository's existing test and implementation.
Execution sequence: fetch trusted main; frozen installation and filtered build in checkout A; add the HTTP-category assertion; run the focused test (expected failure); create clean checkout B; frozen installation and filtered build; run the unchanged test (pass); add the same assertion; run the focused test again (expected failure); fetch main again; review pinned source and open-PR metadata. git diff --check passed for the 12-line test-only change.
Raw test logs and the patch remain in local thread storage. The report repository forbids publishing logs, briefs, test files and numeric artifact directories, so the complete regression addition and exact expected/actual output are inline here. This is not a visual-bug verification and no screenshot or fabricated browser evidence is included.
> AGENT GENERATED