Codex auto-compact loses critical task details and causes wrong execution, even on small fixes

Resolved 💬 6 comments Opened Apr 20, 2026 by jhonpatrick Closed May 8, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

codex 26.415.40636

What subscription do you have?

pro

What platform is your computer?

windows

What issue are you seeing?

I want to report a product bug in Codex app related to "auto-compact / handoff", not model capability.

After working with Codex heavily for about two weeks, I initially thought GPT-5.4 was "not following instructions." After more testing, I found the real issue: when the context window is already highly filled and Codex triggers "auto-compact during execution", the handoff loses important task details. After that, the model continues working from an incomplete internal summary and starts solving a different problem than the one I asked for.

This is not specifically a long-running task issue. I can reproduce it even on a very small fix.

A concrete example:
This happened on a very small UI fix, only about "17 lines of code changed".

My real request was to improve the selected-node animation "without changing the concept of the effect".

The model initially understood this correctly. Early in its reasoning, it stated:

"I’ll fix the animation quality of the selected node specifically: remove the line through the center and replace it with a more professional edge effect along the card border, without touching the map logic."

That was correct.

Then auto-compact happened during execution.

In the final response, it said:

"I removed the masked conic ring that caused the center artifact and replaced it with a small light 'comet' rotating around the outer edge of the card. Glow and node selection logic were unchanged; only the active orbit rendering method changed."

This is the key bug:
the original task was to preserve the intended edge-animation concept and fix the artifact, but after compact the model changed the actual animation approach and delivered a different solution than requested.

So the failure was not "bad coding" or "bad reasoning."
The failure was that "the purpose of the fix was lost during handoff".

What steps can reproduce the bug?

  1. Work in Codex long enough that the context window becomes highly filled, around "90%-97% full".
  2. Start a new request while the context is already near full.
  3. Use a task that the model initially understands correctly, including a constrained fix where the exact intent matters.
  4. Let Codex continue until "auto-compact" happens during execution.
  5. Compare the original request with the final result after compact.

What I observe during reproduction:

  • Before auto-compact, the model understands the task correctly.
  • During execution, auto-compact happens.
  • After compact, the model continues from a degraded internal handoff.
  • The final result is often adjacent to my request, but not the actual requested fix.
  • This makes it look like the model is "ignoring instructions," but the real issue is context loss during compact/handoff.

What is the expected behavior?

Auto-compact / handoff should preserve the full intent, constraints, and priority of the original request, even when the context window is already highly filled.

If the model understood the task correctly before compact, it should continue solving that same task after compact without changing the requested approach.

In the example above, the expected behavior was:

  • preserve the intended edge-animation concept,
  • fix the visual artifact,
  • and not replace the animation with a different effect.

The handoff summary should not become incomplete or distorted in a way that changes execution.

If there were an option to trigger handoff and compact manually, that would likely solve the entire problem.

Additional information

The model may still read agents.md after auto-compact, but the problem is not that it stops reading instructions entirely. The problem is that the handoff summary itself becomes incomplete or distorted, so the execution path changes.

Because of that, this can look like an instruction-following problem, but in my testing it appears to be a product-level compact/handoff issue instead.

In most of my work, GPT-5.4 followed the intended plan very closely, especially on smaller tasks. On larger refactors or broader-scope requests, there were occasional cases where it deviated somewhat, but those were relatively rare. In my experience, the more serious failures began specifically after auto-compact occurred during execution of the plan.

Thank you for your time and attention to this issue.

View original on GitHub ↗

6 Comments

github-actions[bot] contributor · 3 months ago

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

  • #17912
  • #18257
  • #18517
  • #18707

Powered by Codex Action

jlekerli-source · 3 months ago

having the same issue

0x80O0oOverfl0w · 2 months ago

Same issue, this needs to be fixed, really annoying when you're 45 min deep into an ML training session and you have to redo it because Codex "forgot" about it.

jhonpatrick · 2 months ago

Yes, this breaks the whole workflow.

The only workaround I have found so far, until the devs fix it, is based on the fact that after any auto-compact, Codex/GPT first reads AGENTS.md automatically before continuing work.

So I came up with rules using two additional files where I store all the important things needed to complete the current task. Any important agreements with the assistant go into ACTIVE_CONTRACT.md, and the task and plan go into ACTIVE_PLAN.md.

Overall, this works. I’ve managed to get tasks completed with about 95–100% reliability, especially on large refactors where several auto-compacts happen while the plan is being executed.

The only thing you need to watch is the contract: what gets written there and when to clean it up after the task is finished. Essentially, you store important agreements, current-task memory, and general invariants with the assistant there.

As a result, after each auto-compact, Codex/GPT reads three files before continuing:

AGENTS.md, ACTIVE_CONTRACT.md, and ACTIVE_PLAN.md.

It is also important to reinforce these rules in your own prompts whenever you ask the assistant to perform a task. It does not really matter whether you use GPT-5.4 or GPT-5.5. I even worked with GPT-5.2 for a week because that model follows prompts extremely well, but even it broke the plan after an auto-compact.

So the model choice may not matter as much as it seems. After auto-compact, the model receives an incorrect summary. If the model is to be believed, it says that this summary is created by another agent. I could not find any information online about who actually performs the handoff/summary for continuing the work.

If you want to try it, I’ll leave the rules below. They should be added to the very beginning of your AGENTS.md file.

0. WORKFLOW SOURCE OF TRUTH

For active work, disk files beat chat memory and compact summaries.

Primary active files:

  • ACTIVE_CONTRACT.md
  • ACTIVE_PLAN.md

Before implementation:

  1. Read ACTIVE_CONTRACT.md if it exists.
  2. Read ACTIVE_PLAN.md if it exists.
  3. Follow those files plus the latest user instruction.
  4. If they conflict, stop and ask.

During discussion:

  • Any durable user decision must be written to ACTIVE_CONTRACT.md before implementation continues.
  • Any approved execution sequence must be written to ACTIVE_PLAN.md.

After auto-compact:

  1. Do not trust the handoff summary as source of truth.
  2. Re-read the active workflow files.
  3. Report the recovered active contract briefly.
  4. Continue only if the contract is complete and matches the latest user request.

User workflow commands:

These commands are manual shortcuts, not the only allowed way to update active workflow files.

The assistant must still update ACTIVE_CONTRACT.md when a durable user decision is made, and ACTIVE_PLAN.md when an execution sequence is approved, even if the user does not use these commands.

  • !contract: append a concise decision record to ACTIVE_CONTRACT.md based on the latest agreed discussion.
  • !contract: ...: append the provided text as a durable decision, with minimal context if needed.
  • !plan: append a concise execution-plan note to ACTIVE_PLAN.md based on the latest approved implementation sequence.
  • !plan: ...: append the provided text as an approved plan note.
  • These commands are explicit permission to edit only the targeted active workflow file.
jhonpatrick · 2 months ago

Latest update: the issue has been resolved. Thank you for your attention.

cowwoc · 1 month ago

Possible strong relation to #28736.

#28736 now has source + testcase evidence that SessionStart(source=compact) is not delivered immediately after mid-turn auto-compaction. Compact events are queued and only delivered on a later turn.

That means a fresh post-compaction agent can continue execution in the same logical turn without restored post-compaction context. This seems directly relevant to the symptom here where the task intent/constraints were understood before compaction but the execution path changed after compact/handoff.