Skip to content

Repeated early compaction across GPT-6.1 Sol and Astra: internal token counts exceed reported usage #49961

Open

Description

@future3OOO

Scope update: repeated occurrences are now independently observed across GPT-6.1 Sol and GPT-6 Astra. See the cross-session measurements below.

What version of Codex CLI is running?

codex-cli 0.159.2

Which model were you using?

gpt-6.1-sol, reasoning effort high, ChatGPT sign-in.

Platform

Linux 6.6.87.2-microsoft-standard-WSL2, x86_64, interactive Codex CLI in Herdr.

What issue are you seeing?

Codex interrupted real work for over five minutes to compact a session whose last reported usage was 193,193 tokens. Its internal compaction counter said 266,425. The extra 73,232 tokens have been reconstructed exactly from the client's accounting code.

This is unacceptable behavior for a tool intended to improve engineering productivity. Users should not have to reverse-engineer the client's token estimator to understand why it stops working while the context indicator still shows roughly a quarter of the window available. The interruption also generated another large model request. Raising settings to compensate is a workaround, not a repair.

This report supplies a current GPT-6.1 Sol reproduction and exact local arithmetic for the problem reported in #39767 and #49026. It also resembles #45074. Please connect it to the owning issue and provide a concrete fix/status rather than treating this as a request for ordinary earlier compaction.

Configuration at the incident

model_auto_compact_token_limit = 258000
model_auto_compact_token_limit_scope = "body_after_prefix"
# model_context_window was unset

The local model catalog reported a 272,000-token window with a 95% effective-window adjustment, yielding 258,400. This is the client's configured window, not a claim about GPT-6.1 Sol's maximum supported context.

The running process logged the configured 258,000 limit. This was not an assumed stale configuration or a manual /compact command.

Exact calculation

Quantity Tokens
Last server-reported input 191,910
Last server-reported output 1,283
Of that output, reasoning tokens (already included) 1,034
Last server-reported total 193,193
Client estimate of earlier encrypted reasoning, from 131 items 69,286
Client estimate of newly appended tool output 3,946
Count used for compaction 266,425
Effective full-context limit 258,400
193193 + 69286 + 3946 = 266425
266425 >= 258400 -> automatic compaction

The older-reasoning estimate was reproduced by applying the source's encrypted-length heuristic to the retained items before the last user boundary, without decrypting their contents. The fresh-tool-output estimate was reconstructed separately. Their sum matches the runtime log exactly.

The relevant sanitized log fields at 2026-10-01 10:49:20 UTC were:

post sampling token usage
 total_usage_tokens=266425
 auto_compact_scope_tokens=93720
 auto_compact_scope_limit=Some(258000)
 auto_compact_limit_scope=BodyAfterPrefix
 auto_compact_window_prefill_tokens=Some(172705)
 full_context_window_limit=Some(258400)
 full_context_window_limit_reached=true
 token_limit_reached=true

The subsequent operation was logged as run_auto_compact{reason=ContextLimit phase=MidTurn}. The full-context guard triggered even though the body-after-prefix counter was below its configured limit.

Actual interruption and extra model operation

The preceding token event was recorded at 10:49:20.660 UTC. The completed compaction checkpoint was recorded at 10:54:30.101 UTC: approximately 309.4 seconds later.

The checkpoint's compaction response ID matches its usage receipt:

Compaction request usage Tokens
Input 197,182
Cached input, included above 191,744
Output 8,202
Total reported usage 205,384

Cached tokens are not added a second time here. These are usage counts, not a claimed dollar charge. This was a real remote operation and interruption, not merely a misleading UI label.

Relevant source and what is established

The inspected source revision is d42056091aded7feb1d88ac7e83972108b2aa478; the running CLI identifies itself as 0.159.2. This report does not assume that source checkout is the exact binary build revision. Its accounting formula reproduces the observed runtime values exactly.

Relevant functions:

  • core/src/context_manager/history.rs: get_total_token_usage, get_non_last_reasoning_items_tokens, estimate_reasoning_length, estimate_item_token_count.
  • core/src/session/context_window.rs: context_window_token_status_with_config.
  • core/src/tasks/regular.rs: reset of server_reasoning_included.
  • core/src/session/turn.rs: handling of ServerReasoningIncluded and the compaction decision.

When server_reasoning_included is false, the history calculation adds estimated earlier reasoning on top of the completed response's reported usage. The captured values exactly match that branch.

Evidence boundary: this capture establishes the extra accounting and the resulting compaction. It does not include a raw response/handshake capture, so it does not independently establish whether this backend already counted every historical reasoning item or where the reasoning-included signal was lost. The earlier reports provide evidence of double-counting through this same path. Please investigate that contract rather than assuming that an absent signal proves the extra estimate is needed.

What steps can reproduce the bug?

The observed shape is a long-running GPT-6.1 Sol session with retained encrypted reasoning across user turns:

  1. Use the configuration above and continue real tool-driven work across multiple user turns.
  2. Compare the latest rollout token_count with the internal post sampling token usage log immediately before automatic compaction.
  3. Reconstruct the active history from its last compacted.replacement_history plus subsequent response items.
  4. Apply the existing estimator to earlier encrypted reasoning and newly appended tool results.
  5. Observe that the additional reasoning allowance pushes the internal count over the full-context limit while reported usage remains far below it.

The figures above come from an actual captured incident, not fabricated fixture token totals. Private prompts, tool contents, raw encrypted payloads, thread identifiers and local project paths are deliberately omitted.

What is the expected behavior?

  • Use a coherent, request-bound accounting contract for compaction. Do not add historical reasoning to reported usage unless those quantities are actually disjoint.
  • Make the displayed context usage and the compaction decision explain the same budget. If an additional allowance is required, expose it instead of silently adding tens of thousands of tokens.
  • Preserve the reasoning-accounting contract correctly across user turns, connection reuse and resume.
  • Add coverage for the missing-header/reset paths and verify the correction with real reported usage, not only synthetic totals.

Please assign an owner and give users a fix or an explicit accounting explanation. A five-minute forced interruption caused by a hidden 69K reasoning adjustment, after closely related reports have already documented this behavior, is not an acceptable default.

Follow-up: repeated across multiple Sol 6.1 and Astra sessions

This is not limited to the single session documented above. The user reports repeated early compaction in that agent, other GPT-6.1 Sol agents, and GPT-6 Astra. A bounded read-only audit now independently confirms the broader scope.

Completed compactions in four sampled session rollouts

These are distinct completed compacted checkpoints from September 30–October 1, 2026. Model identity comes from the preceding recorded turn context. “Reported usage” is the latest server-reported total before each checkpoint, not cumulative session billing.

Session (anonymous label) Recorded model Completed checkpoints Reported usage before those checkpoints
A — initial report GPT-6.1 Sol 9 185,004–222,107
B — separate session GPT-6.1 Sol 6 182,120–223,094
C — separate session GPT-6 Astra 4 183,371–222,416
D — separate session GPT-6 Astra 1 236,292

20 completed compactions across four distinct session histories. This is a sampled count, not a claim to have audited every agent or every historical event. A checkpoint plus its preceding usage proves that compaction occurred at that reported usage; it does not alone prove the trigger mechanism for every historical checkpoint.

Direct runtime confirmation of the accounting mismatch across models

For these events, the native trigger log can also be joined to the completed checkpoint:

Session Model Trigger time (UTC) Reported total Internal compaction count Effective window Time from preceding token event to completed checkpoint
A GPT-6.1 Sol Oct 1 10:49:20 193,193 266,425 258,400 309.441s
C GPT-6 Astra Sep 30 07:33:23 207,168 261,140 258,400 213.133s
D GPT-6 Astra Sep 30 22:25:09 236,292 261,095 258,400 182.374s

All three log full_context_window_limit_reached=true and token_limit_reached=true. Those three completed events alone occupy approximately 11 minutes 45 seconds between their preceding usage events and compaction checkpoints. This is summed across sessions, not a claim about one uninterrupted wall-clock interval.

A further GPT-6.1 Sol threshold event in session B at Oct 1 04:38:58 logged an internal count of 263,815 against 258,400, while the latest reported total was 187,840. The turn was subsequently interrupted at 04:41:44; it is not counted as a completed compaction in the table above.

The exact prior-reasoning/new-output arithmetic is reconstructed for session A in the initial report. The other logged events independently establish the same reported-versus-internal count mismatch and actual threshold crossing; their extra-count components have not all been reconstructed separately. Likewise, the installed CLI is 0.159.2, but this follow-up does not assign that build to every historical resume.

This is repeated lost working time across models, not an isolated bad session. Please investigate the shared accounting and signal propagation path, identify the affected versions/routes, and provide a fix with a regression test. Users should not need to inflate their context settings to compensate for an unexplained second token counter.

Activity

  1. added
    bug
    CLI
    context
    rate-limits
    on Oct 1, 2026
  2. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. changed the title [-]GPT-6.1 Sol / CLI 0.159.2: 193K displayed usage becomes 266K and forces a 5-minute compaction[/-] [+]Repeated early compaction across GPT-6.1 Sol and Astra: internal token counts exceed reported usage[/+] on Oct 1, 2026
  4. railway02 commented on Oct 2, 2026

    @railway02

    me too

  5. coinman-dev commented on Oct 4, 2026

    @coinman-dev

    Same cause here on Codex 0.159.2 with gpt-6.1-sol under WSL2. A small client patch that stops the double count is described in #39767 (comment): with it the same chat went from being compacted at 734,065 tokens to 922,856 with no early compaction, and its regression test fails on unpatched 0.160.0. Patch and notes: https://github.com/coinman-dev/codex-context-accounting-fix

  6. jfet97 commented on Oct 5, 2026

    @jfet97

    Another reproduction with CLI 0.160.0, GPT-6.1 Sol, and high reasoning effort. Automatic compaction started while the footer showed 21% context remaining.

    Measurement Tokens
    Configured context window 550,000
    Effective context window 522,500
    Configured compaction threshold 500,000
    Runtime compaction threshold 495,000
    Latest server-reported total 416,300
    Internal count triggering compaction 495,677
    Difference 79,377

    The trigger log recorded token_limit_reached=true, followed by run_auto_compact{reason=ContextLimit phase=MidTurn}. Compaction completed approximately four minutes later.

    The footer's 21% matches the reported usage with the 12,000-token baseline adjustment. The internal count crossed the threshold despite that displayed headroom.

    This confirms the reported-versus-internal accounting discrepancy on 0.160.0. It does not independently establish whether historical reasoning was already included by the backend or where the reasoning-included signal was lost.

    Please investigate the shared accounting path and make the displayed percentage reflect the budget used for compaction.

  7. johnnywang commented on Oct 10, 2026

    @johnnywang

    Additional reproduction on Codex CLI 0.162.1, model gpt-6.1-sol, reasoning effort xhigh, using the default compaction limits (no explicit context-window or auto-compaction-limit overrides).

    The TUI showed 67% context used when automatic compaction started.

    Reconstructed threshold decision

    Quantity Tokens
    Latest server-reported total 176,426
    Estimated older encrypted reasoning, 85 items 61,645
    Newly appended tool-output estimate 10,048
    Count used by the compaction guard 248,119
    Automatic-compaction threshold 244,800
    Effective full-context window 258,400

    Applying the rust-v0.162.1 history-accounting formula to the retained records, without decrypting their contents, reproduces the runtime count exactly:

    176426 + 61645 + 10048 = 248119
    248119 >= 244800 -> automatic compaction
    248119 < 258400 -> full context-window limit not reached
    

    Reviewed numeric/boolean fields from the trigger log:

    total_usage_tokens=248119
    auto_compact_scope_tokens=248119
    auto_compact_scope_limit=Some(244800)
    auto_compact_limit_scope=Total
    full_context_window_limit=Some(258400)
    full_context_window_limit_reached=false
    token_limit_reached=true
    

    The arithmetic matches the server_reasoning_included == false branch. This capture does not establish why that signal was false or whether the backend had already included earlier reasoning in reported usage.

    Display mismatch

    The TUI uses the latest reported total with its 12,000-token baseline adjustment. That calculation reproduces 33% remaining / 67% used exactly. The compaction guard simultaneously evaluates a much larger total.

    This makes context-percentage-based handoff and stoppage rules unreliable: the displayed budget and the enforced budget are different.

    Reasoning estimate worth validating

    The 85 older reasoning records originally generated 16,823 server-reported reasoning-output tokens, while their replay estimate is 61,645, approximately 3.7 times larger.

    This comparison is evidence to investigate the encrypted-length heuristic, not proof that replay occupies exactly the original number of generated tokens. A fully rendered server-side context count and verification of the reasoning-included contract are still needed to establish the correct total.

    Relevant release source

    Please validate the reasoning-accounting contract and heuristic, and expose a consistent, explicitly labeled context-budget metric for the compaction decision, UI, and agent stoppage rules.

    Only reviewed numeric diagnostics and public source references are included here. No raw logs, prompts, project details, local paths, encrypted payloads, or session/turn/response identifiers are attached.

  8. xue-ding-e commented on Oct 11, 2026

    @xue-ding-e

    Additional reproduction from the Windows desktop app on 2026-10-11 UTC, with an exact reconstruction of the discrepancy on a newer bundled core.

    Environment

    • Desktop app version: 26.1007.21434 (Windows package version 26.1007.2314.0).
    • App-launched, bundled core: codex-cli 0.162.0-alpha.17.2, running app-server.
    • Windows 11 x64, OS build 26200.
    • Model: gpt-6.1-sol; reasoning effort: max; ChatGPT sign-in.
    • The running app-server binary and the app's packaged resources/codex.exe have identical SHA-256 hashes. This is the desktop-bundled core, not an independently installed npm CLI.
    • The desktop updater currently reports up_to_date on its configured prod channel. This is not a claim about every release channel.

    Relevant configuration:

    model_context_window = 872000
    model_auto_compact_token_limit = 872000
    # model_auto_compact_token_limit_scope unset

    The runtime logged an effective window of 828,400 and an auto-compaction threshold of 784,800, with scope Total.

    Exact reconstruction

    At 16:43:39.966 UTC, the most recent rollout token event contained:

    Quantity Tokens
    Server-reported input 495,587
    Server-reported output 548
    Latest reported total 496,135
    Effective context window 828,400
    Desktop displayed occupancy 59.89%
    Estimate for 251 earlier encrypted reasoning records 304,613
    Estimate for the newly appended tool result 9,935
    Native compaction decision count 810,683
    Effective automatic-compaction threshold 784,800

    The desktop usage calculation uses the latest reported total divided by the effective context window.

    Applying the published history estimator to the recorded items, without decrypting any reasoning, reproduces the native decision exactly:

    496135 + 304613 + 9935 = 810683
    810683 >= 784800 -> token_limit_reached=true
    810683 < 828400  -> full_context_window_limit_reached=false
    

    The 304,613-token term comes from the 251 encrypted reasoning records before the latest user boundary, using the published encoded-length heuristic:

    sum(ceil(max(floor(encoded_length * 3 / 4) - 650, 0) / 4))
    = 304613
    

    The fresh tool result contains 39,700 UTF-8 content bytes and a 37-byte call ID:

    ceil((39700 + 37) / 4) = 9935
    

    These calculations match the get_non_last_reasoning_items_tokens, get_total_token_usage, and estimate_item_token_count path in the published codex-rs/core/src/context_manager/history.rs. This establishes arithmetic agreement; it does not establish that the currently published source revision is the exact binary build revision.

    Native trigger evidence

    Tracing prefixes, thread/turn identifiers, paths, and conversation content are omitted:

    2026-10-11T16:43:39Z post sampling token usage
    total_usage_tokens=810683
    auto_compact_scope_tokens=810683
    auto_compact_scope_limit=Some(784800)
    auto_compact_limit_scope=Total
    auto_compact_window_prefill_tokens=None
    full_context_window_limit=Some(828400)
    full_context_window_limit_reached=false
    token_limit_reached=true
    model_needs_follow_up=true
    has_pending_input=false
    needs_follow_up=true
    

    A completed compaction checkpoint was recorded at 16:46:11.071 UTC, approximately 151.1 seconds after the trigger. Its response ID matches a usage receipt containing:

    • Input: 505,250 tokens.
    • Output: 5,621 tokens.
    • Total: 510,871 tokens.

    Thus this caused a real remote compaction operation and interruption while the desktop indicator showed approximately 60% occupancy. It was not a manual compaction request.

    Expected behavior and limits of this capture

    Please reconcile the budget shown by the desktop indicator with the budget used by the compaction guard, and investigate the extra historical-reasoning term on this desktop/core version.

    The reconstruction matches the server_reasoning_included == false accounting branch. This capture does not independently establish why that flag was false, whether the backend already included historical reasoning in reported input usage, or whether the reasoning-included compatibility signal was absent. Those require upstream investigation; the report does not claim to have proved double-counting for this particular request.

    This was observed in an existing, long-running conversation with many tool calls and screenshots. There is no deterministic minimal reproduction from a fresh conversation yet. Raw transcripts, encrypted reasoning blobs, credentials, and unrelated machine settings are not attached. No configuration or bundled binaries were modified as a workaround.

  9. GuXinghai commented on Oct 12, 2026

    @GuXinghai

    Additional Windows Codex Desktop reproduction with the default 373,000-token window, rather than a manually enlarged window.

    Environment: bundled core 0.162.0-alpha.17.2, gpt-6.1-sol, reasoning effort medium. No explicit model_context_window or model_auto_compact_token_limit overrides. The catalog window was 373,000, the effective window 354,350, and the runtime auto-compaction threshold 335,700, with scope Total.

    At 2026-10-12 02:17:32 UTC, the completed ordinary response (R1) reported:

    Measurement Tokens
    Input 245,156
    Cached input, included above 243,712
    Output 95
    Reasoning output, included in output 0
    Reported total (U) 245,251
    Estimate for 96 older encrypted reasoning items (R) 95,703
    Newly appended tool-result estimate (N) 154
    Native compaction count 341,108

    The 95,857-token difference is reconstructed exactly, without decrypting reasoning:

    U + R + N = 245251 + 95703 + 154 = 341108
    R = sum(ceil(max(floor(encoded_length * 3 / 4) - 650, 0) / 4))
    N = ceil((578 UTF-8 content bytes + 37 call-ID bytes) / 4) = 154
    

    Sanitized native trigger fields:

    total_usage_tokens=341108
    auto_compact_scope_tokens=341108
    auto_compact_scope_limit=Some(335700)
    auto_compact_limit_scope=Total
    full_context_window_limit=Some(354350)
    full_context_window_limit_reached=false
    token_limit_reached=true
    

    This was followed by ContextLimit / MidTurn automatic compaction. The checkpoint completed at 02:19:45.800 UTC, approximately 132.8 seconds after the trigger. A continuous pre-compaction interval (01:27:01–02:17:32 UTC) containing 22 runtime nodes matched U+R+N exactly.

    The separate compaction response (R2) reported input 245,438, cached input 244,992, output 4,420, reasoning output 0, and total 249,858. R1 and R2 have distinct response identities in the same turn. Reconstructed local logical histories retained the same 96 reasoning items, verified by order, encoded lengths and SHA-256; the corresponding source preserves these items in the prompt paths. This is not a capture of the full wire payload. The 282-token input difference cannot independently establish whether historical reasoning was included: shared components cancel. The total-usage difference also includes the new compaction output.

    Evidence boundary: the extra historical-reasoning estimate and resulting compaction are established. The arithmetic exactly matches the server_reasoning_included=false branch, but no direct flag observation, handshake-response headers or per-item input attribution are available for this request. #49026's Sol Responses Lite / all-turns protocol observation and #39767 strongly motivate investigating overlap; they do not prove this particular WebSocket request double-counted reasoning.

    Version-matching public source: tag rust-v0.162.0-alpha.17.2, commit 740e5af33c71225640e0c1c1555c514c2c93ab74. The calculation matches exactly; an exact binary-to-source build correspondence has not been established.

    Could maintainers verify the GPT-6.1 Sol Responses Lite / all_turns / WebSocket input-usage contract, compatibility-header propagation, and request-bound compaction accounting? The catalog and source support Lite/all-turns for this configuration, and runtime logs identify WebSocket transport; complete request parameters were not captured. If reported usage already covers historical reasoning, the additional estimate should not be added again. Under that condition, U+N=245405 would leave 90,295 tokens below the auto-compaction threshold, making this compaction avoidable.

    Only sanitized numerical evidence and public source references are shared. No raw logs, transcripts, encrypted payloads, credentials, personal paths or session/turn/response identifiers are attached.

  10. Zeno-Young-GitHub commented on Oct 13, 2026

    @Zeno-Young-GitHub

    Another reproduction on Windows Codex Desktop with bundled core 0.162.0-alpha.17.2, model gpt-6.1-sol, reasoning effort max, and ChatGPT sign-in.

    Configuration:

    model_context_window = 1000000
    model_auto_compact_token_limit = 900000
    # model_auto_compact_token_limit_scope unset

    On 2026-10-13 at approximately 02:42:09 UTC, automatic compaction started while the desktop indicator showed 60% used (498K / 828K).

    Measurement Tokens
    Latest server-reported input 497,360
    Latest server-reported output 511
    Latest reported total 497,871
    Internal compaction decision count 792,463
    Effective compaction threshold 784,800
    Effective context window 828,400
    Internal-versus-reported difference 294,592

    The native runtime log recorded:

    total_usage_tokens=792463
    auto_compact_scope_tokens=792463
    auto_compact_scope_limit=Some(784800)
    auto_compact_limit_scope=Total
    full_context_window_limit=Some(828400)
    full_context_window_limit_reached=false
    token_limit_reached=true
    

    No manual compaction was requested. The same conversation previously compacted at approximately 66% displayed usage, so this is a repeated occurrence.

    This closely matches the other Windows desktop reproduction in this issue. I have not yet reconstructed the extra 294,592 tokens or verified whether historical reasoning was already included by the backend; these observations establish the accounting/display discrepancy rather than independently proving double-counting.

    Please investigate the historical-reasoning accounting path, reconcile the displayed and enforced context budgets, and clarify why the configured 900,000-token threshold becomes 784,800 at runtime.

  11. martinmclee commented on Oct 14, 2026

    @martinmclee

    Additional reproduction on 2026-10-14 with Codex 0.162.0, GPT-6.1 Sol, and Max reasoning effort. Automatic compaction started at approximately 287K reported tokens, despite a catalog context window of 500K.

    Environment

    • Codex Desktop connected to a remote Linux runtime, kernel 7.0.0-31-generic, x86_64.
    • The affected session's session_meta records client version 0.162.0, originator Codex Desktop, and source vscode. The installed CLI also reports codex-cli 0.162.0.
    • Model: gpt-6.1-sol; reasoning effort: max; ChatGPT sign-in.
    • No model_context_window or model_auto_compact_token_limit override was found in the host's global config.toml.

    Reported usage versus the compaction decision

    At approximately 03:39:10 UTC / 11:39:10 Hong Kong time, the latest model-reported usage and the matching native threshold check disagreed:

    Measurement Tokens
    Catalog context window 500,000
    Effective context window 475,000
    Runtime automatic-compaction threshold 450,000
    Latest reported input 286,879
    Latest reported output 14
    Latest reported total 286,893
    Internal count used for compaction 451,798
    Internal-versus-reported difference 164,905

    Cached input was 283,520, already included in input. Reasoning output was 14, already included in output. Those subtotals are not added again in the reported total above.

    Sanitized native trigger fields:

    total_usage_tokens=451798
    auto_compact_scope_tokens=451798
    auto_compact_scope_limit=Some(450000)
    auto_compact_limit_scope=Total
    auto_compact_window_prefill_tokens=None
    full_context_window_limit=Some(475000)
    full_context_window_limit_reached=false
    token_limit_reached=true
    model_needs_follow_up=true
    has_pending_input=true
    needs_follow_up=true
    

    The next operation was run_auto_compact{reason=ContextLimit phase=MidTurn}. The completed compacted checkpoint was recorded at 03:41:49.482 UTC, approximately 159 seconds after the preceding token-count event at 03:39:10.472 UTC.

    Requested behavior and evidence limits

    Please investigate the unexplained 164,905-token adjustment, reconcile displayed context usage with the budget enforced by the compaction guard, and avoid compaction while the actual request still has sufficient room. If an additional allowance is valid, the context display should expose and explain it.

    This confirms the accounting discrepancy and a completed automatic compaction on 0.162.0. I have not reconstructed the extra-count components or captured the reasoning-included signal, so this incident does not independently prove historical-reasoning double-counting. It closely resembles the other incidents here and #49026.

    This occurred in an existing long-running conversation, with no deterministic fresh-session reproduction yet. Only sanitized numerical diagnostics are included; raw conversation content, credentials, project paths, encrypted payloads, and session/turn/response identifiers are omitted.

    Martin

  12. Muelmue commented on Oct 16, 2026

    @Muelmue

    Additional reproduction on 2026-10-16: automatic compaction started at 59.84% displayed context usage.

    Environment:

    • Codex Desktop on macOS
    • Bundled CLI: 0.162.0-alpha.17.2
    • Model: gpt-6-astra
    • Reasoning effort: high
    • model_context_window = 872000
    • model_auto_compact_token_limit = 784800
    • Effective context window: 828400
    • Runtime compaction scope: Total

    At 00:31:43 UTC, the latest reported usage and the internal compaction counter differed:

    Component Tokens
    Latest reported input + output 495,710
    Estimated earlier encrypted reasoning, 480 items 410,584
    Newly appended tool-output estimate 5,266
    Internal compaction count 911,560

    Reconstructing the retained history using the matching CLI source reproduces the runtime count exactly:

    495710 + 410584 + 5266 = 911560

    The runtime logged both token_limit_reached=true and full_context_window_limit_reached=true. Compaction completed at 00:33:44 UTC, about two minutes later. This was automatic compaction, not a manual request.

    The preceding successful HTTP response did not contain X-Reasoning-Included.

    A separate two-turn synthetic HTTP probe against the ChatGPT Codex backend, using the same OAuth account and model, also returned HTTP 200 and response.completed without that header. The second request replayed the first response's encrypted reasoning. Its usage attribution included 13 input tokens for historical reasoning, within 73 total input tokens; the attribution sum matched the reported input total.

    The probe used HTTP client-version header 0.163.0; the affected desktop CLI remained 0.162.0-alpha.17.2. These were new short requests, not an exact replay of the long-session incident. They demonstrate that historical reasoning can be included in reported usage while the header is absent, but do not independently prove inclusion of every historical reasoning item in the original incident.

    Please investigate the header-dependent reasoning fallback and reconcile the displayed context usage with the count used to trigger compaction.

  13. shaoxu-wang commented on Nov 19, 2026

    @shaoxu-wang

    I observed a similar compaction event in a long-running Codex desktop chat using GPT-6.2 Sol through a custom Responses provider.

    Environment

    • Windows x64, Codex desktop package 26.1111.2228.0, core 0.170.0 as recorded in the rollout
    • GPT-6.2 Sol, max reasoning effort
    • Requests routed through Magpie v0.1.4504
    • Configured context window: 400,000 tokens. Effective window recorded at turn start and in usage events: 380,000 tokens.
    • Configured automatic compaction limit: 360,000 tokens

    Observed behavior

    On November 19, 2026 (UTC), the ordinary response reported 278,632 tokens at 02:43:09.127. After a tool result was appended, the matching token_count event at 02:43:14.120 recorded last_usage_includes_reasoning=false.

    The gateway logged a compaction request at 02:43:14.149, and the rollout recorded compacted at 02:44:25.210 in the same turn. The sequence is consistent with automatic mid-turn compaction. The capture has no explicit runtime trigger reason or scope.

    Token accounting reconstruction

    The estimates below use the Codex 0.170.0 history estimator.

    Quantity Tokens
    Latest API-reported total (U) 278,632
    Estimate for 63 earlier encrypted reasoning items (R) 106,020
    Estimate for the newly appended tool result (N) 398
    Reconstructed count (U + R + N) 385,050
    Counterfactual if the API total already included historical reasoning (U + N) 279,030
    Configured automatic compaction limit 360,000

    The reconstructed count crosses the configured limit, while the counterfactual stays below it. 385,050 is a reconstruction from the rollout. The runtime decision count was unavailable.

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

    CLIbugcontextrate-limits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions