Repository navigation
Description
Source-audit correction: The original 8,861,733,667 figure below is the legacy running-counter subtotal. Summing the more complete per-response ledger over the same fixed 36-hour window gives 8,949,499,238 tokens across 50,465 unique response IDs, with zero duplicate response IDs and zero cross-session attribution mismatches. The difference is 87,765,571 tokens, including 260 installed compaction requests totaling 87,636,109 tokens. See the source findings appended below. The original measurement is retained for auditability.
Excessive cached context processing in Codex desktop across 36 hours
Summary
During 36 hours of local Codex desktop use, telemetry recorded 8,861,733,667 input-plus-output tokens across 50,204 usage increments and 293 sessions, including subagents. Of the input, 98.40% was cached. Long-running research and implementation chats generated thousands of coordination steps, repeatedly processing large contexts.
Please investigate whether this volume is expected, whether context management and agent orchestration are producing avoidable work, and whether the associated subscription and credit deductions were correct. Local telemetry establishes the volume; it does not establish the server-side charging formula or prove incorrect billing.
This appears closely related to openai/codex#44884. This report is additional evidence for that investigation, rather than a claim of a separate root cause.
Environment and window
- macOS 26.6.2, Darwin 25.6.0
- Local Codex desktop sessions; runtime versions recorded in session metadata:
0.155.0-alpha.9.2,0.155.0-alpha.16.3,0.162.0-alpha.17.2and0.163.0-alpha.10.2(session metadata may predate execution in this window) - Two account identities appear in local session creation metadata; account identities are excluded from attachments
- Telemetry contains subscription plan identifiers
proandpromax - October 17, 2026 07:34:16 through October 18, 2026 19:34:16 America/Los_Angeles
- October 17, 2026 14:34:16 through October 19, 2026 02:34:16 UTC
- Main models include GPT-6 Astra and GPT-6.1 Sol, with varying reasoning settings
- During the incident, the configured concurrent subagent limit was 40 per session
The desktop application marketing version has not been verified. Runtime version and application version should not be conflated.
Measured usage
| Metric | Value |
|---|---|
| Sessions with usage in the window | 293 |
| Positive cumulative usage increments | 50,204 |
| Input tokens | 8,844,202,627 |
| Cached input tokens, included in input | 8,702,544,000 |
| Uncached input tokens | 141,658,627 |
| Output tokens | 17,531,040 |
| Reasoning output tokens, included in output | 4,458,627 |
| Total input plus output | 8,861,733,667 |
Cached input is not added to input a second time. Reasoning output is not added to output a second time. These totals represent accounted token processing, not unique text, network bytes or full-price tokens.
The three largest root workloads, including their descendants, accounted for approximately 5.602 billion, 1.470 billion and 1.349 billion tokens. The largest workload contained 152 sessions over the full 36-hour window. The full anonymous workload totals are in the prepared evidence package.
Observed behavior
In the narrower 24-hour window inspected within this period:
- One research workload had 122 sessions including the root, 4,282 inter-agent send-message calls and 752 follow-up-task calls
- One coordinator made 1,859 positive usage increments, averaging approximately 203,000 input tokens per increment
- A separate implementation workload had only four sessions, but made 6,174 positive usage increments, with 1,027 inter-agent messages and 394 follow-up-task calls
- Two workers in that implementation workload averaged approximately 210,000 and 220,000 input tokens per increment
- Some subagent trees reached depth four
- Half-hourly scheduled continuations kept two workloads active; later continuation attempts encountered usage-limit errors
These observations show that concurrency alone does not explain the volume. Repeated steps in a small number of long-lived contexts can also produce very high usage.
Local snapshots recorded multiple allowance windows reaching 100%, and credit balances declining to zero. Account switching or resets may explain changes between windows. We cannot attribute every deduction to an account from session creator metadata, and are not claiming duplicate billing across accounts.
Workload pattern for reproduction
This is an observed workload pattern, not a verified minimal reproduction:
- Start a long-running research or implementation chat with tools and subagents enabled
- Continue work through many tool operations, agent messages and follow-up tasks
- Let the same chats continue for hours, including scheduled continuations
- Inspect cumulative token usage increments and per-step input size
- Compare the accounted volume and server-side quota deductions
Please avoid reproducing this at full scale on a paid account. A bounded internal replay or instrumented test should be enough to investigate the behavior.
Expected behavior and investigation requests
Long-running tasks should avoid carrying unnecessary context through thousands of small operations. Coordination and waiting should consume as little model work as possible, and unusually expensive loops should be visible to the user before an allowance is exhausted.
Please investigate:
- Whether each recorded usage increment corresponds to a distinct billed inference
- Whether cumulative usage counters include retries, repeated accounting or child usage already counted elsewhere
- How cached input and reasoning output were weighted against the subscription allowance and purchased credits
- Whether compaction, retention of tool results or repeated agent coordination caused unnecessary context processing
- Whether the subagent limit of 40 was enforced across each complete descendant tree
- Whether guardrails can bound coordination loops and alert users to rapidly increasing usage
The recorded data does not prove a concurrency-limit breach: total sessions over time can legitimately exceed the concurrent limit.
Evidence method and privacy
The evidence was generated from local rollout JSONL files referenced by the local thread index. For each session, the extractor walks cumulative counters in file order, including records before the window to establish the baseline. It sums positive changes within the fixed window and excludes repeated unchanged snapshots. Sessions are aggregated once each, including archived sessions indexed locally.
The extraction found zero counter decreases and zero input-plus-output arithmetic mismatches. summary.json records these checks. Run python3 verify_evidence.py to independently verify the evidence totals. sanitized-token-events.jsonl.gz contains timestamped positive increments, anonymous session and workload labels, model and reasoning settings, context sizes and selected rate-limit metadata. sanitized-session-summary.csv records anonymous parent-child relationships and per-session totals.
No prompts, responses, tool arguments or outputs, source code, original session identifiers, account identifiers, emails, usernames, workspace names, filesystem paths, credentials or authentication material are included in the sanitized telemetry files. Exact event timestamps remain for investigation. Unrecorded or unindexed activity on other devices is outside this dataset.
Mitigation already applied
After this measurement window, concurrency was reduced to three subagents per session, with GPT-6.1 Sol and low reasoning as subagent defaults. This is a precaution, not a demonstrated fix. The main-chat default and existing schedules were unchanged by that configuration edit.
Sanitized log sample
Each line is a positive per-session cumulative counter delta, not a raw cumulative total. Session and workload labels are anonymous.
{"timestamp_utc":"2026-10-17T15:45:57.414Z","session":"session-016","workload":"workload-06","model":"gpt-6-astra","reasoning_effort":"ultra","usage_delta":{"input_tokens":204944,"cached_input_tokens":197760,"cache_write_input_tokens":0,"output_tokens":467,"reasoning_output_tokens":261,"total_tokens":205411},"last_input_tokens":204944,"context_window":258400,"weekly_used_percent":91.0,"window_minutes":10080,"plan_type":"pro"}
{"timestamp_utc":"2026-10-17T15:46:04.998Z","session":"session-016","workload":"workload-06","model":"gpt-6-astra","reasoning_effort":"ultra","usage_delta":{"input_tokens":205423,"cached_input_tokens":204800,"cache_write_input_tokens":0,"output_tokens":478,"reasoning_output_tokens":139,"total_tokens":205901},"last_input_tokens":205423,"context_window":258400,"weekly_used_percent":91.0,"window_minutes":10080,"plan_type":"pro"}
{"timestamp_utc":"2026-10-17T15:46:08.268Z","session":"session-016","workload":"workload-06","model":"gpt-6-astra","reasoning_effort":"ultra","usage_delta":{"input_tokens":206530,"cached_input_tokens":205312,"cache_write_input_tokens":0,"output_tokens":149,"reasoning_output_tokens":73,"total_tokens":206679},"last_input_tokens":206530,"context_window":258400,"weekly_used_percent":91.0,"window_minutes":10080,"plan_type":"pro"}
{"timestamp_utc":"2026-10-17T15:46:14.646Z","session":"session-016","workload":"workload-06","model":"gpt-6-astra","reasoning_effort":"ultra","usage_delta":{"input_tokens":209197,"cached_input_tokens":206464,"cache_write_input_tokens":0,"output_tokens":336,"reasoning_output_tokens":212,"total_tokens":209533},"last_input_tokens":209197,"context_window":258400,"weekly_used_percent":91.0,"window_minutes":10080,"plan_type":"pro"}Full evidence package available
A sanitized 1.4 MB ZIP has been prepared locally with all 50,204 positive usage increments, the 293-row session summary, aggregate totals, a standard-library verification script and SHA-256 checksums. The ZIP is not attached to this issue yet; it can be provided through an agreed upload channel. No raw private rollouts need to be shared.
Archive SHA-256: 81b9439c6bdc2f8f210f7487c724c70a818b5999d02e85dc31e8b1a60c7bd08a
Verification result:
PASS: 50,204 increments, 293 sessions, 8,861,733,667 total tokens
Related issue
Related investigation: #44884
This report provides an independent macOS desktop dataset with a fixed 36-hour window and sanitized evidence. Please consolidate with #44884 if that is the preferred tracking issue.
Source audit findings
Inspected public source at rust-v0.163.0-alpha.10.2 (4ebc485ca321243727539187169425fcf972f2c4), with the compaction path also checked at rust-v0.162.0-alpha.17.2 (740e5af33c71225640e0c1c1555c514c2c93ab74). These versions occur in local session metadata; metadata alone does not establish which binary handled every resumed request.
Concrete reporting inconsistency
The per-response ledger contains 50,465 distinct response IDs and 8,949,499,238 tokens. The legacy token_count.info.total_token_usage increments contain 50,204 increments and 8,861,733,667 tokens. Zero repeated response IDs were found across the full dataset.
Of the difference, 260 response IDs match installed compactions, totaling 87,636,109 tokens. One further response contributes 129,462 tokens.
The code records compaction completion in the per-response ledger, then records its rollout-budget usage and recomputes context usage. It does not apply the same cumulative token-info update as ordinary sampling. Please confirm whether this omission from the legacy counter is intentional and which user-facing totals are affected.
Source-supported amplification mechanism
- Each sampling step constructs input from retained history
- Default compaction threshold is 90% of context capacity, permitting many costly steps below the threshold
followup_tasktriggers another turn; the concurrency limit does not bound repeated rounds- Compaction retains selected agent messages, subject to a 10,000-token per-message limit and 64,000-token shared retained-message budget
- Optional rollout-budget fallback counts weighted output and uncached input unless server-defined units are supplied; it cannot independently serve as a complete cached-token spending cap
These are source-supported mechanisms and an accounting inconsistency, not proof of duplicate billing. The main amplification still needs engineering investigation; changing concurrency alone cannot prevent it. A second sanitized per-response evidence file is available, alongside the original counter-based dataset.
Installed app inspection and offline concurrency reproducer
The installed app is version 26.1013.40934 (build 20770), bundling native codex-cli 0.163.0-alpha.10.2. Its compiled desktop JavaScript was unpacked read-only, and the native ARM64 admission functions were disassembled and compared with the matching public source tag. Runtime SHA-256: 1afb28c01d7d49e892bd75f11076b10f1451e34e0ee308a95e5ab7f69f9c84fe.
A separate concurrency defect is reproducible: check_turn_admission checks capacity without reserving it, then admit_turn increments the active count later. The source contract explicitly describes this as non-atomic. The shipped machine code likewise has a separate load/compare and later atomic increment.
- Limiter implementation
- Admission contract
- Precheck before asynchronous submission
- Later guard acquisition
A standalone Rust reproduction using those same limiter methods (with dependency stubs and visibility adjustment only) synchronizes two threads after their checks. Both then acquire guards at a configured limit of one:
configured_limit=1 concurrent_admitted=2 per_thread_observations=[2, 2]
REPRODUCED: separate check and increment admits two workers at a limit of one
This test performs no network requests or model inference. Atomic permit reservation would close that race.
This race has not been shown to cause this incident. The completed-turn history has a peak of 30 overlapping subagent turns in the largest workload, under the configured limit of 40. It is a separate defect found while investigating.
A new classification of the same response ledger finds 11,087 responses issuing only coordination tools, totaling 1,912,871,075 tokens (21.37%). Other explicit-tool responses total 6,567,145,729 tokens; responses without an explicit tool call total 469,482,434 tokens. These categories describe observed output calls, not provider billing categories or a claim that every token was unnecessary.
One coordinator ran 1,860 recorded responses in just two turns. Of its 529 waits, 135 returned within one second and 373 within ten seconds. Fresh messages can legitimately wake waits; this is evidence of frequent coordination, not proof of a broken timer.
The incident's main measured mechanism remains repeated tool/coordination steps carrying large retained histories. A single billing, scheduler or memory-corruption defect has not been established as the primary cause. The offline reproducer and additional sanitized profiling data are prepared for maintainers.
Further investigation: goal accounting excludes billed cached input
The matching source and installed ARM64 binary expose a cost-control gap relevant to this incident. The goal token metric excludes cached input, while Codex's published credit rate for cached input is nonzero. This is intentional in the source's tests, so the engineering question is whether these budget semantics and their presentation are appropriate for billed autonomous work, rather than whether the subtraction is an accidental typo.
At the installed runtime's matching commit, goal_token_delta_for_usage computes:
usage.input_tokens
.saturating_sub(usage.cached_input_tokens)
.saturating_add(usage.output_tokens.max(0))An offline Rust harness includes this entire upstream accounting file unchanged, with external dependency type stubs. It makes no model/API requests. Results:
per_response: recorded_total=200100 cached_input=200000 goal_budget_count=100
1000_responses: recorded_total=200100000 goal_budget_count=100000
1000_successful_wait_only_turns: empty_response_guard_never_trips
control: truly_empty_turns_trip_guard_at_3
The installed GoalAccountingState::progress_snapshot disassembly has the corresponding subtraction and addition at 0x1069cf250 and 0x1069cf264.
The wait-only test establishes the scope of the empty-response safeguard, not a full desktop reproduction: record_tool_outcome resets the empty-turn streak and marks activity even for successful waits. The safeguard does not measure objective progress. The within-turn sampling loop also continues for tool follow-ups or pending input; one incident coordinator made 1,860 responses in only two turns.
Matching incident evidence
- Fuller ledger: 8,949,499,238 tokens.
- Cached input: 8,788,141,824, or 98.197% of that total.
- Non-cached input plus output: 161,357,414. Applying the goal formula to all recorded responses would exclude the other 98.197%; this is a metric comparison, not the actual combined goal counter.
- 7,233,111,675 tokens, approximately 80.82%, were already on Sol 6.1 Low, attributed using the last recorded turn context. A cheaper default alone does not fix the request volume or retained-history amplification.
- One research goal reported
tokensUsed=72,457,032. In its approximate active interval (2026-10-18 04:38:26 through 08:02:15 UTC), the root and descendants recorded 4,136,902,089 total tokens, of which 4,063,375,104 were cached input. - The legacy usage path in that interval yields 72,455,823 non-cached input plus output, only 1,209 below the reported goal count. Goal timestamps are second-resolution, so this is not an exact response-level reconciliation. It supports the cache exclusion, and does not support a claim that all descendant usage was missing.
Causal limit: the inspected creation calls for the three large goals omitted token_budget, and goal reports returned remainingTokens=null. The user requested continued overnight work without specifying a token ceiling. Therefore, this incident does not demonstrate violation of a configured goal budget. It demonstrates sustained autonomous work without a spending ceiling, and a goal accounting metric that would not represent all priced usage even if a token budget were configured.
Current published Codex pricing assigns nonzero cached-input credit rates. This does not prove incorrect billing or imply cached and uncached input have the same price. The official Goals guide describes budget-limited continuation but does not define cached-input exclusion.
Please investigate a cost-aware budget shared across the root and descendants, including cached input and compaction; explicit handling of unbudgeted unattended goals; accurate labels for goal-budget units versus total tokens and billed credits; and repeated waiting/status/retry loops that do not advance the objective. Reconcile the response ledger against private billing records separately.
A sanitized v4 package is prepared locally with the unchanged upstream accounting source, license, portable Rust harness, output, minimal installed-binary disassembly, aggregates and checksums. It contains no prompts, account IDs, credentials or private project contents. The package has not been uploaded to this issue.
Focused runtime safeguard follow-up
Implementation proposal: #55180
That companion issue covers pre-request budget reservation shared by the root and descendants, complete spending units, and exhaustion/recovery behavior. The incident evidence, billing reconciliation request, reporting discrepancy and separate concurrency race remain in this report. This is a companion relationship, not a claim that the proposed safeguard proves the incident's root cause.
Source-reference correction: the earlier references used annotated release-tag object hashes as commit identifiers. The source links above now use the underlying commits: 4ebc485ca321243727539187169425fcf972f2c4 for rust-v0.163.0-alpha.10.2, and 740e5af33c71225640e0c1c1555c514c2c93ab74 for rust-v0.162.0-alpha.17.2. The inspected source remains the same; the new issue's referenced files were compared with the resolved release commit. Previously prepared evidence archives retain their original metadata and checksums.
Activity
github-actions commentedon Oct 19, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
[-]Codex desktop: 8.86B recorded tokens in 36h, 98.4% cached input across 293 sessions (related to #44884)[/-][+]Codex desktop: 8.95B recorded tokens in 36h, context amplification and omitted compaction usage (related to #44884)[/+]samvallad33 commentedon Oct 19, 2026
Hi Brendan, Codex Desktop went through 8.86B tokens in 36 hours across 293 sessions with coordinator loops of thousands of calls. Did anything warn you before the 36 hours were up? I hit the same kind of problem where an agent kept running a command it had been allowed once. If that is what happened on your end, would you want to see something combining memory, authority, and security so an agent can't keep running past a limit nobody set? Sam