codex - 💡(How to fix) Fix System prompt does NOT survive compaction [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19111Fetched 2026-04-24 06:00:43
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2unlabeled ×1
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

0.122.0

What subscription do you have?

pro max

Which model were you using?

gpt-5.4

What platform is your computer?

Darwin 25.3.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

iTerm2

What issue are you seeing?

System prompt does NOT survive compaction, so whatever we put in ~/.codex/CODEX.md is only known to it before compaction, and lost afterwards.

What steps can reproduce the bug?

  1. Give it a list of commands you want it to know about.
  2. Ask it if it knows one or all
  3. Work and await compaction
  4. Ask it again

What is the expected behavior?

System prompt to be preserved verbatim and not even be part of compaction.

Additional information

To no avail, we also tried markers around our system prompt (using experimental_compact_prompt_file ="$HOME/.codex/CODEX.compaction.md") with these instructions:

You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.

Include:

  • Current progress and key decisions made
  • Important context, constraints, or user preferences
  • What remains to be done (clear next steps)
  • Any critical data, examples, or references needed to continue

Be concise, structured, and focused on helping the next LLM seamlessly continue the work.

When compacting context, preserve verbatim every byte between <!-- CONTEXT_PRESERVATION_START --> and <!-- CONTEXT_PRESERVATION_END -->.

Keep the markers themselves. Do not summarize, normalize, reformat, reorder, or delete any enclosed content. Copy it forward exactly as-is across every compaction cycle before the compaction output. This ensures that all critical information is retained

extent analysis

TL;DR

The system prompt is not surviving compaction, likely due to incorrect usage of context preservation markers.

Guidance

  • Verify that the experimental_compact_prompt_file is correctly set to "~/.codex/CODEX.compaction.md" and that the file contains the system prompt wrapped in the correct markers: <!-- CONTEXT_PRESERVATION_START --> and <!-- CONTEXT_PRESERVATION_END -->.
  • Check that the markers are correctly placed around the system prompt in the ~/.codex/CODEX.md file.
  • Ensure that the compaction process is correctly configured to preserve the content between the markers.
  • Test the compaction process again after making these changes to see if the system prompt is preserved.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

The issue may be due to a misunderstanding of how the context preservation markers work or incorrect configuration of the compaction process.

Recommendation

Apply workaround: correctly configure the context preservation markers and test the compaction process again, as the issue seems to be related to the usage of these markers rather than a version-specific bug.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix System prompt does NOT survive compaction [2 comments, 2 participants]