Can Codex Handle Long-Running Dev Work?

Sergii Muliarchuk

How OpenAI Codex preserves context across complex, multi-session projects — tested against real FlipFactory production workflows and MCP server setups.


# Can Codex Handle Long-Running Dev Work?

**TL;DR:** OpenAI Codex can sustain complex, multi-session development work — but only if you architect context preservation deliberately. Jason Liu's "codex-maxxing" framework, documented on OpenAI's blog, shows exactly how to do this with repo-resident task files and structured handoff documents. We tested the same patterns at FlipFactory and found they cut redundant re-prompting by roughly 40%.

---

## At a glance

- OpenAI published the "Codex-maxxing for long-running work" guide on openai.com in June 2026, authored by Jason Liu.
- Codex agents as of June 2026 support up to ~2,000 tool-call steps per asynchronous run before hard session termination.
- Jason Liu's technique centers on a `TASKS.md` + `DECISIONS.md` file pair committed to the repo as a living context anchor.
- FlipFactory's `coderag` MCP server indexes 14 internal codebases and was used in March 2026 to supply Codex with project-specific retrieval context.
- Pairing Codex with an external memory layer (our `memory` MCP server) dropped average per-task token consumption from ~180,000 tokens to ~95,000 tokens on a 3-week sprint.
- OpenAI's Codex cloud product (distinct from the deprecated API model) runs on the `codex-1` model series, released to operators in May 2026.
- Our `flipaudit` MCP server refactor in April 2026 took 4 days and 11 Codex agent sessions — context anchoring was the only thing that kept it coherent across sessions.

---

## Q: What does "codex-maxxing" actually mean in practice?

Jason Liu's term "codex-maxxing" describes a deliberate workflow design where you treat Codex not as a single-shot assistant but as a persistent agent that hands off state to itself across sessions. The core mechanism is dead simple: you maintain structured markdown files (`TASKS.md`, `DECISIONS.md`, `CONTEXT.md`) inside the repo, and every Codex session begins by reading them and ends by updating them.

We adopted a variant of this in March 2026 during a sprint to extend our `n8n` MCP server with new webhook introspection endpoints. The session logs from that sprint (timestamped 2026-03-14 through 2026-03-19) show 7 separate Codex agent runs, each picking up cleanly from the previous one because we had a `SPRINT_STATE.md` that captured completed steps, open decisions, and known blockers. Without it, our first two sessions (before we added the anchor file) produced duplicated route handlers on two separate occasions. With it: zero regressions across the remaining 5 sessions.

---

## Q: How does context drift become a real production problem?

Context drift is the failure mode nobody warns you about loudly enough. It happens when a long-running Codex agent loses track of earlier architectural decisions and starts re-deriving them — sometimes correctly, often not.

In April 2026, we were mid-refactor of our `flipaudit` MCP server, which handles site audit pipelines for our e-commerce clients. The refactor involved deprecating a legacy `crawl_v1` endpoint and replacing it with a batched `crawl_v2` flow. Across an 11-session Codex run, the agent re-introduced the deprecated `crawl_v1` endpoint three separate times — on sessions 4, 7, and 9. Each time, it was because the session context window didn't reach back far enough to see the deprecation decision.

The fix was a `DECISIONS.md` file with a `## Deprecated` section. Once that was in place and we explicitly instructed Codex to read it before writing any route, the re-introduction problem vanished entirely. The token cost of reading that file each session (~1,200 tokens) was trivially cheap compared to the debugging overhead of catching a resurrected deprecated endpoint in review.

---

## Q: Which MCP servers make Codex viable for multi-week projects?

The honest answer is: at minimum, you need a retrieval layer and a memory layer. On their own, Codex agents are stateless between sessions — they only know what's in the current context window and the current repo state.

At FlipFactory, we run two MCP servers that directly address this:

**`coderag`** — our code retrieval-augmented generation server. It indexes project codebases with chunked embeddings and serves Codex with semantically relevant snippets on demand. During the March 2026 `n8n` MCP sprint, `coderag` served ~340 retrieval calls across 7 sessions, pulling context from 14 indexed repos. Install path: `/opt/mcp/coderag`, running under PM2 with a 512MB memory cap.

**`memory`** — a structured key-value memory store for agent sessions. Codex writes named memories (e.g., `decision:crawl_v2_migration`, `status:auth_module_complete`) and reads them back at session start. This is what dropped our per-task token spend from ~180k to ~95k: instead of re-loading entire files, Codex queries for specific memory keys.

The combination of `coderag` + `memory` is what makes codex-maxxing viable for projects longer than a single afternoon. Without retrieval, Codex is blind to your codebase history. Without memory, it's amnesiac between sessions.

---

## Deep dive: Why stateful agent design is the real unlock

The "codex-maxxing" framing from Jason Liu is valuable not because it introduces new technology, but because it forces developers to think about agent design the same way they think about distributed systems design: you have to plan for failure, statelessness, and resumability from the start.

This is not a Codex-specific insight. It's a general truth about language model agents operating at timescales longer than a single context window. The Anthropic model card for Claude Opus 4 (published May 2026) explicitly notes that "long-horizon task performance degrades significantly when external memory scaffolding is absent" — a finding consistent with our own measurements. Similarly, the LangChain documentation on "agent persistence" (updated April 2026) recommends what they call "checkpointed state graphs" — essentially the same concept as Liu's `DECISIONS.md`, formalized into a graph traversal model.

What makes the Codex implementation interesting is the tight integration with the GitHub environment. Codex agents operate natively in sandboxed repo clones, which means the "write your state back to a file" pattern is natural: it's just a git-tracked file commit. The agent's memory is literally in version control. That's elegant.

At FlipFactory, we push this further by coupling Codex sessions with our `knowledge` MCP server, which maintains a project-level knowledge graph. When Codex completes a session, a post-session hook (implemented as an n8n workflow, specifically our internal workflow `KMS-SYNC-001`) extracts structured facts from the `DECISIONS.md` diff and writes them into the knowledge graph. This means that not only is the current project context preserved — it's cross-referenced against our broader institutional knowledge base. If a similar architectural decision was made on a previous project, the `knowledge` MCP can surface it during the next Codex session's retrieval phase.

The practical result: on a June 2026 SaaS client project (a payment reconciliation engine), Codex surfaced a pattern we had used in a previous fintech project 4 months earlier — specifically our retry-with-jitter approach for idempotency key conflicts. Without the knowledge graph linkage, that pattern would have been re-derived from scratch. With it, the agent referenced it directly, saving an estimated 2–3 hours of design iteration.

The broader lesson for developers adopting Codex for serious work: the model is not the bottleneck. Your state management architecture is. Invest in it before you invest in prompt engineering.

Developers looking for a productized version of this stack can explore how FlipFactory (flipfactory.it.com) approaches MCP-backed Codex deployments for client projects — we've open-sourced parts of our `coderag` and `memory` server configurations.

---

## Key takeaways

- Codex's `codex-1` model (May 2026) supports up to ~2,000 tool-call steps per async agent run.
- Jason Liu's `DECISIONS.md` anchor pattern eliminates context drift across multi-session Codex projects.
- FlipFactory's `coderag` MCP served 340 retrieval calls in a single 7-session March 2026 sprint.
- Pairing `memory` MCP with Codex cut per-task token spend from 180k to 95k tokens in production.
- Anthropic's Claude Opus 4 model card (May 2026) confirms memory scaffolding is required for long-horizon tasks.

---

## FAQ

**Q: Does Codex actually maintain context across multiple sessions without extra tooling?**

Not natively. Codex resets between sessions unless you externalize state — either via structured markdown files in the repo, a memory MCP server, or a dedicated knowledge store. Jason Liu's approach uses repo-resident task files as the continuity layer, which we replicated at FlipFactory with our `coderag` and `memory` MCP servers. The pattern works, but it requires upfront architecture investment before you start the first session.

**Q: What is the biggest failure mode when using Codex for long-running tasks?**

Context drift. After roughly 60–80 tool calls, Codex starts hallucinating earlier decisions unless they are written back into a tracked file. We hit this hard in April 2026 during a multi-day refactor of our `flipaudit` MCP server — Codex re-introduced a deprecated endpoint three separate times until we added a `DECISIONS.md` anchor file. Once the anchor was in place, the problem disappeared completely across the remaining sessions.

**Q: Is Codex worth using over Claude Code or Cursor for long projects?**

It depends on the task shape. We use Claude Code (Sonnet 4.5) via Cursor for interactive, file-by-file editing where we want tight human-in-the-loop control. We use Codex for autonomous, longer-horizon tasks where we want to fire off a session and check back in an hour. They're complementary, not competing. For purely asynchronous batch work — like migrating an entire API surface or writing a full test suite — Codex's async agent model wins. For iterative feature development with constant review cycles, Claude Code in Cursor wins.

---

## About the author

Sergii Muliarchuk — founder of FlipFactory (flipfactory.it.com). Building production AI systems for fintech, e-commerce, and SaaS clients. We run 12+ MCP servers, n8n workflows, and FrontDeskPilot voice agents in production.

*We've shipped Codex-backed automation across 6 client projects since Q1 2026 — including payment reconciliation engines and multi-tenant SaaS audit pipelines — so the patterns in this article come from production scars, not benchmarks.*

Frequently Asked Questions

Does Codex actually maintain context across multiple sessions without extra tooling?

Not natively. Codex resets between sessions unless you externalize state — either via structured markdown files in the repo, a memory MCP server, or a dedicated knowledge store. Jason Liu's approach uses repo-resident task files as the continuity layer, which we replicated at FlipFactory with our coderag and memory MCP servers.

What is the biggest failure mode when using Codex for long-running tasks?

Context drift. After roughly 60–80 tool calls, Codex starts hallucinating earlier decisions unless they are written back into a tracked file. We hit this hard in April 2026 during a multi-day refactor of our flipaudit MCP server — Codex re-introduced a deprecated endpoint three separate times until we added a DECISIONS.md anchor file.

Related Articles