Skip to content

Context Pollution When Reverting a Task #6550

Closed

Description

@LucasInsight

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

Activity

  1. added
    contextIssues related to context management (including compaction)
    on Nov 12, 2025
  2. github-actions commented on Nov 12, 2025

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. etraut-openai commented on Nov 13, 2025

    @etraut-openai
    Contributor

    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?

  4. LucasInsight commented on Nov 17, 2025

    @LucasInsight
    Author

    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.

  5. etraut-openai commented on Jan 17, 2026

    @etraut-openai
    Contributor

    Closing out old bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcontextIssues related to context management (including compaction)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions