MemoryLake
Back to all articles
NewsJuly 28, 2026·6 min read

Why Codex Forgets Your Project Context — and How to Fix It (2026)

If Codex has felt more forgetful lately, you're not imagining it. In July 2026 developers noticed OpenAI had quietly reduced the default input context for GPT-5.6 in Codex — from around 372k tokens to 272k, roughly a 27% cut, surfaced through a configuration change on GitHub rather than an announcement. Less room per session means compaction kicks in sooner, and compaction is where your project context goes to die.

The short answer: Codex forgets your project context because each session rebuilds understanding from your repo and then compacts it away as the window fills — nothing durably stores your architecture, decisions, or the rules you set, so a long task can lose the very requirements it started with.

Here's what's actually happening, how far `AGENTS.md` and compaction really get you, and how to give Codex a project memory that survives every session and every context cut.

Why Codex Forgets Your Project Context

How Codex handles context today

Codex starts a session by exploring: reading files, tracing dependencies, building a working model of your codebase in its context window. That model is session state. As the conversation grows, older content gets compacted — summarized and dropped — to make room. The understanding isn't stored anywhere; it evaporates when the session ends or the window fills, and the next task starts the exploration over.

The technical reason it doesn't stick

Compaction is lossy by design, and it doesn't respect what you consider important. A GitHub issue on the Codex repo documents compaction dropping AGENTS.md rules mid-task, with reported progress jumping from 97% back to 42% because the agent lost the requirements it had been following. Another documents context being lost when you switch models mid-session. And with the default input window cut by roughly a quarter, those compaction events now arrive earlier in a task than they used to. AGENTS.md helps — it's read at startup — but it's a static file you maintain by hand, and it can be compacted out of the active window like anything else.

What this costs you

Every session opens with rediscovery: the architecture, the key files, the dependencies, the decisions you already made. Developers describe exactly this on OpenAI's own forum, asking how to preserve project context across Codex sessions in a large codebase. Then there's the mid-task failure mode: an agent that forgets your requirements at 80% completion produces work you have to review line by line — and the smaller window makes that more likely, not less.

Codex's Built-in Workarounds (and Where They Stop)

AGENTS.md

The right home for stable instructions: conventions, commands, constraints. Two limits, though. It's hand-maintained, so dynamic knowledge — decisions made, approaches rejected, bugs resolved — never reaches it. And it isn't immune to compaction, which is exactly what the reported 97%→42% regression illustrates.

Compaction and re-reading

Compaction keeps a long session alive rather than hard-failing, which is genuinely useful. But it trades detail for room: the exact commands, the specific requirement, the earlier decision are what get summarized away. The agent then re-reads files to recover what it lost, spending tokens to rebuild what it already knew.

Starting a fresh session

The usual fix for a degraded session is to restart it — which restores window space by discarding everything the session had learned. You buy clarity by paying with context.

The shared wall: none of these is a durable, queryable store of your project's knowledge that survives a session boundary or a context-window change — the same root gap behind why Claude Code forgets project context.

The Fix: Give Codex a Persistent Project Memory

The durable setup is a memory layer outside the session that holds what compaction keeps discarding: architecture, decisions, constraints, and resolved issues. MemoryLake stores them once — searchable, versioned Git-style so you can trace when a decision changed, and end-to-end encrypted so your code and infrastructure details stay yours. Because the knowledge lives outside the window, a smaller context window stops meaning a smaller memory.

Step 1: Create an API key

Sign in to MemoryLake, generate a key, and make your first request — it takes about 30 seconds.

Create a MemoryLake API key
Create a MemoryLake API key

Step 2: Upload your first memories

Drop in the project knowledge sessions keep rediscovering: architecture notes, decision records, API and data-flow docs, and the requirements a long task must not lose — documents, images, and other files all work. When a session settles something worth keeping, capture it as a one-line memory.

Upload your first memories to MemoryLake
Upload your first memories to MemoryLake

Step 3: Connect your AI & agents

Add MemoryLake to Codex via MCP with your API key, so the agent retrieves requirements and past decisions on demand instead of holding them in a window that compacts. The same memory is available to Claude, OpenClaw, and other agents via MCP or the API — one project memory across every tool you code with.

Connect your AI and agents via MCP
Connect your AI and agents via MCP

What Rediscovery and Compaction Actually Cost

The shrinking-window tax

A smaller default window doesn't just truncate earlier — it makes the agent re-read more often to recover what compaction dropped, and every re-read is tokens spent rebuilding known context instead of doing work. On a large codebase, that rediscovery is the most expensive part of the session, and it now happens sooner.

Retrieval instead of re-summarizing

With a persistent layer, Codex pulls the specific decision or requirement a task needs, rather than trying to keep the whole project in a window that can't hold it. Less compaction pressure, fewer mid-task regressions, lower spend — MemoryLake's Token Saving Calculator projects the effect from your usage.

Best Practices for a Codex Project Memory

Put requirements where compaction can't reach them

If a requirement must survive a long task, it belongs in retrievable memory, not only in the prompt or AGENTS.md. That's the difference between an agent that finishes the job and one that regresses at 80%.

Capture decisions at the moment they're made

One dated line — decision, reason, rejected alternative — beats a retrospective cleanup that never happens, and it stops the agent re-proposing what you already ruled out.

Scope by repository

One memory scope per repo keeps retrieval precise and lets each project's Codex sessions pull only what applies to them.

Conclusion

Codex didn't get more forgetful by accident — a smaller default window means compaction arrives sooner, and compaction has always been where requirements and decisions quietly disappear. AGENTS.md can't carry the dynamic knowledge, and restarting sessions just trades context for clarity. Put your project's real memory outside the window, and window size stops determining how much your agent knows. The context can shrink; your memory doesn't have to.

Frequently asked questions

Did OpenAI reduce Codex's context window?

Developers documented a reduction in the default configured input context for GPT-5.6 in Codex — roughly 372k to 272k tokens, about a 27% cut — noticed through a GitHub configuration change rather than an announcement. Practically, it means compaction triggers earlier in long sessions.

Why does Codex forget my AGENTS.md rules mid-task?

Because AGENTS.md is loaded into the same context window everything else competes for. A GitHub issue documents compaction dropping those rules mid-task, with progress reportedly regressing from 97% to 42% once the requirements were lost.

Doesn't AGENTS.md solve project context?

For stable conventions, it helps. But it's hand-maintained, so decisions and resolved issues never reach it — and it can be compacted out of the active window like any other content.

How do I preserve project context across Codex sessions?

Keep it outside the session. With MemoryLake, architecture, decisions, and requirements live in a retrievable layer Codex reads over MCP, so each session starts informed instead of re-exploring your repo. The same pattern is covered in setting up cross-AI memory with MCP.

Will a memory layer slow Codex down?

No — retrieval is on demand and typically faster than re-reading files to rebuild lost context. It also frees window space for the actual task rather than spending it on rediscovery.