Support additive compaction guidance without overriding the built-in compact prompt
What variant of Codex are you using?
Codex CLI / Codex app
What feature would you like to see?
I would like Codex to provide a supported way to add small user-defined preservation requirements to the context compaction process without fully overriding Codex's built-in compaction prompt.
Today, Codex exposes compact_prompt / experimental_compact_prompt_file, but these appear to be overrides rather than additive extensions. That makes them risky for this use case: if I provide my own compact prompt just to preserve a few important rules, I may accidentally replace or weaken Codex's default compaction behavior.
The specific need is not to rewrite how compaction works. It is to tell Codex, at compaction time:
- preserve applicable
AGENTS.md/ repository instructions - preserve active user constraints and standing requirements
- preserve the current task goal, open TODOs, blockers, verification status, and important decisions
- do not weaken these into vague summaries if they still affect future work
Ideally this would be an additive setting, for example:
compact_prompt_append = """
Preserve applicable AGENTS.md rules and active task invariants.
Do not omit verification requirements, current TODO state, blockers, or user-stated constraints.
"""
or a more explicit small invariant slot:
[compaction]
preserve_invariants = [
"Preserve applicable AGENTS.md and project rules.",
"Preserve current task state, TODOs, blockers, and verification requirements.",
"After compaction, reconstruct state before continuing if anything is uncertain."
]
The important distinction is that this should augment Codex's existing compaction prompt, not replace it.
Problem
In long-running sessions, automatic compaction is necessary, but it can create uncertainty about what survived. Critical task state and operational instructions may be compressed too aggressively or omitted.
For repository development, some instructions are not ordinary conversation history. For example:
AGENTS.mdrules- verification requirements
- active user preferences
- current plan / TODO state
- known blockers
- files changed
- decisions already made
- assumptions that must be rechecked before continuing
If these are lost or weakened during compaction, Codex can continue with degraded context, repeat work, miss verification requirements, or behave as if earlier constraints no longer apply.
A full compact_prompt override is not an ideal workaround, because users who only want to add a small preservation reminder may unintentionally replace a carefully tuned default prompt.
Expected behavior
Codex should support a small additive compaction guidance layer that is applied alongside the built-in compaction prompt.
This guidance should be:
- additive, not a full override
- small and intended for preservation requirements, not arbitrary long memory
- applied to both manual and automatic compaction
- safe across CLI/app surfaces where compaction is supported
- documented clearly so users know when to use it instead of
compact_prompt
After compaction, Codex should be more likely to preserve the operational effect of important repository/user instructions without requiring users to replace the entire default compaction prompt.
Why this matters
This would make long-running Codex sessions more reliable while preserving the benefits of the default compaction behavior.
It would also address a gap between existing mechanisms:
AGENTS.mdis good for durable repository guidance, but users still need confidence that its active operational requirements are preserved across compaction.PreCompact/PostCompacthooks can observe lifecycle events, but they are not a documented way to inject preservation instructions into the compaction prompt.compact_promptcan guide compaction, but as an override it is too heavy for users who only need a small additive reminder.
Related issues
This seems related to, but not exactly the same as:
- #21468 - prompt-guided compaction and visible compact summaries
- #25083 - "Do Not Compact" areas
- #25792 - compaction forgetting AGENTS rules / task state
- #27130 - non-compactable preflight rule slot
- #21777 - exposing compaction to the agent with summary instructions
- #17148 / #28736 - compact lifecycle hooks and post-compact restoration timing
This request is specifically for an additive, low-risk way to guide compaction without replacing Codex's built-in compaction prompt.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗