codex - 💡(How to fix) Fix Goals: active goal continuation prompt and audit requirements can be lost after mid-turn compaction [1 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#19910Fetched 2026-04-28 06:35:11
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×3commented ×1mentioned ×1renamed ×1

Root Cause

This leaves a concrete failure mode: the agent is busy finishing up a local task of its own -- for example running tests and verifying its changes. Compaction happens in the model of this finishing up process, and the compaction message conveys to the agent with fresh context that this specific task is almost done, the previous agent was just verifying their changes, continue with the verification. This new agent then proceeds to perform the verification process, and after it is done mark the goal as complete because it was only fed that the local task and not the global goal and the audit requirements of it (the bigger picture).

Fix Action

Fix / Workaround

I have a small local patch of roughly 193 lines for this and would be happy to open a PR or discuss the approach further, since I understand goals is a WIP and likely still evolving.

RAW_BUFFERClick to expand / collapse

@etraut-openai first off, incredible work on the new goals feature. This fixed the most painful part of using Codex: having the model sandbag its work and not actually complete what you want fully. This is genuinely life changing stuff.

There is quite a persistent issue with it, however. That issue is that after compaction, the goal is sometimes not carried through cleanly to the new agent.

I have been using the goals feature extensively over the past few days, and none of the times I have ran it on ambitious work has the work been completed, and that is due to one specific reason: compaction.

Often, the compaction message does not carry the goal task through cleanly, and more specifically it often does not carry through cleanly the most important "perform a completion audit against the actual current state" requirement of the goal prompt.

This leaves a concrete failure mode: the agent is busy finishing up a local task of its own -- for example running tests and verifying its changes. Compaction happens in the model of this finishing up process, and the compaction message conveys to the agent with fresh context that this specific task is almost done, the previous agent was just verifying their changes, continue with the verification. This new agent then proceeds to perform the verification process, and after it is done mark the goal as complete because it was only fed that the local task and not the global goal and the audit requirements of it (the bigger picture).

I have found this to be the root cause of the agent prematurely stopping:

  • After compaction in these circumstances, the new agent often sends a message to the commentary channel before running any tools like "Let me finish running tests so I can wrap this goal up". The agent then runs the tests, looks at the git status, and a few modified files, and that is enough to satisfy its confirmation bias to mark the goal as completed. This is a red flag as it shows the agent has treated completion of the goal as a foregone conclusion, then interpreted circumstantial evidence as confirmation.
  • I have reverse engineered the opaque compaction message in these scenarios, and it clearly does not convey the completion audit of the goals prompt effectively, if at all.

I have implemented a fix locally for this where the active goal continuation prompt is now reattached during mid-turn compaction for both local and remote compaction paths, using the persisted active goal and only when the current turn is the synthetic goal-continuation turn. Manual/pre-turn compaction stays unchanged to avoid duplicate prompts.

I have ran many extremely ambitious, long-horizon tasks after this change and the rate of premature closure has dropped significantly as my changes eliminated the primary failure mode.

This is the correct solution as:

  • The continuation prompt without the {{ objective }} placeholder is 462 tokens (via o200k_base). Add a relatively average user goal prompt and that is likely 500-1000 tokens. This is a perfectly acceptable amount of tokens to inject after compaction.
  • This keeps the persisted goal table as the source of truth and avoids depending on the compacted summary to remember the active objective.
  • The orthogonal-to-this-solution way to fix this failure mode is essentially adding a tool to retrieve the goal prompt for the new agent to call, which is the wrong fix as if the agent already has the goal in their context, this tool is practically useless. The only scenario the agent will not have the goal in its context is compaction, which makes the correct fix injecting the goal directly after the only time the model may lose it.

An alternative acceptable solution is making and injecting after compaction a brand new compaction-centered message with the goal. This is still not the optimal fix in my opinion as the current continuation prompt is short and is already in the optimal shape for a post-compaction injection ("Continue working toward the active thread goal."), and this would just be reinventing a prompt to achieve the exact same outcome as the current continuation prompt.

I have a small local patch of roughly 193 lines for this and would be happy to open a PR or discuss the approach further, since I understand goals is a WIP and likely still evolving.

extent analysis

TL;DR

Reattaching the active goal continuation prompt during mid-turn compaction can fix the issue of the agent prematurely stopping due to loss of goal context.

Guidance

  • The issue is likely caused by the compaction message not conveying the completion audit requirements of the goal prompt effectively, leading to the new agent treating goal completion as a foregone conclusion.
  • To verify, check the compaction message and the agent's behavior after compaction to see if it is indeed losing the goal context.
  • Reattaching the active goal continuation prompt during mid-turn compaction, as implemented in the local patch, can help resolve the issue.
  • An alternative solution is to create and inject a new compaction-centered message with the goal, but this may not be the optimal fix.

Example

No code snippet is provided as the issue does not contain explicit code, but the local patch of roughly 193 lines is mentioned as a potential solution.

Notes

The solution may need to be adapted based on the evolving nature of the goals feature, and discussion with the maintainers may be necessary to ensure the fix is compatible with the current implementation.

Recommendation

Apply the workaround of reattaching the active goal continuation prompt during mid-turn compaction, as it has been shown to significantly reduce the rate of premature closure in ambitious tasks.

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 Goals: active goal continuation prompt and audit requirements can be lost after mid-turn compaction [1 comments, 2 participants]