Codex agent stuck in infinite read/search loop ("Context automatically compacted") on macOS

Hi everyone,

Has anyone else run into issues where the Codex extension in Cursor for Mac gets stuck in an infinite read/search loop during complex agentic tasks?

My agent has been running for over 3 hours across multiple model selections (including 5.6 Sol Medium and 5.6 Sol Ultra). It keeps cycling through the exact same behavior:

  1. It announces a plan to inspect files and run preliminary searches (rg, git status, sed).

  2. It hits Context automatically compacted.

  3. It forgets its previous context, repeats the exact same file-reading steps, and loops indefinitely without actually applying file edits or executing builds.

Even editing the prompt or switching models mid-session hasn’t broken the loop—it eventually gets hit with Reconnecting /5 or crashes the Cursor app when attempting to “Branch in new chat.”

Is there a known fix or setting tweak to prevent the compaction algorithm from poisoning the agent’s task state?

Welcome to the forum!

You are welcome to discuss Codex issues here. However, the official place to report and track them is the OpenAI Codex GitHub issue tracker.

The issue of compaction losing relevant information during a compaction is quite common. So much so that a search of the issues for compact currently shows 993 open issues.

Consider searching the open issues, if an issue matches your problem, consider adding a :+1: reaction on the GitHub issue itself. Reactions on GitHub can help the developers gauge the number of affected users.

Also see:

I switched from the Codex extension in the Cursor desktop app to the standalone ChatGPT/Codex desktop app, and the issue is completely resolved.

Thanks for the reply with your solution, it helps when others post what worked for them.