Repository navigation
Description
Client or integration
Codex App
Area
Authentication and account pool
Summary
In Pool mode with the Codex App signed in as the native main account, a pool-account session mirrors its billing onto the caller-owned main account: during a 38-minute pool session the main account's 5-hour usage window rose +45 percentage points while zero requests were attributed to the main account anywhere in OpenCodex's own logs, and the magnitude matches the pool account's own consumption in the same window (+43 points event-level within the window, +46 across the pool account's full 5-hour window). One workload, two accounts billed — the second charge is invisible to every local request ledger (usage.jsonl, spend-ledger.jsonl, response spill files, session rollouts) and shows up only in backend-side quota reads (ChatGPT dashboard; locally, the proxy's quota cache, which mirrors backend reads).
Expected: when Pool selection picks a stored pool account for a request, the caller-owned main credential should not participate in that request's billing. At minimum, the main account's window should not move while it has zero attributed requests.
This is the billing-side counterpart of the routing behavior already documented in #5019 (a request-owned main bearer is excluded from pool ordering and reached only through resolveCallerOwnedMainContext) and #3647 (the caller-credential fallback can consume quota of a paused main account — auto-closed by the template bot with no fix). This report adds end-to-end quota evidence that the coupling is billable, not just routable.
Reproduction
Environment (all times local, UTC-7):
- OpenCodex 2.90.0 on Windows 11. Canonical
openaiprovider in Pool mode (codexAccountMode: "pool",authMode: "forward"). Codex App signed in as main account M (ChatGPT Plus). Two stored pool accounts added viaocx account login openai --device(bothisMain: false); no selection order /codexAccountPrioritiesconfigured — M is not incodexAccountsat all (it is the native App login); Pool active selection = P. - Resume an old conversation that was originally created while bound to M (its thread affinity still points at M). Record M's 5-hour window from the ChatGPT backend dashboard: 7% used (window resets 17:24 local).
- Send one long turn. The thread migrates to P (visible in
usage.jsonl:accountLogLabelswitches from none/main to the pool label). The session runs 19:44:47–20:22:56 local: 187 dispatched requests (186 completed + 1 aborted at 20:22:5x with HTTP 499 and no token report), 20.65M tokens (97% cache hits), modelsgpt-6-sol(177) andcodex-auto-review(9). - Read M's backend dashboard again at 20:47:38: M's 5-hour window is now 52% used — i.e. +45 points with zero locally attributed main requests. (This read was observed live; no screenshot was retained. It is corroborated by
codex-quota-cache.json, whose 6-minute samples from 21:45–22:08 show M frozen at 5h 52% / weekly 73%, and by the absence of any M-attributed event after 19:44:47 in the rollouts.) - Cross-checks performed (all local, read-only):
usage.jsonl(full proxy ledger, 668 rows for the day): all 187 requests in the window carry the pool label; 0 rows attributed to M.~/.opencodex/responses-state-spill/: 628 spill files ↔ usage rows 1:1 (one 176 s gap, rest second-exact) — no off-ledger responses.spend-ledger.jsonl: all 187reserverecords in the window carry both targets, e.g.targets: [{scope: "identity", alias: "0e403d4824…"}, {scope: "pool", alias: "91c1cb36c8…"}].- All session rollouts (1019
token_countevents, day-wide, attributed by weekly-reset anchors): M's last inference event is at 19:44:47 (5h 7% / weekly 66%) — the exact moment the thread left M. No M event afterwards. codex-quota-cache.jsonsamples every 6 min from 21:45 to 22:08: M frozen at 5h 52% / weekly 73% — matching the 20:47:38 backend read, so M's window stopped moving when the session ended.
- Same pattern in a second window the same day: M's 5-hour window (reset 12:01:35) had climbed to 66% by 13:28:25, while the only locally attributed M activity inside that window was two requests at 13:13 with no reported token usage — nowhere near the ~170–190K tokens/point calibration (66 points ≈ 11M tokens). During the same window the pool account P served 264 requests and its own 5-hour window went 0% → 78%.
- Control (negative): after the Codex App was restarted at 21:37 (auth.json refreshed), 8 subsequent pool sends (~1.3M tokens, 21:39–21:40) produced no M movement between the 20:47:38 and 21:45:40 reads. The phantom tracks the "App holds M's credential + pool selection" combination, not pool traffic per se.
Quantitatively: M's +45 points (dashboard reads: 7% → 52%) vs P's +43 points within the same window (event-level from rollouts: 5% at the first in-window event 19:44:54 → 48% at the last 20:22:56; +46 across P's full 5-hour window from 2% at its 17:57:58 reset). Calibrated against M's own attributed requests (~170–190K tokens/point), 45 points ≈ 8.5M tokens, i.e. the phantom is the same order as a full copy of the pool session's billable work.
Version
2.90.0 — confirmed as the incident-time version by two independent machine artifacts: (a) the installed package was not reinstalled or upgraded between 2026-10-21 12:25 and the incident at 19:41 (package metadata unchanged since), and (b) every usage.jsonl row in the incident window carries attempts[].codexWsStage.ocxVersion = "2.90.0" — the proxy stamped its own version into each request record at the time. The same coupling is source-visible in 2.42.0 per #3647's inspection, and the #5019 ordering fix (shipped shortly after 2.58.0, September 2026) does not remove the billing coupling.
Operating system
Windows 11 Pro 10.0.26300
Provider and model
openai (canonical ChatGPT backend) / gpt-6-sol, codex-auto-review (auto-derived review subagent, 9 of the 187 requests)
Logs or error output
No error is produced. Key excerpts (sanitized):
# usage.jsonl — window 19:44:47–20:22:54: 187 rows, all accountLogLabel = pool account P; zero rows for M
# last M-attributed token_count event (session rollout, all sessions, attributed by weekly resets_at anchor):
2026-10-21T19:44:47 primary(5h): used=7% resets_at=<M 5h window> secondary(weekly): used=66% resets_at=<M weekly anchor>
# backend dashboard read of M at 20:47:38: 5h used=52%, weekly used=73%
# spend-ledger.jsonl reserve row (representative, all 187 identical in shape):
{"kind":"reserve","send":"…","targets":[{"scope":"identity","alias":"0e403d4824…"},{"scope":"pool","alias":"91c1cb36c8…"}]}
(The `alias` values are per-install salted hashes — by design the journal never stores real account or credential IDs, so the truncated aliases above are meaningless outside this machine and safe to publish.)
Attribution method for the rollouts: each account's weekly window has a distinct `resets_at` anchor; the 5h `used_percent` series per anchor gives per-account curves. Happy to share the sanitized attribution script.Screenshots and supporting files
No dashboard screenshots were retained from the event window (2026-10-21 evening). The backend readings quoted in this report were observed live at the time and are corroborated by a machine-generated local artifact (quota-cache samples), so the report does not depend on screenshots. All sanitized evidence accompanies this report as a single archive, opencodex_phantom_billing_evidence.zip (.jsonl is not an allowed issue-attachment type on GitHub, hence the archive), containing:
README.md— manifest, redaction rules, key reconciliation numbers, and the commands to re-run both scripts.usage_window_slice_sanitized.jsonl— 187 usage rows for the incident window (account labels mapped to M/P, conversation IDs to C-01, token counts and status preserved).spend_ledger_window_slice_sanitized.jsonl— 187reserverecords for the same window, all carrying bothidentityandpooltargets; 186 settled + 1 aborted (the 20:22:56 send that was never settled).quota_cache_samples_sanitized.json— quota-cache history samples (6-minute cadence) for M and P2 up to 2026-10-21 23:59:59 local. Note: P's (8524's) samples from the incident night have been rotated out of the cache (it retains 200 samples per account), so P's curve evidence comes from the rollout attribution below instead.rollout_attribution_local-2026-10-21_sanitized.json— per-account usage curves for local 2026-10-21, attributed by weeklyresets_atanchors (3 accounts). Shows M's last event at 19:44:47 (5h 7% / weekly 66%) with nothing after; P's 187 events in the window (5h 5% → 48%); and the morning window (M 0% → 66% by 13:28:25 with only two no-usage M requests at 13:13).attribute_rollouts_by_reset_anchor.py— the attribution script (weekly-reset-anchor clustering, local-day filtering; generic, runs against any~/.codex/sessions).build_issue_attachments.py— the sanitizer that produced the slices above (documents every redaction rule).
Any operator with the same setup can independently verify the phenomenon by following the Reproduction steps and reading their own backend dashboard at the two time points — no artifacts from this reporter are needed to reproduce.
opencodex_phantom_billing_evidence.zip
Redacted configuration
Config shape at incident time (2026-10-21 19:41–20:47 local):
{
"providers": {
"openai": {
"adapter": "openai-responses",
"baseUrl": "https://chatgpt.com/backend-api/codex",
"codexAccountMode": "pool",
"authMode": "forward"
}
}
}
Account roster at incident time: two stored pool accounts, both `isMain: false`; **no `codexAccountPriorities` / selection-order field present**; main (M) not in `codexAccounts` (it is the native Codex App login); `activeCodexAccountId` = P (the pool account that served the session). Account IDs, tokens, emails and conversation IDs redacted. Main (M) not paused, health "Healthy", quotaRefresh ok.
(For completeness: the reporter later added a third pool account and a `codexAccountPriorities: {"__main__": -2}` entry while remediating — that is the post-incident state and is *not* what produced this report. The coupling reproduced with no selection order configured at all.)Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
Ingwannu commentedon Oct 23, 2026
I inspected the attached sanitized data without executing either supplied script. The archive contains 187 usage rows, all attributed to P and stamped OCX 2.90.0, plus 187 send reservations (186 settled and one unsettled). All reservations include identity and pool scopes; nine also include a root scope. That supports the reported local-ledger observation, and the main-account quota movement deserves investigation.
One distinction matters for diagnosis:
src/lib/spend-reservation-ledger.tsrecords several local budget scopes for one physical send.identitypluspoolis not evidence that two upstream accounts were billed, and the journal does not name the native main account merely by including an identity scope. Likewise, matching changes in two accounts' percentage windows do not alone identify the credential/account actually received by the backend. I have not reproduced the account-side quota effect or established its cause, and I am keeping this open rather than dismissing it or claiming a fix.The next useful evidence is one minimal, redacted boundary correlation: selected slot label and attempt id, transport (HTTP/WebSocket), whether this is a reused conversation/connection, and whether the effective outbound account identity matches the selected pool slot. Please report equality/category results or salted local labels, never bearer tokens, auth.json, cookies, raw account IDs or full conversations. Your sanitized attribution method can also remain separate from backend identity proof. No paid replay, live credential experiment or native-account reset is requested. A preserved boundary mismatch would justify a focused routing fix; absence of such a mismatch would leave the account-side attribution question open.
catchingxy commentedon Oct 23, 2026
Thanks — both distinctions are fair. First, the evidence hierarchy: the billing claim does not rest on the
identity+pooldual scope. It rests on backend dashboard reads (M 7% → 52%), the proxy's quota cache mirroring backend reads (frozen at 5h 52% / weekly 73% after the window), and per-request rollout attribution (M's last inference event at 19:44:47, nothing after). The ledger scopes only show that every pool send locally carries a main-identity budget target — a proxy observation, not a billing claim.Your question — effective outbound identity vs selected slot — is answerable from the proxy's own selection log (
service.log; extract attached, UTC with local rendering):Pool selected caller-owned main credential15 times, and all 15 match a main-attributed usage row to the exact second (e.g.02:44:00.940Z↔ usage row 19:44:00). In Pool mode these requests went upstream with the caller-owned main credential — real main billing. Together with 4 more caller-owned-main requests earlier that evening (17:24:34, 18:10 ×3), these 19 requests (~1.29M tokens ≈ 6.9 points at the ~187K tokens/point calibration) fully account for the 7% read at 19:44:47. So the pre-switch main usage is real, correctly billed, and completely explained.p119efd), and every upstream response's quota frames reported the pool account's windows (weeklyresets_atanchor; none reported M's anchor after 19:44:47). (Counts: the attached CSV's 191 rows = 4 main-tail rows + 186 completed pool requests + 1 aborted send at 20:22:54 with HTTP 499 and no token report — this reconciles the "187 dispatched" figure in the original report.)Source audit of the two layers where a caller identity could survive pool substitution (v2.90.0):
materializeCodexUpstreamAuth(codex/auth-context.ts:1790, pool branch) overwrites bothauthorizationandchatgpt-account-idwith the selected pool account's values — per-request headers are fenced.codexWsReuseIdentity(server/responses/codex-ws-pool.ts:33) builds the WS reuse scope and key fromauthorizationandchatgpt-account-id— a socket can never be reused across accounts, which is why the first pool send at 19:44:47 dialed a fresh socket (reused=false) instead of inheriting the main-account one.So during the phantom span, outbound identity == selected pool slot on every client-side channel (selection log, usage ledger, upstream quota frames, and both source layers) — and M's window moved +45 anyway. Under your criterion that leaves the account-side attribution open, but now with a complete client-side exclusion rather than an absent answer.
The same caller-owned-main selection also appears 43 times in an earlier session the same day (13:28:17–13:40:48 local), matching 43 main-attributed usage rows totaling ~5.98M tokens — real main-account billing through Pool mode.
Remaining answers, briefly: transport 191/191 Codex WS (
sent=true), 173/191 reused; the 9 root-scope reserves reconcile 1:1 with the 9codex-auto-reviewrequests (settle tokens match exactly); control after the 21:37 app restart: 9 sends (~1.46M tokens) on pool slots, no M movement.The question this leaves for the source side: given the proxy fences identity on both layers, is there any path by which the backend bills the caller-owned main credential for a pool-authenticated request (forwarded identity headers surviving substitution, or the credential observed during selection) — or is the +45 a backend-side split-billing behavior? No credentials included (salted labels and equality results only); no paid replay, live credential experiments, or account resets were performed. Attachments:
boundary_correlation_window_sanitized.csv(191 rows) andservice_log_selection_extract_sanitized.txt(all[codex]lines, UTC + local).service_log_selection_extract_sanitized.txt
boundary_correlation_window_sanitized.csv
Ingwannu commentedon Oct 25, 2026
I inspected both new sanitized attachments. The CSV has 191 rows: all identify Codex WS with
sent=true, 173 record reuse, and statuses are 190 × 200 plus one 499. Its slot groups are 4 main-tail rows and 187 pool rows, consistent with 186 completed pool requests plus the aborted send. The selection extract contains 62 caller-owned-main messages across the earlier sessions. This is materially more evidence than the local reservation scopes alone.I also checked the cited v2.90.0 paths: the pool branch of
materializeCodexUpstreamAuthoverwrites both Authorization andchatgpt-account-id;codexWsReuseIdentityincorporates the selected outgoing credential/account into the reuse identity. These two mechanisms do not support the simple “reuse the old main socket after pool substitution” explanation.The remaining distinction is between this client-side evidence and authoritative upstream billing attribution. A selected-slot row and a response quota window do not independently expose the identity OpenAI billed, and the extract does not prove an exhaustive absence of every other account consumer. I therefore cannot conclude either a hidden OpenCodex main-credential send or backend split billing from these files. The +45 movement remains unexplained; I am not dismissing it as the identity/pool reservation pair.
The useful next evidence is an upstream-side correlation of the already-recorded time window/request references and account usage, if the provider can supply it. Keep actual account IDs and request references out of this public thread. No paid replay, account reset, extra warmup or credential experiment is needed. Leaving the issue open with those two source paths and the reconciled counts recorded, without a billing-cause claim or speculative routing patch.
catchingxy commentedon Oct 26, 2026
Thank you for going through both attachments line by line, and especially for reading the two source paths yourself. That last part is something I could not have done from my side — I could show that the first pool send opened a new connection, but not that no path existed for reusing the old one. Your reading settles that properly.
I have no objection to the disposition. Keeping this open without a cause finding or a speculative routing patch strikes me as entirely reasonable, and I understand that evidence of this kind cannot carry the weight of an upstream attribution on its own.
One observation I would like to put on record, though I appreciate it does not change the position you described. The same pattern seems to appear a second time earlier the same day: per the usage ledger, the 5h window in effect had started at 12:01:35 local, and a reading returned at 13:28:38 showed the caller-owned main credential at 67%, while that credential's own locally attributed traffic before 13:28:17 was two records at 13:13, both with
status 200and a nullusagefield. Whether that is an independent sample or the same gap seen twice, I am not in a position to say.Thanks again for the care that went into this review.
lidge-jun commentedon Oct 28, 2026
Related progress: #7774 is merged to
devas 86da613. It makes a keyring-only native main login available to OpenCodex (the Codex answer is authoritative per lookup; a withheld token makes main unavailable for that request) and keeps quota ownership bound to the exact credential observation, including forced-refresh account replacement.It does not explain or fix the reported movement of the main account's 5-hour window while only pool-attributed requests were sent; that needs upstream attribution evidence. Keeping this issue open for that part.
lidge-jun commentedon Oct 30, 2026
Triage against current
dev(3ea8965), read-only source review.For a selected pool context,
materializeCodexUpstreamAuth(src/codex/auth-context.ts) replaces both the outgoing Authorization and the account header with the selected pool credential, and Responses, compaction and refreshed pool contexts all go through it. WebSocket reuse is keyed on the outgoing account and authorization (src/server/responses/codex-ws-pool.ts). I found no path where a request sent with a pool context is also sent with the main credential.Pool mode does make separate main-authenticated traffic, which may matter when reading the backend numbers:
src/codex/quota-auto-refresh.ts,src/codex/warmup.ts). That is billable on main and independent of the selected pool request.@catchingxy, if you still have the configuration from that day, it would help to know whether quota auto-refresh was enabled for the main account. Please don't post account identifiers or credentials.
Without that, or an authoritative upstream attribution or a reproducible outbound identity mismatch, there is no evidenced code defect to fix. Keeping this open.
lidge-jun commentedon Nov 15, 2026
Could you share evidence that ties the main account's window movement to pool requests specifically, after ruling out the paths that legitimately bill main (fallback to main, quota priming, auto-refresh warmup)? Request ids and timestamps from both the usage log and the account's usage page would be ideal.