Why does Codex trigger "Context automatically compacted" so frequently?

I’m seeing “Context automatically compacted” extremely frequently in Codex.

In many cases the agent only:

  • Reads a few files
  • Runs a few commands
  • Makes a small code change

Yet auto-compaction happens repeatedly.

Do you tend to use only 1 session?

How many artifacts are you dragging around typically in a session?

Those are my first two questions I’d be troubleshooting with if this were happening to me.

Anything over 20-30 is usually a bit much, depending on the scope of your work…

Oh, I ran into the exact same situation where tokens were going down the drain and Codex itself couldn’t do anything useful. All I saw were messages in this sequence:

I’ll look into the issue now. Searching…
Context automatically compacted.
After the context compression, I’ll figure out where we left off.
Context automatically compacted
It looks like the context was compressed, and I’ll continue working.
Context automatically compacted

Anyway, just like with many other people I found facing this problem, no one had posted a solution.

And after 8 hours—having deleted VS Code and Cursor, and scrubbed every directory of all MCPs and skills—I was back to square one…

Context automatically compacted
Context automatically compacted
Context automatically compacted

That turned out not to be the problem.

In the Codex chat, you need to click the gear icon and go to Codex Settings.
Select the “Personalization” tab there.

Look at the “Custom instructions” text field.

Since I write in Cyrillic rather than English, one MCP had inserted rules using Cyrillic text; naturally, this became unreadable due to an encoding error, turning all the Cyrillic characters into gibberish.

When this situation started, the first thing I saw were messages claiming my requests looked like a system hack attempt, and it started blocking all requests. Then something changed—requests started getting through, but the “Context automatically compacted” message appeared.

It’s hard to believe that a broken encoding issue could cause such problems for people who don’t work in English, but the fact is: I deleted all the text with the corrupted encoding from that field, kept only the English versions, and everything is working perfectly again.

Wiping away a cold sweat.

Thanks for raising this.

Referring to that error message, it may not be limited to the context of the latest output. Factors like remaining account limits, earlier conversation context, file contents, instructions, and command output can all contribute.

That could explain the frequency you're seeing, but we can't confirm the cause from the report alone. If this is still happening, try updating Codex and starting a fresh thread with a brief task summary and only the relevant files.

If compaction still repeats after a few small actions with little progress, please report it through the Codex issue tracker. Include your client version, model, reproduction steps, and screenshots or sanitized logs, noting whether compaction completes normally, stalls, or loses important task details.

Avinash

Out of curiosity, do you have lot of skills downloaded? If there are lot of skills, Codex shortens the descriptions of them automatically, and this sometimes impedes its ability to pick the right skill, so the progressive disclosure is not really put to work, and it ends up traversing and loading a tonne of skills into its context.

If you have lots of skills downloaded, could be worth backing them up, removing all of them except the system ones, and seeing if the problem persists?

If you don’t have a lot of skills, ignore this :slight_smile: