Context compaction causes task drift: assistant reverts to stale prior request and executes unrelated command

Resolved 💬 6 comments Opened Feb 10, 2026 by JLarM2Utah Closed May 14, 2026

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

CODEX plugin in VS Code - GPT5.3 Codex

What subscription do you have?

Plus

What issue are you seeing?

Product: Codex coding agent (GPT-5 based) in IDE workflow
Environment: Windows, PowerShell, local repo workspace
Date observed: [fill your local timestamp + timezone]
Frequency: Intermittent but reproducible after “Context automatically compacted”

Summary:
After “Context automatically compacted” appears, the assistant may acknowledge my current prompt correctly, then later revert to a prior request from recent history and execute unrelated actions.

What happened:
1) I sent this prompt:
“our standard table needs to have access to a data layer that has columns that are hidden but can be used by the presentation layer to drive behavior.....”

2) Assistant initially responded correctly:
“You want hidden data available to table behavior without rendering those columns...”

3) Soon after another “Context automatically compacted” appeared.

4) Assistant then switched to a stale prior task and executed unrelated command flow:

  • “I’ll push main again now so the latest fix is definitely on origin...”
  • Ran: git push origin main
  • Reported: “Everything up-to-date”
  • Continued with unrelated Vercel redeploy/env-var guidance

Expected behavior:

  • After compaction, assistant should remain scoped to the latest user prompt.
  • No unrelated command execution from stale context.
  • If confidence is low after compaction, assistant should ask for confirmation before taking actions.

Actual behavior:

  • Task drift to previous request.
  • Unrelated terminal action executed.

Impact:

  • Trust/safety issue for coding workflows.
  • Risk of unintended repository actions.
  • Requires user to manually detect drift and stop execution.

Evidence snippets:

  • “Context automatically compacted”
  • Correct intent acknowledgment for hidden data requirement
  • Later unrelated action: “I’ll push main again...”
  • Command executed: git push origin main

Please investigate context-merging logic around compaction and guardrails for tool/action selection after compaction.

What steps can reproduce the bug?

Codex chat thread with a lot of history

What is the expected behavior?

Stay on the current prompt

Additional information

_No response_

View original on GitHub ↗

6 Comments

human-bee · 5 months ago

this also seems to be happening to me. codex 5.2 has a slight regression on auo-compaction, cuasing it to work on things it had finished previously.

MisterRound · 5 months ago

Compaction is the biggest weak-point as of current. The current implementation is suboptimal in many regards. It wastes a huge amount of tokens re-auditing, and then when you get "caught up" to the actual task, you've already burned through half the context window just to proceed with the current task. It doom loops through this. Compaction is critical, it's not enough to just say "use short tasks in individual agents" when you're working on something deep context. I think the entire summary compaction process needs a page one overhaul as it's literally regressive yet critical.

nullbio · 4 months ago

Came here to see if this was being spoken about.

I send my agent on some long-running task and tell it to do a sequence of steps (let's call them steps 1, 2 and 3). It completes most of those steps (1 and 2) and begins the longer-step (3).

It gets half way through 3 and compacts.

The agent then re-does step 1 after compacting when step 1 was already completed before, and it doesn't continue where it left-off with the half finished step 3.

ThinkOffApp · 4 months ago

We see this across 100K+ token sessions daily with multiple agents. Our mitigation: agents poll an external room (GroupMind) and re-read their instructions on each cycle rather than trusting conversation history. When compaction drops context, the agent's next poll picks up the current task from the shared room state. User Intent Kit adds another layer: a live "intent" signal that authoritatively says what the user wants right now, surviving any number of compactions. The problem is fundamental: critical state cannot live only inside the context window.

mahdikayvan · 2 months ago

@JLarM2Utah Hey — I saw your compaction drift issue, and it looked very close to the exact pain I’m trying to solve.

I’m building AgaveCore, and I’d like to let a few early people use it for free while I shape it into something stronger.

It helps when a coding agent starts to drift, forget important progress, or gives you an output you do not fully trust.

In practice, it works through two habits:

  • tell the agent to remember-progress or remember-this when something important should not be lost
  • use consult-brain when the current task needs more grounded feedback on what to do next

Over time, as useful journals, decisions, and failures pile up, the product should help the agent make sharper decisions and take better actions with less drift.

If this sounds relevant, reply here and I’ll send the exact steps. You can also use the email or Telegram on my profile.

Cheers,
Mads.