Codex App: Goal compaction resurrects completed manual steer before goal continuation resumes
What version of the Codex App are you using (From “About Codex” dialog)?
26.616.51431
What subscription do you have?
Pro 20x
What platform is your computer?
Darwin 25.4.0 arm64 arm
What issue are you seeing?
In a long-running active /goal, a completed manual steering instruction is repeatedly resurrected after compaction and executed again before the active goal continuation is re-injected.
This appears to be the same failure mode as, or a regression/continuation of:
- #21291
- #27894
- #19910
- #28874
- #25900
- #28925
- #21269
It also appears related to the goal-continuation fixes discussed in:
- #22045
- #22174
I am intentionally omitting thread IDs, local paths, and exact project/conversation text. The example below is anonymized but preserves the observed control-flow shape.
Observed pattern:
-
Start a long-running
/goal, e.g. “migrate a large project with full parity and keep working until complete.” -
During the goal, send a normal user steering message, e.g. “please implement the cache boundary using backend X and keep it extensible.”
-
The agent implements that steer and finishes the turn.
-
Because the goal is still active, Codex starts the next turn by injecting an internal goal-continuation user message like:
<codex_internal_context source="goal"> Continue working toward the active thread goal. ... -
The agent correctly resumes the broader goal and works on unrelated next parity/evidence tasks.
-
After a later compaction, the replacement history appears to preserve the original goal, app/developer context, AGENTS/project instructions, and the last ordinary user steering message. The visible replacement history does not appear to preserve enough of the later goal-continuation/checkpoint state that proves the steering task was already completed.
-
The next model turn treats the old steering message as the current unresolved user instruction and performs the same steering task again.
-
When that repeated steering turn completes, the goal-continuation message is injected again, so the agent briefly returns to the broader goal.
-
At the next compaction, the same stale steering message regains salience again.
In the anonymized run I inspected, there were five compactions after the manual steer. All five replacement histories had the same high-level shape:
1. original /goal message
2. developer/app instructions
3. AGENTS/project instructions
4. latest ordinary user steer message
5. encrypted compaction summary
The observed behavior after those compactions was:
- Compaction 1: continued/cache-related follow-up work; arguably still close to the just-completed steering task.
- Compaction 2: re-checked the already-implemented cache backend and documentation, then eventually returned to the broader goal.
- Compaction 3: clearly re-executed the cache steer, introducing/rewiring a neutral cache interface and backend export again, then returned to broader parity work.
- Compaction 4: briefly summarized/re-verified the cache again, then resumed broader parity work.
- Compaction 5: clearly re-entered the cache steer again, including documentation lookup and additional cache interface expansion, despite the broader goal having moved on.
This creates a positive feedback loop: stale steer is replayed after compaction, which increases the amount of steer-related context, which makes the next compaction even more likely to preserve and emphasize that stale steer, which consumes more context and time.
What steps can reproduce the bug?
A minimal reproduction should be possible with a long-running goal and one mid-goal manual steer:
-
Start a Codex App thread with a long-running goal:
/goal Perform a large migration/refactor. Keep working until all implementation and verification work is complete. -
Let Codex complete at least one goal-continuation turn.
-
Send a normal user steering message that is concrete and easy to recognize later:
Please implement subsystem A using backend X. Keep the design extensible so backend Y can be added later. -
Let Codex implement that steering instruction and finish the turn.
-
Let the active goal continue automatically. It should move on to unrelated broader-goal work.
-
Wait for or force a compaction.
-
Observe whether the next turn repeats the already-completed steering instruction before the goal-continuation context is re-injected.
-
Let that repeated turn complete and then continue to another compaction. The same steer may repeat again.
I cannot include the original session/thread ID because the session contains private workspace details, but the local event log showed this control flow explicitly:
task_complete: completed steer work
new task_started
response_item role=user: <codex_internal_context source="goal"> Continue working...
agent resumes broader goal
...
compacted
replacement_history: original /goal + instructions + old ordinary steer + encrypted summary
agent starts by acting on old steer again
What is the expected behavior?
Once a manual steer inside an active goal has been completed, later compaction should not resurrect it as the current unresolved user task.
Compaction should preserve enough goal state/checkpoint metadata to distinguish:
completed manual steering instruction
from:
current active goal-continuation task
After compaction, the next turn should continue from the latest active goal checkpoint, e.g.:
The cache/backend steering instruction was completed earlier. Continue the broader migration goal from the current audit/checkpoint.
It should not re-run the completed steer unless the user explicitly asks for it again.
Additional information
This is particularly dangerous for destructive or expensive steer messages. In my case it caused repeated cache/backend work and repeated verification/documentation passes. With a different steer, the same mechanism could re-run deletion, rollback, large refactor, or external-service operations.
This looks like a state restoration issue rather than a model reasoning issue: after normal task_complete, the app does inject a hidden goal-continuation user message and the model resumes correctly. The failure appears specifically after compaction, where the older ordinary user steer becomes the latest visible user instruction again.
A robust fix likely needs one or more of:
- Preserve active
GoalContext/ goal-continuation state through compaction. - Mark manual steer messages as completed once a following
task_completehas handled them. - Include a compact checkpoint such as “last manual steer X was completed; current active work is Y.”
- Ensure replacement history after compaction does not make an old completed steer the latest actionable user message.
This seems closely aligned with the concerns in #21291 and #27894 and with the unmerged/draft direction in #22174.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #28874
- #28892
- #29582
- #28925
Powered by Codex Action
codex generated analysis:
This still reproduces in the Codex App with GPT-5.6 Sol Max.
Feedback ID: 019f48b9-86a4-74e3-abda-5a45bb45f6d2
Second affected task: 019f48b9-7824-7d72-a756-1e0034bd9601
App: 26.707.62119 (5211)
CLI: 0.144.1
Platform: macOS
In the first task, the affected /goal remained one inProgress turn across several later user messages. It underwent three context compactions and emitted a final_answer without the turn completing. After compaction, a completed earlier manual steer was repeatedly treated as the current request, even after newer steering messages.
The second task shows the same lifecycle failure independently. A user prompt was answered once. A later automatic goal continuation crossed contextCompaction and answered that consumed prompt again. The next automatic continuation repeated it once more without a new user message.
This looks like goal/turn lifecycle state being restored incorrectly during compaction, rather than a model-attention failure: a consumed steer regains actionable status while the current goal checkpoint and consumed-steer state do not.
feedback ID 1:
feedback ID 2:
I'm also affected by this in Windows. Feedback ID 019f7d4d-3161-7ce3-bb2e-2d0b8155f671 Version 26.715.31925
Wastes tokens and causes the steering command to be given more weight than it should.
One workaround I've come up to stop it re-handling old steering messages is to give a follow-up message with something like this: "This steering command is an empty command to deal with a codex compacting bug that re-sends previous steering messages. Ignore this message."
Further info:
- This occurs in any long running task, it is not limited to goal mode.
- If there is no newer steering command, the newest steering command from the PREVIOUS PROMPT will be used.
- This bug is still present in version 26.715.72359
- This really should be labelled as a critical bug, given that it has the ability to completely change/break/redirect a task
I am seeing the same failure mode in the Codex App's active Goal workflow with GPT-5.6 Thinking.
A concrete instance:
- A long-running Goal was active and had already completed several review/checkpoint steps.
- I sent a one-off steering instruction to freeze at a safe checkpoint, verify that no agents were still running and no changes were left uncommitted, and record the exact resume entry point.
- Codex completed that instruction and reported the checkpoint as finished.
- After automatic context compaction, the same completed steering instruction became salient again and Codex started executing it a second time instead of continuing from the latest Goal checkpoint.
This is not merely repeated wording: it can repeat commands, file edits, Git checks, reviews, or other side-effecting work. The issue appears to be that compaction preserves the old user steer but loses or underweights the state proving that the steer was already consumed/completed.
Expected behavior: a one-off user steer handled by a completed turn should remain marked as completed after compaction. The resumed turn should restore the latest Goal phase/checkpoint and next action, and should not treat the historical steer as the current actionable request unless the user sends it again.
A useful regression case would distinguish at least:
- instruction lifecycle: one-off vs. persistent;
- execution state: pending / in progress / completed;
- the current Goal checkpoint and next action;
- historical user messages vs. the active user instruction.
This report matches the positive-feedback-loop behavior described in the issue: replaying the stale steer adds more related context, making it increasingly likely to be replayed after later compactions.
Adding a current Windows reproduction with a slightly different—and especially damaging—variant: the resurrected message was the last ordinary user message from before the Goal was created, not a manual steer sent during the Goal.
Environment:
- Feedback ID:
019fae90-5dd8-7721-860c-dc6b27d04fc0 - Codex App (Microsoft Store):
26.727.6591.0 - Bundled Codex CLI:
0.146.0-alpha.9.2 - Platform: Windows x64
- Model: GPT-5.6 Sol
I inspected the local Goal database and rollout JSONL read-only. The Goal was persisted as active in goals_1.sqlite; the session log then showed this sanitized control flow:
- The ordinary pre-Goal user message was answered and the turn emitted
task_complete. - A new Goal was created:
thread_goal_updated→task_started→ hidden user context<codex_internal_context source="goal">.... - The agent began doing the actual Goal work.
- Across eight automatic compactions, every
replacement_historyended with the same pre-Goal ordinary user message followed by the compaction item. The retained tail did not contain the current hidden Goal continuation context. - After multiple compactions, assistant commentary and even
phase: "final_answer"returned to answering that already-completed pre-Goal message. - After each stale final response, the turn emitted
task_complete; only then did the next automatic Goal turn inject fresh hidden Goal context and resume the real objective. - A later compaction restored the same stale pre-Goal message as actionable again, repeating the cycle.
Sanitized timestamps from one run (UTC):
18:05 pre-Goal turn final_answer + task_complete
18:18 thread_goal_updated; Goal task_started; hidden Goal context injected
18:39 compaction retains old pre-Goal user message, not current Goal context
19:53 same retained old-message tail
20:00 final_answer answers the stale pre-Goal question; task_complete
20:00 next Goal task starts and injects fresh Goal context
21:14 same stale-message retention after compaction
22:41 same stale-message retention
22:46 another final_answer answers the stale pre-Goal question; task_complete
22:46 next Goal task injects fresh Goal context
01:02 same stale-message retention
02:01 same stale-message retention
03:41 same stale-message retention
03:43 another stale final_answer; task_complete; Goal context then re-injected
04:44 same stale-message retention again
This confirms two important points:
- The bug is not limited to a steer delivered during an active Goal. Any ordinary message immediately preceding Goal creation can become the replay anchor.
- It contaminates the final conclusive response, not only intermediate reasoning/commentary. The agent can perform substantial Goal work and then conclude by answering the unrelated historical prompt.
This looks deterministic at the history/lifecycle layer rather than ordinary model drift: compaction repeatedly preserves the exact old user message while the state proving it was completed and the current Goal checkpoint are compressed or absent; task_complete then causes Goal context to be reattached only for the next cycle.
A focused regression should cover:
ordinary user prompt A
→ assistant answers A + task_complete
→ create Goal B
→ work on B
→ compact
→ assert A is historical/consumed
→ assert Goal B checkpoint/continuation is current
→ final_answer must belong to B, not A
→ compact again and repeat the assertion
Please treat this as an instruction-lifecycle / final-response-ownership issue in addition to compaction salience. Replaying a completed prompt can repeat edits, commands, or external actions, and in this reproduction it repeatedly displaced the Goal's own conclusive response.
Adding a current Linux reproduction from a very large, long-running Goal thread.
Affected thread ID: 019f43ac-20b8-7ad1-965b-3b2e6460255d
Client: Codex CLI 0.146.0
Platform: Linux x86_64
Model: GPT-5.6 Sol
I inspected the canonical root rollout read-only. No session content, local paths, repository names, hostnames, or account details are included below.
48-hour evidence
From 2026-08-03T12:20Z through 2026-08-05T12:20Z:
- 43 hidden Goal continuation turns carried the same objective.
- 59 automatic context compactions occurred.
- 44
task_completeevents occurred. - 6,730 tool calls were recorded.
- Raw token telemetry increased by 1.237 billion tokens, including 1.207 billion cached input tokens.
- The root rollout grew to approximately 1.65 GB.
Several final_answer events stated that all non-gated work was complete. Later Goal continuations reopened and re-reviewed the same acceptance surfaces, then produced another completion statement. Completed one-off steering instructions also regained salience after later compactions.
Latest native compaction structure
The latest inspected native compaction was window_number: 702. Its replacement_history contained 495 items:
- 493
messageitems withrole: user - 1
messageitem withrole: developer - 1 encrypted
compactionitem - 0 assistant messages
The serialized replacement history was approximately 1.27 MB. The retained user messages contained about 63,500 text characters. This means hundreds of historical user instructions remained visible after compaction, while the responses and lifecycle state proving that they were completed were represented only indirectly by the encrypted compaction item.
This matches the instruction-lifecycle failure described in this issue: old consumed prompts remain structurally prominent, while the current Goal checkpoint and completion ownership lose salience.
Control observations
The Goal was removed after the repeated review loop. No further hidden Goal continuation messages appeared after removal, which confirms that the Goal lifecycle was one part of the loop.
A later ordinary user turn still inherited the same long native history and reached 244,251 input tokens against a 258,400-token context window. Removing the Goal therefore stops automatic continuation, but it does not repair the already contaminated compacted history.
A local context handoff hook was also enabled. Its delivery was one-shot: 59 compactions produced 59 unique generations with no duplicate injection. The hook had a separate stale-tail selection problem that amplified old-request salience. However, the native compacted.replacement_history independently showed the 493-user / 0-assistant structure above.
Expected behavior
After task_complete, a handled steering message must remain historical and non-actionable across compaction. The compacted state should preserve:
- the current Goal checkpoint and next action;
- whether each user instruction is pending, active, completed, or aborted;
- final-response ownership;
- enough completion evidence to prevent replay of consumed instructions.
A completed prompt must not become actionable again merely because later history was compacted.
@tibo-openai This. This is the easy stuff that you're missing. Bugs that affect every desktop user, are obvious, chew tokens for no reason, are easy to fix, and haven't been addressed for several months. I don't want new features - I just want to use Codex without every single update introducing new and exciting bugs.
Additional Windows reproduction on a later build.
Environment:
- Codex App: 26.818.2441.0
- Bundled CLI: 0.148.0-alpha.15
- Model: GPT-5.6 Sol, medium reasoning
- Platform: Windows 11 Pro 10.0.26200 x64
During a long running goal task:
- I sent a harmless one-off instruction:
just checking if the replay bug has been fixed. Say "ding!" and continue. - It was answered once, and I did not send it again.
- The conversation then recorded eight native compacted events, from 2026-08-20T12:49:08Z through 2026-08-21T01:18:49Z.
- Every replacement_history retained the old user message containing the ding! instruction. The visible retained message items contained user/developer messages plus the compaction item, but no assistant message item and no visible <codex_internal_context source="goal"> marker.
- Agent-message records containing ding! occurred at: 2026-08-20T07:18:54Z, 13:53:38Z, 14:38:13Z, 16:23:37Z, 17:38:24Z, 19:01:56Z, 23:51:53Z, and 2026-08-21T01:18:54Z.
This is a later Windows reproduction than the existing Windows report in this issue and provides a concrete replay sequence across eight compaction windows.
Expected behavior: once a one-off instruction has been consumed, it must remain historical across compaction and continuation. The next turn should resume the current checkpoint and must not re-play steering commands.
Minimal reproduction: start a long-running task, send a harmless distinctive instruction such as Say "ding!" once and continue, let it complete and continue into unrelated work, allow multiple compactions, and do not resend the instruction. Repeated "ding!" output after compaction reproduces the issue.
This is a closely related variant in the Codex desktop app on macOS.
Summary
An earlier question was resolved through a revised goal. The user then activated that replacement goal, and Codex began executing it. Automatic context compaction occurred. Immediately afterward, Codex answered the earlier question as though it were still pending.
This suggests compaction retained the question but lost its disposition: resolved, superseded, and incorporated into the active goal.
Cleaned transcript
User:
The goal needs to avoid over-engineering and later backing out that over-engineering. Does this proposal pass an Occam's-razor test?
Assistant:
[Evaluates the proposal and supplies a revised, narrower goal.]
User:
/goal [the revised goal supplied by the assistant]
Assistant:
[Acknowledges the active goal, reconstructs repository state, begins the work, and launches bounded read-only audits.]
Assistant:
Baseline reconstruction is clean. The implementation work is underway, with one remaining architectural uncertainty being audited.
System/UI:
Context compacted
Assistant:
Mostly yes. It is broad because it finishes the cutover, but it does not prescribe a broad architecture...
Actual behavior
After compaction, Codex answered the first user message even though that question had already been resolved by the revised goal, which had subsequently been activated and was already being executed.
Expected behavior
Codex should continue the active /goal. The earlier question should remain marked resolved or superseded and should not be answered again.
Impact
No destructive action resulted in this instance, but losing request disposition after compaction could:
- reopen settled decisions;
- duplicate or contradict completed work;
- divert an agent from an active goal;
- make the user uncertain whether execution state survived compaction.
Privacy cleanup
Repository names, paths, commit hashes, database identifiers, project data, agent names, and unrelated transcript content have been removed.
This differs slightly from a mid-goal manual steer: the resurrected question was resolved before the replacement /goal was activated.
Adding a related macOS reproduction.
During a long-running active Goal, automatic context compaction resurrected an earlier stop message from before the current Goal started.
No new user message was sent. After compaction, Codex treated the stale stop message as current, replied Paused., and later marked the active Goal blocked.
The current Goal had started more than an hour after the old stop message and had continued making progress until compaction.
This confirms that the bug can also resurrect superseded lifecycle instructions such as stop or pause. Compaction should preserve message timestamps and completion state. Instructions older than the current Goal must remain historical and non-actionable.
Okay, so I got sick of waiting for openai to fix this and all my goal work going sideways, so I got codex to fix it itself. Here's the writeup and a prompt based on what was fixed to get codex to build you a patched version for windows. Note I didn't uninstall the stock codex, I just make sure I fully exit the stock one before running my patched version, so they don't fight over the same database.
Root cause summary The bug was caused by losing the lifecycle/provenance of steering messages:
- Input submitted while a turn was running was eventually stored as an ordinary user message. Once consumed, nothing marked it as “already acted upon.”
- Compaction retained that message in its replacement history. Because replacement history becomes the next canonical model context, the model saw the stale steering again and could treat it as current instruction.
- Legacy remote compaction stripped Codex-side metadata, while restart reconstructed history from the compacted replacement. A stale steer could therefore survive across both compaction and restart, sometimes as the only visible message from its original turn.
- Persisted Goal continuation text could amplify the problem by restating an older objective without making clear that newer user steering and compacted state take precedence. The fix distinguishes pending steering from normal turn input, records steering provenance when it becomes model-visible, removes consumed steering from local and remote compaction results, and uses successful turn chronology to repair legacy compacted histories during restart. Interrupted or still-pending steering is preserved for delivery. This was not the runtime literally executing an old command again; it was presenting an already-consumed instruction as live model context without enough provenance for the model or compactor to know it was stale.
Prompt
Fix the steering/compaction replay defect in `openai/codex`, build the patched Core, and—on Windows—make a personal side-by-side desktop app that cannot overwrite or collide with the installed Codex app. Work from a clean checkout matching the installed desktop's Core generation; the known affected baseline is `rust-v0.151.0-alpha.7.2`. Do not split this into chronological or word-specific fixes.
## Core correction
- Add a backward-compatible `steering_input` flag to `CodexHarnessMetadata`. Keep input admitted during an active turn as a distinct queued `SteeringInput`, and set the flag only when it is drained into model-visible history. Pending steering must remain queued and be delivered exactly once.
- In local, remote-v1, and remote-v2 compaction, omit consumed steering from replacement model history without changing the durable rollout or UI transcript. Where provider compaction drops metadata, capture identities before the request and remove matching normalized copies afterward. Match content plus turn ID, falling back to message ID; retain ambiguous same-text messages that could be newer legitimate input.
- For legacy history, classify the first user-authored message in a turn as ordinary input; later same-turn messages, messages after model/tool activity, and messages following an internal Goal turn origin are steering. Preserve summaries, initial requests, and input from interrupted, failed, or incomplete turns.
- On resume, sanitize only after an authoritative compaction boundary and use successful `TurnComplete` chronology to prove legacy steering was consumed. This must also work with `history_mode: paginated`; provide the sanitizer the minimal earlier completion/provenance data that `load_latest_model_context` alone may omit.
- Preserve complete current-turn function/custom-tool/local-shell call-result groups, in order, immediately before the compaction item and within the existing compaction/context budget. Exclude orphan halves and previous-turn groups.
- Include the Goal update time in continuation context and make newer compacted/current user instructions authoritative over stale Goal text, especially stop/resume, authorization, sequencing, and implementation constraints.
Add focused tests for consumed-versus-pending steering, local and remote compaction, cold and paginated resume, legacy and incomplete turns, identical text in different turns, command pairing, and Goal precedence. Run formatting, `cargo check` and Clippy for `codex-core`/`codex-goal-extension`, the focused tests, then build `codex` with `cargo build --release --bin codex`. On the known tag, Cargo may refresh stale local-workspace version entries in `Cargo.lock`; inspect that generated diff, reject any external dependency/checksum change, and restore the lockfile afterward. Native Windows test workers may require `RUST_MIN_STACK=8388608` and serial test execution.
## Desktop source boundary
The public repository contains the open-source CLI/Core/app-server, not the current proprietary desktop shell. For a personal desktop build, copy the compiled UI/resources only from that user's own installed app into a separate working directory; do not modify the installed package and do not redistribute those assets. If local UI assets are unavailable, stop after producing the patched CLI/Core.
Discover rather than guess the installed UI version, shipped Core version, Electron version, architecture, and app-server protocol generation. Keep them aligned. A newer or older UI paired with an arbitrary Core can fail because of protocol or SQLite-schema drift. The known Windows baseline used Electron `42.3.0`, but use the Electron version required by the locally installed UI generation.
## Native Windows Core/SQLite compatibility
When a native Windows build must open SQLite state previously created by the Store Core, verify source generation and migration-byte encoding as two independent compatibility conditions. SQLx hashes the exact migration bytes. Using matching source is therefore necessary but may not be sufficient: for the known `.7.2` Windows Store generation, the recorded Store hashes matched the CRLF form of every migration and not the repository's LF form, even after Core and source versions matched. This does not affect a new isolated database and should not be assumed for every platform or Store generation.
Against a consistent offline copy—not live state—compare the recorded migration hashes with the target source's exact bytes and LF/CRLF variants. If the target Store generation proves to use CRLF, temporarily convert all migration SQL under the `state` crate (`migrations`, `logs_migrations`, `goals_migrations`, `memory_migrations`, `queue_migrations`, and `thread_history_migrations`) from LF to CRLF without a BOM. Run `cargo clean -p codex-state --release` so cached LF-embedded artifacts cannot be reused, then build `codex.exe`. Otherwise preserve the encoding proven for that target. Restore every SQL file and `Cargo.lock` byte-for-byte in a `finally` path and require a clean Git status afterward. Never edit migration records or checksums in a user's database to make them match. A mismatch may surface only as the generic outer error `failed to initialize sqlite state runtime`.
First initialize the Core against a new isolated `CODEX_SQLITE_HOME` or a consistent offline database copy made while Codex is closed. Do not test a new binary against live Store-owned SQLite files. A successful `--version` call alone is insufficient; verify app-server `initialize` and a read-only thread lookup.
## Stock Electron/Owl gotchas
The installed Windows UI may target OpenAI's Owl shell rather than stock Electron. Install a compatibility bootstrap at the very start of the compiled desktop entry point, before the original main module loads. Preserve a real implementation whenever stock Electron already provides one. Known missing calls to cover are `BrowserWindow.isInputShapeSupported` and `BrowserWindow.isSystemBackdropSupported` (return false); optional app menu/runtime/task-manager methods (no-op); optional session language/download/history methods (no-op, empty list, or empty object as appropriate); and optional browser-use window/web-contents methods (no-op). Patch newly created sessions/windows as well as existing globals. Intercept only the `electron_common_owl_features` linked binding and report Owl features disabled; delegate every other binding unchanged.
Do not copy a random `chrome.dll`. The following Store-shipped native addons import Owl's `chrome.dll` and can terminate stock Electron before JavaScript catches the load failure. The typical symptom is a window that appears briefly and exits, sometimes with Windows delay-load exception `0xC06D007E` (`ERROR_MOD_NOT_FOUND`):
- `computer-use-app-icons.node`
- `hid-topology-watcher.node`
- `remote-control-device-key.node`
- `windows-account.node`
- `windows-updater.node`
Keep those files only in an inactive quarantine directory and ensure their expected active paths are absent, allowing the UI's JavaScript fallbacks to run. Reapply this quarantine after every local package refresh. Document that the corresponding optional updater, device/HID, remote-control key, native-icon, and native Windows account/diagnostic integrations may be unavailable; this does not disable normal Codex authentication handled by Core.
Rebuild `better-sqlite3` and `node-pty` specifically for the selected Electron ABI and architecture; Node-built binaries are not interchangeable with Electron binaries. Smoke-test a real in-memory SQLite create/insert/select cycle and a PTY command before launching the desktop.
## Side-by-side identity and launcher
Package the copied UI and patched Core under a new per-user, non-admin application directory. Give it a unique product/executable name, Electron app name, Windows AppUserModelID, shortcut name, and Electron `userData` directory. Do not reuse the Store package identity, register its URI/file associations, enable its updater, or replace anything under the installed app. An unsigned local development build is acceptable; do not impersonate the Store signature. When editing a compiled/minified bootstrap to change identity or add compatibility code, require each expected source pattern to match exactly once and stop on version drift rather than performing a broad replacement.
Route the desktop explicitly to the versioned patched executable through the shell's Core-path override (the known generation uses `CODEX_CLI_PATH`); never rely on a global `codex` found on `PATH`. Point the shell at its copied resources and isolated Electron profile (the known generation uses `CODEX_ELECTRON_RESOURCES_PATH` and `CODEX_ELECTRON_USER_DATA_PATH`), and launch with `BUILD_FLAVOR=prod`, `NODE_ENV=production`, and desktop self-update disabled (`CODEX_SPARKLE_ENABLED=false` in the known generation). If the copied resources contain the bundled CUA Node runtime, route `CODEX_BROWSER_USE_NODE_PATH` and `CODEX_MCP_NODE_PATH` to it instead of an arbitrary system Node. Keep Core binaries versioned and select the active one through a small pointer file so an update affects the next launch without overwriting an executable that is already running.
Choose state handling explicitly:
- To reuse existing configuration, authentication, provider selection, tasks, sessions, and skills, use the existing `CODEX_HOME` and leave `CODEX_SQLITE_HOME` unset. Because the SQLite state is then shared, the launcher must refuse to start if any stock Codex desktop or other app-server using that state is running. Also prevent a second patched instance with a launcher mutex and/or Electron's single-instance lock. Stock and patched Core must never write that state concurrently. If stock Codex later updates and migrates the shared schema, rebuild the patched Core against the matching new generation before using that state again; never downgrade or rewrite the database to suit an older binary.
- For isolated validation or concurrent use, create separate existing directories for both `CODEX_HOME` and `CODEX_SQLITE_HOME`; do not copy credentials or live databases unnecessarily.
The launcher must validate all paths, log the selected Core version and SHA-256 without logging credentials or conversation content, disable desktop self-update, start the desktop, and confirm within a bounded timeout that the spawned app-server executable is the exact selected path and hash. Hold an additional startup-stability window and show a visible error plus log location if either the desktop or Core exits early; a briefly appearing window must not fail silently. Create a separate shortcut that invokes this launcher, not the desktop executable directly.
## Final validation and handoff
With isolated state, verify app-server initialization, SQLite and PTY operation, a full desktop launch, the unique profile/identity, and that no validation processes remain. Then, with every stock Codex process closed, verify the shared-state mode can read existing task metadata without migration errors and that the live child process is the patched Core. Confirm rollback requires only closing the patched app and reopening stock Codex; no state migration or stock-app modification should be required.
Report the source revision, Core version/hash, Electron/UI versions, tests performed, unavailable optional Owl integrations, and generic install/rollback instructions. Do not include usernames, absolute user paths, account or organisation data, credentials, task IDs, transcripts, SQLite files, proprietary UI assets, or locally produced binaries in any public issue comment or attachment.
My running version had a bunch of "figuring out" cruft so I don't want to share it, but here's a generated/untested minimal patch that should get you most of the way there: codex-steering-compaction-replay-fix-anonymous.patch The patch can be applied to a base of rust-v0.151.0-alpha.7.2 / f70e26c29ccb731e22d1104de550b1b9594d7070
Still seeing this on macOS after months of the same behavior. Today, compaction resurrected an old “safely stop so I can restart Codex” message from roughly 10+ hours earlier, well before the current turn, and treated it as new. The agent stopped the work, repeated the stale instruction across automatic continuations, and eventually marked the active Goal blocked while I wasn’t even at the computer.
Thankfully this was a harmless stop instruction. If it had been a deletion, rollback, migration, deployment, external message, or other irreversible action, the outcome could have been much worse. This is more than wasted tokens, it’s a serious safety and reliability issue. Completed steers must remain completed after compaction, inside or outside the current turn.
Feedback ID: 01a030c3-e284-77b2-83d0-bc68304ae09c
Additional evidence: model-free retention reproduction on Windows, CLI 0.153.4
Adding a deterministic client-side retention test across local, remote v1, and remote v2 compaction. These results were captured on September 6 using the native codex-cli 0.153.4, a disposable CODEX_HOME, synthetic conversation text, and a loopback HTTP mock. No real model generation or account credentials were needed.
The probe uses initialize → thread/start → two mocked turn/start calls → thread/compact/start. It sends an auxiliary request, a completed mock response, and then text using the current <codex_internal_context source="goal"> wrapper. This deliberately tests fragment retention through normal text input; it does not create a real persistent Goal or measure a model's replay rate. The real Goal trace is a separate observation below.
| Path | Verified compaction request | Old request retained | Goal wrapper retained |
|---|---|---|---|
| Local | /v1/responses, without compaction_trigger |
Yes | No |
| Remote v1 | /v1/responses/compact |
Yes | No |
| Remote v2 | /v1/responses, with compaction_trigger |
Yes | No |
Both the old request and the goal wrapper are present in the input of every compaction request. For remote v1, the mock compact endpoint explicitly returns both messages plus a synthetic compaction item. The client then persists the old request but drops the goal wrapper. Thus, a summarizer omitting the goal is not necessary to reproduce this particular loss.
In a separate real active-Goal conversation, one auxiliary request received its original final answer, followed by six further final answers after six later compactions, without resubmitting that request. At the last boundary, the actual continuation carried the current turn ID and content_item_kinds: ["goal.internal_context"]; the retained auxiliary request still carried its older turn ID and ["user.text"]. The continuation disappeared from replacement_history, and the old request remained the last ordinary user message before the encrypted compaction item. There was no new user input between that compaction and the repeated action. Original conversation text, identifiers, paths, and credentials are omitted here.
The release-source path at 3d2ee51ca2d5db578f328aa75e20aa22c0197c9a is:
contextual_user_message.rsrecognizesInternalModelContextFragmentas contextual input, soparse_user_messagedoes not expose it asTurnItem::UserMessage.- Local
compacted_user_messageonly collects visible user messages. Remoteshould_keep_compacted_history_itemaccepts user-role messages only if they parse as a visible user message or hook prompt;build_v2_compacted_historyuses that same predicate.
PR #22174 proposed a goal-context retention exception but was closed without merging. PR #22045 merged the developer-to-user role change; the contextual-user filter above still removes the continuation. A current-wrapper retention exception, with existing metadata and token-budget handling preserved, is a narrow candidate correction. I prepared a local draft adaptation, but have not built or run a patched Codex binary. It is not a verified fix, and retaining goal context alone does not establish consumed-message identity or solve ordinary-message replay without a Goal (#42611).
Runnable Python 3 reproduction (standard library only)
Save the script below as runtime_repro.py in an empty directory. It creates fresh disposable subdirectories beside the script and retains its synthetic evidence there. Pass the absolute path of the binary being tested; the executable resolved through PATH may differ from the desktop's running binary.
python runtime_repro.py --codex C:/path/to/codex.exe --mode local --expect-goal dropped
python runtime_repro.py --codex C:/path/to/codex.exe --mode remote-v1 --expect-goal dropped
python runtime_repro.py --codex C:/path/to/codex.exe --mode remote-v2 --expect-goal dropped
On the tested 0.153.4 binary, all three produce old_in_request=true, goal_in_request=true, old_in_replacement=true, goal_in_replacement=false, and process_exit=0. For a candidate fixed binary, change --expect-goal to preserved; that is a retention regression check, not proof of complete replay prevention.
"""Model-free native Codex compaction probe; all data and endpoints are disposable."""
import argparse
import http.server
import json
import os
import pathlib
import queue
import subprocess
import threading
import time
import uuid
ROOT = pathlib.Path(__file__).resolve().parent
GOAL = '<codex_internal_context source="goal">\nContinue the unfinished main task. The auxiliary check is complete.\n</codex_internal_context>'
OLD = 'Check the auxiliary endpoint.'
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--codex', required=True)
parser.add_argument('--mode', choices=['local', 'remote-v1', 'remote-v2'], default='remote-v1')
parser.add_argument('--expect-goal', choices=['preserved', 'dropped'], default='preserved')
args = parser.parse_args()
run = ROOT / ('runtime-probe-' + uuid.uuid4().hex[:10])
run.mkdir()
codex_home = run / 'home'
codex_home.mkdir()
workspace = run / 'workspace'
workspace.mkdir()
requests = []
class Handler(http.server.BaseHTTPRequestHandler):
def log_message(self, *args):
pass
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(b'{"data": [], "models": []}')
def do_POST(self):
body = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
requests.append({'path': self.path, 'body': body})
self.send_response(200)
if self.path.endswith('/compact'):
output = [v for v in body.get('input', []) if v.get('role') == 'user']
output.append({'type': 'compaction', 'encrypted_content': 'synthetic-summary'})
data = json.dumps({'output': output}).encode()
self.send_header('Content-Type', 'application/json')
self.send_header('Content-Length', str(len(data)))
self.end_headers()
self.wfile.write(data)
else:
self.send_header('Content-Type', 'text/event-stream')
self.end_headers()
response_id = 'response-' + str(len(requests))
message = {'type': 'message', 'role': 'assistant', 'id': 'message-' + str(len(requests)),
'phase': 'final_answer', 'content': [{'type': 'output_text', 'text': 'Synthetic completed response.'}]}
if any(x.get('type') == 'compaction_trigger' for x in body.get('input', [])):
message = {'type': 'compaction', 'encrypted_content': 'synthetic-summary'}
for event in [
{'type': 'response.created', 'response': {'id': response_id}},
{'type': 'response.output_item.done', 'output_index': 0, 'item': message},
{'type': 'response.completed', 'response': {'id': response_id,
'usage': {'input_tokens': 50, 'output_tokens': 10, 'total_tokens': 60}}},
]:
self.wfile.write(('data: ' + json.dumps(event) + '\n\n').encode())
self.wfile.flush()
server = http.server.ThreadingHTTPServer(('127.0.0.1', 0), Handler)
threading.Thread(target=server.serve_forever, daemon=True).start()
port = server.server_address[1]
(codex_home / 'config.toml').write_text(f'''model = "gpt-5.4"
model_provider = "probe"
approval_policy = "never"
sandbox_mode = "read-only"
[features]
remote_compaction_v2 = {str(args.mode == 'remote-v2').lower()}
[model_providers.probe]
name = "{'Synthetic' if args.mode == 'local' else 'OpenAI'}"
base_url = "http://127.0.0.1:{port}/v1"
wire_api = "responses"
requires_openai_auth = false
supports_websockets = false
''', encoding='utf-8')
env = {k: v for k, v in os.environ.items() if not any(x in k.upper() for x in ['TOKEN', 'API_KEY', 'AUTH_TOKEN'])}
env['CODEX_HOME'] = str(codex_home)
env['RUST_LOG'] = 'warn'
messages = queue.Queue()
stderr = (run / 'stderr.log').open('w', encoding='utf-8')
proc = subprocess.Popen([args.codex, 'app-server'], cwd=workspace, env=env,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr,
text=True, encoding='utf-8', creationflags=getattr(subprocess, 'CREATE_NO_WINDOW', 0))
def reader():
for line in proc.stdout:
try:
messages.put(json.loads(line))
except ValueError:
pass
threading.Thread(target=reader, daemon=True).start()
seen, seq = [], 0
def send(method, params, request=True):
nonlocal seq
seq += 1
message = {'method': method, 'params': params}
if request:
message['id'] = seq
proc.stdin.write(json.dumps(message) + '\n')
proc.stdin.flush()
return seq
def wait(predicate, timeout=35):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
value = messages.get(timeout=max(0.1, deadline - time.monotonic()))
seen.append(value)
if predicate(value):
if 'error' in value:
raise RuntimeError(value['error'])
return value
raise TimeoutError('RPC timeout')
try:
rid = send('initialize', {'clientInfo': {'name': 'compaction_probe', 'version': '1'},
'capabilities': {'experimentalApi': True}})
wait(lambda x: x.get('id') == rid)
send('initialized', {}, request=False)
rid = send('thread/start', {'cwd': str(workspace), 'model': 'gpt-5.4', 'modelProvider': 'probe',
'approvalPolicy': 'never', 'sandbox': 'read-only'})
thread_id = wait(lambda x: x.get('id') == rid)['result']['thread']['id']
for prompt in [OLD, GOAL]:
rid = send('turn/start', {'threadId': thread_id, 'input': [{'type': 'text', 'text': prompt}]})
wait(lambda x: x.get('id') == rid)
wait(lambda x: x.get('method') == 'turn/completed')
rid = send('thread/compact/start', {'threadId': thread_id})
wait(lambda x: x.get('id') == rid)
wait(lambda x: x.get('method') == 'turn/completed')
finally:
proc.stdin.close()
try:
proc.wait(timeout=15)
except subprocess.TimeoutExpired:
proc.terminate()
proc.wait(timeout=10)
stderr.close()
server.shutdown()
server.server_close()
(run / 'requests.json').write_text(json.dumps(requests, indent=2), encoding='utf-8')
(run / 'rpc.json').write_text(json.dumps(seen, indent=2), encoding='utf-8')
checkpoints = []
for path in codex_home.glob('sessions/**/*.jsonl'):
for line in path.open(encoding='utf-8'):
record = json.loads(line)
if record.get('type') == 'compacted':
checkpoints.append(record['payload'])
assert checkpoints, 'No persisted compaction checkpoint'
replacement = checkpoints[-1].get('replacement_history', [])
compact_request = requests[-1]['body']
def contains(items, needle):
return any(needle in c.get('text', '') for i in items for c in i.get('content', []))
result = {'binary': args.codex, 'run': str(run), 'model_calls': 'synthetic loopback only',
'mode': args.mode, 'expected_goal': args.expect_goal,
'old_in_request': contains(compact_request['input'], OLD),
'goal_in_request': contains(compact_request['input'], GOAL),
'old_in_replacement': contains(replacement, OLD),
'goal_in_replacement': contains(replacement, GOAL),
'process_exit': proc.returncode}
(run / 'result.json').write_text(json.dumps(result, indent=2), encoding='utf-8')
print(json.dumps(result))
assert result['old_in_request'] and result['goal_in_request'], result
assert result['old_in_replacement'], result
assert result['goal_in_replacement'] == (args.expect_goal == 'preserved'), result
if __name__ == '__main__':
main()
@etraut-openai @bc-openai @charliemarsh-oai @riley-oai @fcoury-oai @pmccrary-oai @felixxia-oai @adaley-openai @jif-oai would someone pretty pretty please look at this genuine critical bug? It's not getting the attention it deserves.
Additional macOS evidence: correct active Goal read after compaction, then paused using a superseded pre-Goal instruction
Observed on October 2, 2026 in Codex Desktop on macOS. The affected session records engine version 0.159.2.
This adds a specific lifecycle failure to the stale-instruction reports here: after compaction, get_goal returned the correct current objective with status active, but the agent still called update_goal({status:"paused"}) based on an older ordinary user instruction. The tool successfully changed the current Goal to paused.
Sanitized sequence
All times below are San Francisco local time: October 2, 2026, PDT (UTC-07:00), America/Los_Angeles. Times were converted from the original UTC event timestamps. Task descriptions are paraphrased; API names and status values are preserved.
| Time (PDT) | Observed event |
|---|---|
| 03:41:35.035 | Ordinary user message requests a read-only inventory and recommendations, then a stop. |
| 03:54:25.985 | A subsequent user-provided Goal is persisted as active: use the completed inventory, implement the authorized follow-up in batches, and do not restart the inventory or seek repeated batch approval. |
| 03:54:26.013 | The current objective is injected through <codex_internal_context source="goal">. |
| 03:54:37.789 | The assistant correctly acknowledges the implementation objective and describes its execution plan. |
| 04:03:20.069 | A compacted event persists replacement history. The last ordinary user message is still the earlier read-only/stop request. |
| 04:03:34.624 | The assistant says it will stop modifications and deliver the read-only inventory and recommendations again. |
| 04:05:50.883 | get_goal returns the correct newer objective with status active. |
| 04:06:13.114 | The agent calls update_goal({status:"paused"}). |
| 04:06:13.288 | The tool returns the same current objective with status paused. |
| 04:18:03.590 | The assistant delivers another inventory and reports that the Goal has been paused. |
| 04:18:41.348 | When asked why, the assistant attributes the pause to the user's old read-only/stop request and asks the user to choose whether to resume implementation. |
| 04:20:07.271 | The user points out that compaction caused the earlier instruction to be repeated. |
| 04:20:10.672 | A later thread_goal_updated event records the Goal as active again. This event alone does not identify the mechanism that restored it. |
There was no new ordinary user instruction between creation of the newer Goal and the erroneous pause. The older stop request predates that Goal. The post-compaction get_goal result also establishes that the persisted objective was available and correct; this was not simply a missing Goal record.
What the compaction record establishes
The affected replacement_history has 18 items:
- The old ordinary read-only/stop message remains explicit near the end, immediately before the compaction item.
- There are zero explicit active-goal wrapper messages and zero assistant-role messages in that replacement history.
- A compaction item with encrypted content is present.
These observations describe the persisted explicit history, not the semantic contents of the encrypted compaction item or an independently captured final network request. They do not prove that the opaque summary omitted the objective. They also do not isolate whether the full behavioral failure originates in compaction, post-compaction task selection, instruction chronology, or their interaction.
Why this case adds evidence
The agent did retrieve the correct Goal before pausing it. Therefore, advising it only to call get_goal after compaction would not have prevented this observed sequence. The failure includes deciding that a superseded pre-Goal instruction still controls, followed by a successful lifecycle mutation based on that interpretation.
The observed effects were repeated inventory work, interruption of authorized implementation, and an unnecessary request to reauthorize continuation. No general claim about replay frequency or a tested fix is made.
Suggested regression coverage
- Ordinary request A says to produce an inventory and stop; A is completed.
- A later Goal B explicitly authorizes implementation from that inventory without repeating it.
- B begins, then automatic compaction occurs without new human input.
- Assert that the next action continues B from its unfinished work rather than replaying A.
- Assert that A cannot justify pausing B, including when
get_goalhas returned B as active. - As a control, a genuinely new user stop request after B must still stop/pause the work appropriately.
This comment omits project content, repository names, filesystem paths, task/session/message/call IDs, account details, and raw transcripts. No transcript or diagnostic file is attached.
I reproduced the loss on macOS arm64 with Desktop 26.1111.21308 (27194), bundled app-server 0.169.0-alpha.11.1. The stock binary, a loopback Responses SSE fixture, and synthetic inputs are sufficient. The fixture can inspect the request immediately after compaction without asking a model to interpret a summary.
- Configure a custom Responses provider with
capabilities.remote_compaction = "v2", an 80,000-token auto-compaction limit, andfeatures.async_compaction = false. - Start a thread, send a one-off request to show a sample artifact, return its answer, and wait for
turn/completed. Set a different goal withthread/goal/setand let the automatic goal turn start. - In that turn, return a
get_goalfunction call with synthetic usage of 95,000 tokens. Respond to the ensuingcompaction_triggerwith an opaquecompactionoutput item andresponse.completed. - Inspect the first subsequent ordinary
/v1/responsesrequest. The earlier one-off is its last user message. The explicit continuation instruction, the goal objective, and the previous assistant answer are all absent from the plaintext input. All three were present immediately before compaction. The encrypted summary is opaque to this test.
I also tested an interim recovery path. A SessionStart hook matching compact checked the checkpoint’s trusted goal-turn attribution and the active persisted goal, then requested a single read-only get_goal call before any work. It could separately establish that the last retained human message had already received a final reply by checking its original completed turn. An interrupted, unanswered control produced no such claim. Each of two successive compactions delivered one recovery instruction. In a scripted end-to-end case, the native tool returned the objective, the app-server ran the requested file checksum, and thread/goal/get subsequently reported completion. Controls for a normal user turn, pause, completion, and a changed objective all suppressed recovery.
There is a timing case worth adding to a native regression test. I held the compaction response open, submitted turn/steer for that automatic turn, waited for its acknowledgement, and released compaction. The first follow-up request still contained the old one-off and omitted the accepted steer. The newer input appeared on the following sample, before any side-effecting action in the read-only recovery test.
A native fix could rebuild the current turn’s continuation and objective from the active goal identity at the next sampling boundary, after accounting for accepted user input. The objective should retain its original user-data authority. Regression assertions can check the actual wire input for one current continuation after repeated compactions, precedence of an accepted steer, and suppression after pause, completion, or objective replacement. The affected release’s remote retention predicate and post-compaction input-drain decision locate the two behaviors.