How to Call Codex CLI from Claude Code for a Second Opinion: `codex exec` vs. `codex mcp-server`
When Claude Code reviews a code change, you can have it ask OpenAI’s Codex command-line interface (CLI) to review the same project…
When Claude Code repeatedly says it is compacting, it is summarizing earlier conversation content to free space in its context window. That context window holds everything Claude can use in the session, including chat history, project instructions, and tool information. You hit a compaction loop when the context fills back up soon after Claude Code finishes a summary, leaving little room for useful work.
A large file or a long command output can refill the context quickly, though other factors can do the same. Claude Code may reload project instructions on every turn, hit a small configured compaction window, or run into a bug tied to a specific version or platform. Start by checking what fills the context and which compaction settings take effect. Cut down whatever is refilling the window, and turn off automatic compaction only if you are ready to manage the context yourself.
Claude Code normally starts compacting when a conversation approaches its configured threshold. It summarizes earlier turns so you can keep working with less chat history taking up space. According to the settings reference, Claude Code turns auto-compaction on by default.
You see a loop when the context hits that threshold again right after a summary. Claude Code trims the conversation history, yet other material stays in the window or loads again. Project instructions or tool output can take up a large share of the available space, and if Claude Code reads the same material over and over, the context refills faster than you can get work done.
In one GitHub report, a user saw project instructions get injected again after each compaction and counted 16 compactions in 1 hour and 48 minutes. Those reported measurements show how recurring context can overwhelm a single session, though they come from one user and do not establish a typical rate or explain every loop.
If Claude Code shows a warning about a large file or tool output, check that file or output first, though the warning alone does not prove it caused the loop. Other users have reported rapid compaction without obvious context growth, including a Claude Code Web session that filled back up after a few commands, with no confirmed cause.
Run /context to see the context breakdown. Check whether conversation history, project instructions, tools, or other loaded material takes up the most space, then make a change that matches what you see.
If your CLAUDE.md file contains broad instructions that apply only to parts of the repository, shorten it and move those instructions into path-scoped rules. Claude Code’s troubleshooting guidance also recommends turning off unused servers that use MCP, or Model Context Protocol, which lets Claude Code connect to external tools and sources of context. Run /mcp disable <name> to turn off any server you are not using.
If the context breakdown does not point to a clear source, start Claude Code with claude --safe-mode to test whether a plugin, MCP server, or hook is causing the problem. During the session, watch for repeated file reads or large command outputs, and narrow your searches or read smaller file ranges when those outputs keep coming back. You can cut context use this way when those items are present, though these steps will not find or fix every cause.
For more ways to save context, see how to reduce Claude Code token usage.
You can set the auto-compact window, which controls how much context Claude Code uses before it starts compacting. The model configuration documentation covers how to set it through /autocompact, the --autocompact launch option, autoCompactWindow, and CLAUDE_CODE_AUTO_COMPACT_WINDOW. The documented window must be at least 100,000 tokens and cannot exceed the model’s context window.
Claude Code can read settings from several places, so a value in one file may not be the value it uses. Check the session’s model and configuration, including command-line options and environment variables. You can run /autocompact auto to return the current model to its tuned window. If you raise a low threshold, you give Claude Code more room before it compacts, though doing so will not stop it from reloading the same material or fix a context-accounting bug.
One user report linked thrashing to a 100,000-token window, though the reporter’s explanation that fixed context left too little working room was never confirmed. Treat a threshold change as a diagnostic test rather than a guaranteed fix.
When you turn off auto-compaction, you stop Claude Code from compacting on its own. That change does not enlarge the context window or keep it from filling up. If you keep working without freeing space, Claude Code will eventually hit a context-limit error.
You can turn off Auto-compact in /config, or set autoCompactEnabled to false:
{
"autoCompactEnabled": false
}
If you launch Claude Code from a shell, the environment-variable documentation also lists this option:
DISABLE_AUTO_COMPACT=1 claude
You can still run /compact by hand whenever you want to clear space. Avoid setting DISABLE_COMPACT by mistake, because it turns off both automatic compaction and the manual /compact command.
Before you leave a session that still responds, save your important changes and note the current task, relevant files, and next step. If repeated compactions have stopped Claude Code from making progress, start a fresh session with that short handoff. When you start fresh, you drop the long conversation history, though recurring instructions or other loaded context can still take up space.
Update Claude Code and restart the app or process before you test again, especially after changing an environment variable. In one reported desktop case, removing an environment setting did not stop the loop until the user restarted the app. That makes restarting a sensible troubleshooting step, even if it does not solve every case.
If the loop continues, record your Claude Code version, platform, model, effective compaction settings, /context output, and the commands that ran before each compaction. That information helps separate rapid context growth from a configuration or version-specific problem. User reports describe loops across different versions and platforms, and they do not point to a single cause that applies to every session.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com