Repository navigation
[Windows][Regression] Context compaction loses task state, repeats completed work, and exhausts weekly usage #35935
Description
What version of the Codex App are you using (From “About Codex” dialog)?
26.721.41059
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What issue are you seeing?
Codex repeatedly loses or fails to restore the active execution state of a long-running software-development task after automatic context compaction.
I was using GPT-5.6 Sol in Ultra reasoning mode with subagents enabled. During execution, the main agent and its subagents made substantial and observable progress toward completing the task. Codex inspected the relevant source files, modified the code, built the application, ran verification steps, and repeatedly reached what appeared to be the post-build testing or final-reporting stage.
However, after automatic context compaction, the agent began behaving as though a significant part of the completed work and current task state was no longer available.
It returned to earlier stages of the task, reread files that had already been analyzed, reran commands that had already completed, reopened implementation questions that had already been resolved, and repeated work previously performed by the main agent or its subagents.
The session repeatedly entered the following loop:
substantial progress → near completion → automatic context compaction → loss of active task state → repetition of completed work → another context compaction
The agent sometimes reformulated its reasoning differently, but functionally returned to the same earlier work instead of continuing from the latest valid checkpoint.
This continued for approximately two hours. The task was never completed, despite Codex reaching the build, post-build verification, or final-reporting stage several times.
Before the affected execution, my included weekly Codex usage allowance was approximately 100%. After the repeated execution loop, the allowance had decreased to 0%, while the requested task remained unfinished.
This is not a complaint about the normal usage cost of GPT-5.6 Sol, Ultra reasoning, or subagents. I deliberately selected this configuration and understood that it would consume more usage.
The issue is that the allowance was consumed by repeated work following context-compaction events rather than by continued progress toward completion.
What steps can reproduce the bug?
-
Open an existing local software project in Codex Desktop on Windows 10 x64.
-
Select GPT-5.6 Sol.
-
Select Ultra reasoning mode.
-
Allow Codex to use subagents.
-
Submit a multi-stage software-development task that requires:
- repository analysis;
- modification of existing source files;
- coordination between the main agent and subagents;
- building the application;
- post-build testing or verification;
- production of a final completion report.
-
Allow Codex and its subagents to work until substantial progress has been made.
-
Observe that Codex:
- identifies the relevant files;
- performs implementation work;
- modifies the code;
- builds the application;
- runs tests or post-build checks;
- approaches the final reporting stage.
-
Wait for an automatic context-compaction event.
-
Continue observing the agent after compaction.
-
Instead of continuing from the latest valid execution checkpoint, Codex begins repeating earlier work. Typical behavior includes:
- rereading files that were already inspected;
- rerunning repository searches;
- repeating diagnostic commands;
- reconsidering implementation decisions already made;
- reopening resolved problems;
- repeating work completed by subagents;
- returning from post-build verification to earlier repository analysis.
-
Allow the session to continue.
-
The repeated work consumes more context and causes another automatic context-compaction event.
-
After the next compaction, Codex again returns to earlier work instead of completing the task.
-
The cycle continues without a stable final result.
The problem reproduced repeatedly during attempts made on July 28–29, 2026.
Approximate execution pattern:
analysis → implementation → build → verification → near completion → context compaction → task-state regression → repeated analysis and implementation → another compaction
Observed usage impact:
- Weekly allowance before the affected execution: approximately 100%.
- Weekly allowance after approximately two hours: 0%.
- Final task result: not delivered.
- Exact token and context-window counters were not exposed in the desktop user interface.
- The application displayed automatic context-compaction events during the affected execution.
The affected conversation was also submitted directly through the built-in Codex feedback function. The feedback interface did not display a session ID to me.
What is the expected behavior?
Automatic context compaction should preserve a structured and reliable continuation checkpoint.
After compaction, Codex should continue from the latest valid execution state instead of reconstructing the task from an incomplete general summary or returning to an earlier phase.
At minimum, the preserved state should include:
- the exact current user request;
- the task acceptance criteria;
- the current execution phase;
- work already completed;
- work still remaining;
- files already inspected;
- files already modified;
- commands already executed;
- results of completed commands;
- build results;
- test and verification results;
- implementation decisions already made;
- issues already resolved;
- known unresolved issues;
- approaches already rejected;
- relevant findings returned by subagents;
- changes already completed by subagents;
- the exact next action;
- the explicit task-completion condition.
After context restoration, Codex should verify the current repository state and continue from the latest valid checkpoint.
It should not silently return to initial repository analysis, reopen resolved questions, or repeat completed commands and implementation work.
The runtime should also detect likely repetition loops, including:
- repeated reading of the same files without a new reason;
- repeated execution of the same searches or diagnostic commands;
- repeated reconsideration of the same resolved issue;
- repeated assignment of substantially identical work to subagents;
- repeated builds without intervening code changes;
- returning from final verification to initial analysis;
- repeatedly approaching completion without producing the final response.
When reliable continuation is no longer possible, Codex should stop and explicitly report that state instead of indefinitely consuming the user’s limited usage allowance.
Additional information
Environment
- Product: Codex Desktop for Windows
- Installation source: Microsoft Store
- Application version: 26.721.41059
- Operating system: Windows 10 x64
- Subscription: ChatGPT Plus
- Model: GPT-5.6 Sol
- Reasoning mode: Ultra
- Subagents: Enabled
- Dates observed: July 28–29, 2026
- Time zone: Europe/Kyiv, UTC+3
Severity and impact
Severity: High
The issue caused:
- failure to complete an otherwise finite software-development task;
- repeated loss or weakening of the current execution state;
- repetition of already completed work;
- apparent loss or weakening of subagent findings;
- repeated execution of commands and repository analysis;
- exhaustion of the entire included weekly Codex usage allowance;
- loss of approximately two hours of execution time;
- inability to continue using the selected Codex configuration;
- no completed final result.
This was not simply an incorrect answer or an unsuccessful implementation attempt.
The agent repeatedly reached the build, post-build verification, or final-reporting stage and then regressed after context compaction.
Regression information
This appears to be a regression.
I previously used Codex for comparable long-running software-development tasks. Automatic context compaction also occurred in earlier sessions, but it appeared less frequently and did not normally cause this degree of task-state regression.
Earlier sessions generally continued toward a logical completion after compaction. In the current behavior, compaction can cause the agent to return to substantially earlier stages and enter a non-terminating repetition loop.
Subagent-specific concern
Subagents were enabled during the affected execution.
Some work was completed or investigated by subagents, but after context compaction the parent agent sometimes behaved as though those findings or completed actions were no longer available.
Please investigate whether:
- subagent outputs are fully retained across parent-context compaction;
- completed subagent tasks remain marked as completed;
- the parent agent can distinguish completed subagent work from pending work;
- repository changes and conclusions produced by subagents survive compaction;
- repeated compaction progressively weakens or removes subagent results.
Possible affected components
The exact root cause cannot be determined from the user interface.
The behavior appears correlated with automatic context compaction and may involve:
- preservation of the active execution checkpoint;
- restoration of the current task phase;
- retention of completed and remaining work;
- retention of subagent results;
- synchronization between repository state and compacted conversation state;
- loss of command, build, or test results;
- repeated compaction of already compacted summaries;
- loss of the latest task-completion condition;
- absence of repetition-loop detection.
These are suspected affected areas, not confirmed root causes.
Requested investigation
Please investigate:
- Whether automatic context compaction preserves the latest active execution checkpoint.
- Whether the current task phase remains explicitly available after compaction.
- Whether completed work remains marked as completed.
- Whether command, build, and test results survive compaction.
- Whether subagent results remain available to the parent agent.
- Whether repeated compaction progressively removes important task state.
- Whether the restored state is synchronized with the actual repository state.
- Whether Codex can detect repeated post-compaction behavior.
- Whether the runtime can prevent non-terminating execution loops.
- Whether usage consumed during confirmed repetition loops can be identified in telemetry.
Reporting status
The affected conversation has already been submitted through the built-in Codex feedback function.
OpenAI Support has also been contacted regarding the account-level impact and the weekly allowance consumed during the failed execution.
Possible related reports include:
- Context auto-compaction loop repeatedly rereads files, loses progress, and consumes paid Codex credits #35226
- Context compaction forgets AGENTS rules: task progress can jump from 97% back to 42% #25792
- Compaction should preserve the current task checkpoint to avoid restart loops in long-running sessions #25900
- Pro plan unusable: lossy compaction silently rewrites instructions + unreapable subagent leak (5 compounding bugs, full telemetry) #25563
This report documents an independent reproduction involving Windows 10 x64, the Microsoft Store desktop application, ChatGPT Plus, GPT-5.6 Sol, Ultra reasoning mode, subagents, and complete exhaustion of the included weekly allowance.
Requested resolution
A complete resolution should include:
- reliable preservation of structured task state before compaction;
- restoration from the latest valid checkpoint;
- retention of completed and remaining work;
- retention of relevant subagent results;
- synchronization with the actual repository and build state;
- detection and prevention of repeated post-compaction execution;
- a safe stop condition when reliable continuation is impossible;
- protection against exhausting the user’s allowance through repeated completed work.
Activity
github-actions commentedon Jul 29, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Keesan12 commentedon Jul 30, 2026
This looks like a checkpoint-integrity failure rather than ordinary model drift. A useful regression test would persist the current phase, completed actions, modified files, verification outputs, and exact next action before compaction, then assert that the restored session does not repeat prior commands or reopen resolved decisions. A repeated-work detector should stop the run once the same phase or command sequence recurs without new repository state.
post1917a commentedon Aug 10, 2026
I have an independent metric-level reproduction that matches this issue and shows a mid-turn operational-state loss even though compaction reclaimed ample headroom.
Environment
26.803.5235.0258,400tokensObserved sequence
236,838 / 258,400input tokens.413,695characters of model-facing tool outputs, plus the tool calls and visible assistant progress messages.5,050-character preservation summary.5,450-character message: a 400-character service preface followed by that preservation summary verbatim.replacement_historycontained 19 items:usermessagesdevelopermessages20,370tokens; the first continuation request used21,254input tokens.The active turn had added roughly
65,500input tokens before compaction. Replaying its operational tail after compaction would therefore have produced a prompt of roughly86,000tokens in this case, still far below the258,400-token window.This appears distinct from a compaction that simply fails to reclaim enough space. The compaction reclaimed substantial space, but the immediate continuation lost the completed action sequence and restarted work that the preserved summary already described.
I understand from #14589 that dropping raw tool outputs and assistant reasoning was previously classified as working as intended. Could a maintainer clarify the intended behavior for this narrower failure mode?
PreCompactplusSessionStart(source="compact")intended as the supported mitigation for this case, or only as general extension points?I am not attaching the raw rollout or a screenshot because they contain unrelated private task context, but I can provide additional redacted structural metrics if useful.
Lexoid2 commentedon Aug 11, 2026
Thanks for documenting this in such detail. This matches the failure mode I observed very closely.
In my case, the problem also wasn't simply that compaction failed to reclaim enough context. Codex would compact successfully and continue the same active task, but then fall back to an earlier execution state and repeat work that had already been completed.
Your finding that the replacement history contained none of the assistant or tool execution trail, even though the continuation still had plenty of context headroom, seems especially relevant to what I observed.
It makes the difference between normal compaction and losing the current operational checkpoint much clearer.
I'd also be interested in a maintainer clarifying whether preserving some bounded part of the current-turn operational history is expected or planned, since that seems directly related to the repeated-work behavior reported here.
Thanks again for the independent reproduction.
barcuchj commentedon Sep 3, 2026
This overlaps with #36584 at the checkpoint/handoff level, but the failure documented here is more specific: automatic compaction can restore an earlier task state and repeat completed work, consuming time and usage.
A handoff/checkpoint should therefore be available as a manual recovery path before or after compaction, not only as a warning. It should persist the exact next action, completed and pending work, modified files, Git/worktree identity and dirty state, build/test results, artifacts, subagent findings, and unresolved blockers, then create a successor task while leaving the original intact for audit.
A useful regression test would assert that a resumed task does not repeat commands or reopen resolved decisions when repository state has not changed.
iliaschatt1993-code commentedon Sep 15, 2026
I’m exploring how people preserve state across long coding-agent sessions.
In your case, what is the one artifact you wish had persisted before compaction — decisions, next steps, verification state, or something else?
I’m trying to understand the failure mode properly.
barcuchj commentedon Sep 15, 2026
@iliaschatt1993-code Thanks for asking. The most important missing artifact was not another prose summary, but a structured execution checkpoint.
It should preserve:
If I had to choose the single most important field, it would be the exact next action together with the completed-versus-pending verification state.
In my case, Codex had reached build/verification and then, after compaction, behaved as if it had returned to an earlier phase. It reread files, repeated commands, and reconsidered resolved decisions. The failure was therefore loss of operational state, not merely loss of conversational context.
A HANDOFF.md-style artifact would be useful as a human-readable projection, but the runtime should also preserve machine-readable state so the next continuation can resume from the exact next action rather than reconstructing the task from a general summary.
John-Rood commentedon Sep 18, 2026
Nothing here needs a code change. The artifact @barcuchj described (the exact next action plus verification state) can be produced on current builds with one file and a write rule. The measurement from @post1917a above is why it has to be a file: after compaction the continuation receives the summary plus user and developer messages, with zero assistant turns, tool calls, or tool outputs carried over. It is reasoning about work it can no longer inspect, so it re-derives the task instead of continuing it.
RUN.mdat the repo root, one per task:Rules that make it hold:
git rev-parse HEAD,git status --porcelain). On a mismatch, fix the ledger before any other work.Put rule 3 in AGENTS.md so it covers every task, and repeat it in the task prompt for any run already in flight: Codex builds the instruction chain once per run, so an AGENTS.md edit does not reach a live session (developers.openai.com/codex/guides/agents-md).
For subagent work, have each subagent write its receipts under the same run directory before returning, and reference them from the main DONE list. Subagent tool output disappears at the boundary; the files do not.
Try it on the next long task: put a unique token in NEXT, trigger compaction mid-run (/compact), and confirm the continuation resumes from the token without re-reading old files. If a continuation ever runs the same command twice with no new artifact between the runs, stop it and reconcile from RUN.md.
barcuchj commentedon Sep 23, 2026
@samvallad33 Yes — I think persisting task state outside the compacted conversation and reloading/reconciling it after compaction is the right architectural direction.
The important distinction is between a conversation summary and execution state. A summary can say that implementation and testing were performed, but that is not enough to reliably determine what actually completed, what remains pending, what the exact next action is, which commands/tests produced verified results, or what subagents already established.
@John-Rood's
RUN.mdproposal is a useful workaround on current builds because it moves some of that state outside the compacted history. I would use something similar for long-running tasks today. But I don't think it means the underlying issue requires no product change.There is still a failure window if an action completes and compaction occurs before the model updates
RUN.md. More generally, users should not need to implement their own checkpoint protocol inAGENTS.mdto prevent an internal compaction mechanism from causing completed work to be repeated.Ideally, Codex itself would maintain persistent machine-readable execution state outside the compactable conversation history, including at least:
After compaction, Codex could reload that checkpoint, reconcile it against the actual repository state, and continue from the recorded next action rather than reconstructing operational state from a prose summary.
The ordering matters too: an action should only become “completed” once its result/receipt and updated task state have been persisted. Otherwise the same race can simply move from the conversation summary into the checkpoint mechanism.
So I see
RUN.mdas a good user-space mitigation and potentially a useful model for the feature, while persistent runtime-managed execution state would address the underlying regression.John-Rood commentedon Sep 23, 2026
@barcuchj The ordering point is the right place to tighten, and it exposes the gap in what I posted above: a journal written only after completion always loses whatever finished inside the window.
Write ahead of the action instead of behind it. Log the step as IN-FLIGHT with the exact command or target, then flip the line to DONE with the receipt once it lands. If compaction fires mid-step, the resume finds an in-flight line and reconciles that single item against the repo before anything else runs. Worst case shrinks from "completed work replayed" to "one line to verify".
And I agree it shouldn't stay a user-space protocol. Runtime-managed execution state that reloads and reconciles after compaction is the real fix; the file is the bridge for builds that don't have it yet.
barcuchj commentedon Sep 23, 2026
@John-Rood Agreed —
IN-FLIGHT → receipt → DONEcloses most of the race window and makesRUN.mda much stronger workaround.I would still emphasize that this should remain a temporary bridge rather than the expected user-side solution, especially because the workaround itself consumes the user's usage. Reading and updating the journal, producing receipts, and reconciling state after compaction all require additional model/tool work.
That matters particularly for this issue because one of the reported consequences of the regression is wasted usage from replaying completed work. Users should not have to spend additional usage implementing and maintaining a checkpoint protocol to compensate for an internal compaction mechanism.
If execution-state persistence is runtime-managed, the bookkeeping can happen at the system boundary rather than being repeatedly performed by the model as part of the user's task. The user-space journal is a good mitigation until that exists, but its cost should not become part of the normal workflow.
post1917a commentedon Sep 23, 2026
“Nothing here needs a code change” is an extraordinary conclusion to draw from a workaround. If users have to keep an
IN-FLIGHTjournal so Codex can get through its own automatic compaction, what exactly has been fixed?In my reproduction, compaction left ample context headroom, the continuing model received no assistant or tool trail, and Codex promptly repeated completed work. The repetition is the bug.
RUN.mdmay limit the damage, at the user’s expense in time and usage. It does not make the failure disappear. A workaround for lost execution state is evidence that execution state needs to survive compaction – not an argument for leaving the issue unfixed.John-Rood commentedon Sep 23, 2026
@post1917a Fair. "Nothing here needs a code change" overstated it. What I meant: nothing blocks a mitigation on current builds. The repetition is the bug and the fix belongs in the runtime, either carrying the current-turn tool trail across compaction or reloading a reconciled checkpoint at the boundary. The journal is only for runs in flight before that ships.