Context Pollution When Reverting a Task

Resolved 💬 4 comments Opened Nov 12, 2025 by LucasInsight Closed Jan 17, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.5.39

What subscription do you have?

Context Pollution When Reverting a Task

Which model were you using?

codex

What platform is your computer?

mac + vscode + codex.ide.ext

What issue are you seeing?

Description:
When reverting a task, the context does not properly clear the data from the previously reverted task, which leads to context pollution. This issue causes incorrect behavior or unexpected results due to lingering context data from previous tasks.

Steps to Reproduce:

Create and run a task using Codex.

Revert a previously executed task.

Observe that the context from the previous task is not cleared, leading to polluted context data.

The lingering context data affects the execution of the current task.

Expected Behavior:
When reverting a task, the context should be properly reset or cleared to avoid any contamination from previous tasks.

Actual Behavior:
The context is not cleared when reverting a task, causing context pollution and potentially impacting the task's execution.

Environment:

Codex version: [Include the version you are using]

Operating system: [Include your operating system details]

Python version: [Include the Python version used, if applicable]

Additional Information:
If possible, a potential fix could involve ensuring that the context is explicitly cleared when reverting a task or creating a new task. This would prevent any remnants from a previous task from interfering with subsequent ones.

What steps can reproduce the bug?

revert task

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #6449

Powered by Codex Action

etraut-openai contributor · 9 months ago

When you say "revert a previously executed task", what do you mean? What actions are you taking to perform the revert? Are you asking the model to revert its work? Are you click on the "Undo" in the code diff summary?

LucasInsight · 9 months ago
When you say "revert a previously executed task", what do you mean? What actions are you taking to perform the revert? Are you asking the model to revert its work? Are you click on the "Undo" in the code diff summary?

Thank you for your reply! I'd like to clarify what I mean by “revert previously executed task”.

In my view, the revert behavior of a task should follow the Cursor processing logic:

✅ Expected behavior

When a task is confirmed reverted, the system should:

  1. Simultaneously remove all information generated by this task in the context (including the model's internal task context, reasoning chain, implicit state, etc.);
  2. Not only revert the code diff, but also revert any implicit context effect brought by the task.

Otherwise, although the code diff is reverted, the internal context of the model has not been rolled back together, leading to later tasks experiencing context pollution — i.e., the code was reverted but the context is still dirty.

✅ Suggest supporting two types of rollback

In practice, there are two common scenarios:

  1. Full revert of the task (code + model context) → similar to Cursor's “Revert Task”
  2. Only undo the code diff, without touching the context → similar to an editor's Undo or manually reverting code

The issue I encountered is:
Although the code diff was rolled back, the context residue created by that task in history was not cleaned up together, which causes abnormal behavior in subsequent tasks.

etraut-openai contributor · 7 months ago

Closing out old bugs.