Auto-compaction re-executes the previous command after context compression

Open 💬 2 comments Opened Jun 18, 2026 by jykim89

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

Version 26.611.62324 • Released 2026. 6. 17.

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Windows 11 x64

What issue are you seeing?

Summary

After Codex performs context auto-compaction / context compression, it sometimes re-executes the previous user command instead of continuing from the latest instruction.

The issue is very specific:

After context compression, Codex executes the command I gave immediately before the compression again.

This is dangerous during coding sessions because the previous command may have already modified files, run shell commands, deleted/generated files, or performed a large refactoring step. After compaction, Codex should not replay or re-run the previous instruction.

Expected behavior

After context compression, Codex should preserve the correct conversation state and continue from the latest user instruction.

It should not automatically re-execute the command that was already completed before compaction.

Actual behavior

After context compression, Codex resumes and executes the previous command again.

For example:

  1. I give Codex an implementation/refactoring command.
  2. Codex performs the task.
  3. Context compression happens.
  4. After compression, Codex executes the same previous command again, even though I did not ask it to repeat it.

Why this is a problem

This can cause duplicated code changes, repeated file edits, repeated shell commands, and unnecessary risk during large coding tasks. It is especially problematic during long-running refactoring sessions.

Reproduction pattern

I do not have a minimal reproduction yet, but I have observed it during long Codex coding sessions where auto-compaction is triggered.

The pattern is:

  1. Start a long Codex session.
  2. Give Codex a large coding/refactoring task.
  3. Let the session reach context auto-compaction.
  4. After compaction, Codex resumes.
  5. Codex re-executes the previous user command instead of waiting for or following the latest instruction.

Notes

This appears to be a turn/session resume issue around context compression. The model seems to treat the previous command as if it still needs to be executed after compaction.

What steps can reproduce the bug?

I do not have a minimal reproduction yet, but I have observed it during long Codex coding sessions where auto-compaction is triggered.

The pattern is:

  1. Start a long Codex session.
  2. Give Codex a large coding/refactoring task.
  3. Let the session reach context auto-compaction.
  4. After compaction, Codex resumes.
  5. Codex re-executes the previous user command instead of waiting for or following the latest instruction.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗