Auto-compaction silently discards all conversation history since 0.145.0
What version of Codex CLI is running?
codex-cli 0.146.0
What subscription do you have?
Pro
Which model were you using?
gpt-5.6-sol
What platform is your computer?
Linux 7.0.0-28-generic x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
Ghostty, inside tmux
Codex doctor report
{
"schemaVersion": 1,
"generatedAt": "1785718273s since unix epoch",
"overallStatus": "warning",
"codexVersion": "0.146.0",
"checks": {
"app_server.status": {
"id": "app_server.status",
"category": "app-server",
"status": "ok",
"summary": "background server is not running",
"details": {
"control socket": "/home/manish/.codex/app-server-control/app-server-control.sock",
"daemon state dir": "/home/manish/.codex/app-server-daemon",
"mode": "ephemeral",
"pid file": "/home/manish/.codex/app-server-daemon/app-server.pid (missing)",
"settings": "/home/manish/.codex/app-server-daemon/settings.json (missing)",
"status": "not running",
"update-loop pid file": "/home/manish/.codex/app-server-daemon/app-server-updater.pid (missing)"
},
"remediation": null,
"durationMs": 0
},
"auth.credentials": {
"id": "auth.credentials",
"category": "auth",
"status": "ok",
"summary": "auth is configured",
"details": {
"auth file": "/home/manish/.codex/auth.json",
"auth storage mode": "File",
"stored API key": "false",
"stored ChatGPT tokens": "true",
"stored agent identity": "false",
"stored auth mode": "chatgpt"
},
"remediation": null,
"durationMs": 0
},
"config.load": {
"id": "config.load",
"category": "config",
"status": "ok",
"summary": "config loaded",
"details": {
"CODEX_HOME": "/home/manish/.codex",
"config.toml": "/home/manish/.codex/config.toml",
"config.toml parse": "ok",
"cwd": "/projects/nebulae",
"enabled feature flags": "<redacted>",
"feature flag overrides": "<redacted>",
"feature flags enabled": "45",
"log dir": "/home/manish/.codex/log",
"mcp servers": "9",
"model": "gpt-5.6-sol",
"model provider": "openai",
"sqlite home": "/home/manish/.codex"
},
"remediation": null,
"durationMs": 0
},
"git.environment": {
"id": "git.environment",
"category": "git",
"status": "ok",
"summary": "git version 2.43.0",
"details": {
".git entry": "directory",
"PATH git #1": "/usr/bin/git",
"PATH git #2": "/bin/git",
"PATH git entries": "2",
"git branch": "fix/global-tier-corrections",
"git build options": "git version 2.43.0; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /bin/sh",
"git exec path": "/usr/lib/git-core",
"git version": "git version 2.43.0",
"repo detected": "true",
"repo root": "/projects/nebulae",
"selected git": "/usr/bin/git"
},
"remediation": null,
"durationMs": 22
},
"installation": {
"id": "installation",
"category": "install",
"status": "ok",
"summary": "installation looks consistent",
"details": {
"PATH codex #1": "/run/user/1000/fnm_multishells/2277064_1785710288621/bin/codex",
"PATH codex #2": "/run/user/1000/fnm_multishells/3753_1785459905889/bin/codex",
"PATH codex entries": "2",
"current executable": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
"install context": "npm (package /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
"managed by bun": "false",
"managed by npm": "true",
"managed by pnpm": "false",
"managed package root": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex",
"npm update target": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex"
},
"remediation": null,
"durationMs": 39
},
"mcp.config": {
"id": "mcp.config",
"category": "mcp",
"status": "warning",
"summary": "MCP configuration has optional issues",
"details": {
"configured servers": "9",
"disabled servers": "1",
"playwright": [
"env var DISPLAY is not set",
"env var WAYLAND_DISPLAY is not set",
"env var XAUTHORITY is not set"
],
"stdio servers": "8",
"streamable_http servers": "1"
},
"remediation": "Set the missing MCP env vars or disable the affected server.",
"durationMs": 3241
},
"network.env": {
"id": "network.env",
"category": "network",
"status": "ok",
"summary": "network-related environment looks readable",
"details": {
"proxy env vars": "none"
},
"remediation": null,
"durationMs": 0
},
"network.provider_reachability": {
"id": "network.provider_reachability",
"category": "reachability",
"status": "ok",
"summary": "active provider endpoints are reachable over HTTP",
"details": {
"ChatGPT base URL": "https://chatgpt.com/backend-api/ reachable (HTTP 403)",
"reachability mode": "ChatGPT auth"
},
"remediation": null,
"durationMs": 39
},
"network.websocket_reachability": {
"id": "network.websocket_reachability",
"category": "websocket",
"status": "ok",
"summary": "Responses WebSocket handshake succeeded",
"details": {
"DNS": "2 IPv4, 2 IPv6, first IPv6",
"auth mode": "chatgpt",
"connect timeout": "15000 ms",
"endpoint": "wss://chatgpt.com/backend-api/<redacted>",
"handshake result": "HTTP 101 Switching Protocols",
"model provider": "openai",
"models etag present": "true",
"provider name": "OpenAI",
"proxy env vars": "none",
"reasoning header": "false",
"server model present": "false",
"supports websockets": "true",
"wire API": "responses"
},
"remediation": null,
"durationMs": 693
},
"runtime.provenance": {
"id": "runtime.provenance",
"category": "runtime",
"status": "ok",
"summary": "running npm on linux-x86_64",
"details": {
"commit": "unknown",
"current executable": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
"install method": "npm (package /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl, bin /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin, resources /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-resources, path /home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path)",
"platform": "linux-x86_64",
"version": "0.146.0"
},
"remediation": null,
"durationMs": 0
},
"runtime.search": {
"id": "runtime.search",
"category": "search",
"status": "ok",
"summary": "search is OK (bundled)",
"details": {
"search command": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/codex-path/rg",
"search command readiness": "file exists",
"search provider": "bundled"
},
"remediation": null,
"durationMs": 0
},
"sandbox.helpers": {
"id": "sandbox.helpers",
"category": "sandbox",
"status": "ok",
"summary": "sandbox configuration is readable",
"details": {
"approval policy": "Never",
"codex-linux-sandbox helper": "/home/manish/.codex/tmp/arg0/codex-arg04iiWXv/codex-linux-sandbox",
"execve wrapper helper": "/home/manish/.codex/tmp/arg0/codex-arg04iiWXv/codex-execve-wrapper",
"filesystem sandbox": "unrestricted",
"network sandbox": "enabled"
},
"remediation": null,
"durationMs": 0
},
"state.paths": {
"id": "state.paths",
"category": "state",
"status": "ok",
"summary": "state paths and databases are inspectable",
"details": {
"CODEX_HOME": "/home/manish/.codex (dir)",
"active rollout files": "965 files, 482132177 total bytes, 499618 average bytes",
"archived rollout files": "0 files, 0 total bytes, 0 average bytes",
"goals DB": "/home/manish/.codex/goals_1.sqlite (file)",
"goals DB integrity": "ok",
"log DB": "/home/manish/.codex/logs_2.sqlite (file)",
"log DB integrity": "ok",
"log dir": "/home/manish/.codex/log (dir)",
"memories DB": "/home/manish/.codex/memories_1.sqlite (file)",
"memories DB integrity": "ok",
"sqlite home": "/home/manish/.codex (dir)",
"state DB": "/home/manish/.codex/state_5.sqlite (file)",
"state DB integrity": "ok",
"thread history DB": "/home/manish/.codex/thread_history_1.sqlite (missing)",
"thread history DB integrity": "skipped (missing)"
},
"remediation": null,
"durationMs": 168
},
"state.rollout_db_parity": {
"id": "state.rollout_db_parity",
"category": "threads",
"status": "ok",
"summary": "rollout files and state DB thread inventory agree",
"details": {
"default model provider": "openai",
"rollout DB active files": "965",
"rollout DB active rows": "965",
"rollout DB archive mismatches": "0",
"rollout DB archived files": "0",
"rollout DB archived rows": "0",
"rollout DB duplicate DB paths": "0",
"rollout DB duplicate rollout thread ids": "0",
"rollout DB malformed file names": "0",
"rollout DB missing active rows": "0",
"rollout DB missing archived rows": "0",
"rollout DB model providers": "argo=531, openai=434",
"rollout DB rows": "965",
"rollout DB scan cap reached": "false",
"rollout DB scan errors": "0",
"rollout DB sources": "exec=603, subagent:other=176, cli=81, subagent:thread_spawn=75, mcp=26, subagent:review=3, subagent:memory_consolidation=1",
"rollout DB stale rows": "0"
},
"remediation": null,
"durationMs": 135
},
"system.environment": {
"id": "system.environment",
"category": "system",
"status": "ok",
"summary": "OS language en-US",
"details": {
"EDITOR": "set",
"LANG": "en_US.UTF-8",
"LESS": "set",
"PAGER": "set",
"VISUAL": "set",
"os": "Ubuntu 24.4.0 (noble) [64-bit]",
"os language": "en-US",
"os type": "Ubuntu",
"os version": "24.4.0"
},
"remediation": null,
"durationMs": 5
},
"terminal.env": {
"id": "terminal.env",
"category": "terminal",
"status": "ok",
"summary": "terminal metadata was detected",
"details": {
"SSH_CLIENT": "present",
"SSH_CONNECTION": "present",
"TERM": "xterm-ghostty",
"TERM_PROGRAM": "ghostty",
"color output": "disabled (stdout is not a terminal)",
"effective locale": "en_US.UTF-8",
"multiplexer": "tmux 3.4",
"stderr is terminal": "false",
"stdin is terminal": "false",
"stdout is terminal": "false",
"terminal": "Ghostty",
"terminal size": "80x24",
"terminal version": "1.3.1",
"tmux allow-passthrough": "on",
"tmux client termname": "xterm-ghostty",
"tmux client termtype": "ghostty 1.3.1",
"tmux extended-keys": "off",
"tmux focus-events": "off",
"tmux set-clipboard": "external",
"tmux xterm-keys": "on"
},
"remediation": null,
"durationMs": 12
},
"terminal.title": {
"id": "terminal.title",
"category": "title",
"status": "ok",
"summary": "terminal title default",
"details": {
"terminal title activity": "true",
"terminal title items": "activity, project-name",
"terminal title project source": "git repo root",
"terminal title project value": "nebulae",
"terminal title source": "default"
},
"remediation": null,
"durationMs": 0
},
"updates.status": {
"id": "updates.status",
"category": "updates",
"status": "ok",
"summary": "update configuration is locally consistent",
"details": {
"cached latest version": "0.146.0",
"check for update on startup": "true",
"last checked at": "2026-08-02T22:38:14.386301498Z",
"latest version": "0.146.0",
"latest version status": "current version is not older",
"npm update target": "/home/manish/.local/share/fnm/node-versions/v24.14.0/installation/lib/node_modules/@openai/codex",
"update action": "npm install -g @openai/codex",
"version cache": "/home/manish/.codex/version.json"
},
"remediation": null,
"durationMs": 158
}
}
}
What issue are you seeing?
Since 0.145.0, auto-compaction sometimes discards the whole conversation instead of summarizing it. The session continues but the model has no memory of it, and the next turn opens with the agent asking what to work on.
In the rollout, the compacted record's replacement_history holds only the four boot preamble messages (three developer, one user). A healthy compaction ends with an additional summary item that has no role; on a failure that item is absent.
The agent's next message was:
What would you like to work on in /path/to/project?
There is no error. The TUI reports a successful compaction and last_token_usage drops from 225,050 to 28,030, which is the preamble alone.
What steps can reproduce the bug?
No deterministic repro, since it is threshold-triggered on long sessions. I characterized it across my stored rollouts instead, counting every compacted record and treating a replacement_history of exactly [developer, developer, developer, user] as a failure. ChatGPT auth only, no custom provider:
<!-- linear:table-colwidths:266,266,266 -->
| CLI version | compactions | context lost |
| -- | -- | -- |
| 0.135.0 - 0.144.3 | 45 | 0 |
| 0.145.0 | 8 | 7 |
The first 0.145.0 compactions were healthy, then every one after 2026-07-24 19:00 UTC failed, with no version change in between. That points at a server-side component rather than the client alone.
To check your own rollouts:
find ~/.codex/sessions -name '*.jsonl' -exec jq -c \
'select(.type=="compacted")
| {n: (.payload.replacement_history|length),
roles: (.payload.replacement_history|map(.role))}' {} +
Healthy rows end in null, which is the summary item. Failed rows are exactly ["developer","developer","developer","user"].
0.146.0 is absent from the table because my recent long sessions on it ran through a different model provider. The failure looks identical there, so I do not believe 0.146.0 fixes it.
What is the expected behavior?
Compaction should replace history with the preamble plus a summary. If summarization returns nothing, it should surface an error and leave history intact rather than silently discarding it.
Additional information
Two leads from strings in the 0.146.0 binary, offered as pointers rather than conclusions:
"A new context window will start without summarizing conversation history."describes the observed outcome exactly. If anew_contextpath is reachable from an auto-compaction trigger, that would match.auto_compact_fallback_promptandauto_compact_fallback_buffer_tokenssuggest a fallback compaction path. If the primary summarization fails and the fallback yields empty output, an unconditional history replacement would produce this.
Related but distinct: openai/codex#33493 (local compaction v2, unbounded images) and openai/codex#34428 (remote compaction ignoring compact_prompt).
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I found a strong configuration-level A/B result for the exact four-item failure signature reported here.
Environment
26.727.6591.0codex-cli 0.146.0-alpha.9.2gpt-5.6-sol258400remote_compaction_v2:stable / truethroughout the testtoken_budget: shown bycodex features listasunder developmentI scanned all top-level
type="compacted"records in my local session JSONL files around the configuration change.| Configuration period | Compactions | Healthy | Four-item failures |
| --- | ---: | ---: | ---: |
| Before enabling
token_budget| 12 | 12 | 0 ||
token_budget = true| 7 | 0 | 7 ||
token_budget = false, after restarting Codex | 4 | 4 | 0 |The seven failures occurred between 2026-08-03 09:41:55 UTC and 16:35:45 UTC.
Every failure had exactly:
Those four items contained only the startup/context envelope. The active user request, progress, tool results, conclusions, and next action were absent. The agent then asked what task it should work on.
After setting:
and restarting Codex, four subsequent automatic compactions succeeded. Their replacement histories contained 7 or 8 items and ended with the expected role-less summary item. No task loss occurred.
One correction to my earlier interpretation:
payload.message == ""was present in both failed and healthy records, so an emptypayload.messagealone is not a reliable failure indicator. The useful discriminator is the four boot-only messages with no trailing summary item.This A/B result is consistent with the current open-source implementation:
Feature::TokenBudgetbefore selecting remote or local summarizing compaction:session/turn.rs.compact_token_budget.rs.This behavior and the proposed separation of TokenBudget reminders from summary-free rollover are already documented in #36057.
Therefore, in my affected sessions, the four-item context loss was caused by
token_budget = true, not byremote_compaction_v2alone.remote_compaction_v2remained enabled while compaction worked normally after disabling TokenBudget.This does not prove that every reproduction in this issue has the same cause, because affected users may have different feature flags. However, checking the effective
token_budgetvalue withcodex features listshould provide a deterministic first diagnostic.Current workaround
token_budget = false.Expected product behavior
One of the following would avoid this silent task loss:
new_context.I can reproduce this on current Codex Desktop / CLI
0.150.0-alpha.8on Windows withgpt-5.6-luna(High). I hit the same failure twice in one session, on two different user follow-up tasks.Repro 1: diagnostic task disappears
A long previous task ended with the context already near capacity. I then sent a new bug report with a log attachment. Luna correctly accepted the task and performed two useful diagnostic reads.
Immediately before compaction, telemetry showed:
The next rollout record was:
I inspected
replacement_history. It contained only the static/injected context (app/developer context, memory instructions, context-window metadata, subagent/multi-agent hints, and the AGENTS/environment user payload). It did not contain:A few seconds later the model responded with the equivalent of:
So from the post-compaction model's point of view there really was no active task left.
Repro 2: task disappears mid-edit
A later follow-up reported a concrete runtime assertion from an unlocked simulation-speed feature. Luna correctly diagnosed the exact problem: a value of
25was reaching a vanilla API that asserts1..20. It explicitly announced the intended prefix-clamp/postfix-restore fix and then modified the source accordingly.Immediately before the next compaction:
Again, the next record was a
type: "compacted"event with:and the replacement history again lacked the current user request/task state. Four seconds later Luna replied:
Codex then marked the turn complete, despite the worktree having just been modified and no build/test validation having happened yet.
Additional detail / possible confounder
I do have the experimental token-budget feature enabled with an earlier reminder (~30k tokens remaining), plus AGENTS instructions to checkpoint task state. The reminder itself worked and, on an earlier turn, Luna created a
.codex/TASK_STATE.mdcheckpoint. However, these two failures happened when automatic compaction itself fired, and the observable failure is specifically that the resulting compaction payload had an emptymessageand replacement history with no live task/history.So the custom reminder may affect when the window approaches rollover, but it does not explain why the compaction handoff contains no task summary at all.
This looks extremely similar to the failure described here, except it is still reproducible for me on
0.150.0-alpha.8, on Windows/Desktop, and with Luna rather than Sol. The second reproduction also shows that this can leave a task half-modified and then falsely complete after the model loses its state.Reproducing on Linux x86_64 + codex-cli 0.150.1 (release build) + gpt-5.5 + ChatGPT auth, with
token_budgetenabled — same boot-onlyreplacement_historysignature, plus quantitative evidence that may help confirm the root cause.Rollout record (top-level
type: "compacted"in the session JSONL):No trailing summary item. (CLI shows 3 boot messages vs Desktop's 4 in the reports above — otherwise the same signature.)
Post-compact turn sizes — the first real API call after compaction:
Compaction fired at
input_tokens: 209,892ofmodel_context_window: 258400(~81%). So neither the replacement history nor the server side holds any summary — it behaves as a clean fresh-window restart, and the post-compact model indeed asked what it should work on.Not a network failure: direct connectivity to chatgpt.com is impossible in this environment (proxy required). Through the proxy,
codex doctoris all green (WebSocket 101, inference endpoint reachable, HTTP 405 on GET as expected), and an authenticated minimal POST to the responses endpoint returns 200 withresponse.createdevents. No WARN/ERROR in the sqlite runtime logs around the compaction either — the summary-free rollover is completely silent.Feature states via
codex features listat the time of failure:This is consistent with @Nagi-Inaba's analysis:
token_budget(notremote_compaction_v2) selects the summary-free path incompact_token_budget.rs.Additional gotcha for anyone relying on the reminder as a safety net:
reminder_threshold_tokens = 12000(remaining-tokens semantics) never fired, because auto-compaction triggered at ~81% usage (~48k remaining on a 258k window) — well above the 12k reminder line. For the reminder to fire before rollover, it must be set above the auto-compact trigger point (e.g. ~80k remaining in this window size).Workaround applied:
[features.token_budget] enabled = false(keepingremote_compaction_v2 = true). Will report back after the next auto-compaction on whetherreplacement_historyends with a summary item again.