Codex Architecture Disclosure: MCP's Production Ceiling and the Cache Bug You'll Hit Next
OpenAI published the most honest architecture disclosure we've seen from a major AI lab, and the central finding should change how you plan agent infrastructure: MCP is insufficient for production agentic workflows. They tried MCP for VS Code integration and abandoned it because streaming progress updates, mid-task user approval (server sending requests back to the client), and structured code diffs simply don't map to MCP's request/response model.
The App Server Pattern
The replacement is a bidirectional JSON-RPC protocol over stdio, with backward compatibility baked in. One core binary (agent loop, thread management, tool execution, auth) wraps in this protocol. VS Code and desktop apps launch it as a child process. The web app runs it in a cloud container streaming over HTTP. Third-party IDEs (JetBrains, Xcode) point at the same binary and decouple their release cycles from OpenAI's. This enabled Codex to ship across 5+ surfaces from one codebase.
The hardest engineering problems in Codex were orchestration, not model quality — the agent loop, prompt assembly from 5 sources with role-based priority, and multi-surface delivery.
The Cache Fragility Bug
This is the detail that should trigger immediate action. Codex deliberately chose quadratic data transfer per conversation to preserve statelessness — every turn resends full history. Prefix-based prompt caching keeps actual compute closer to linear. But when they added MCP tool support, a bug where tools weren't listed in consistent order between requests destroyed every cache hit. Non-deterministic JSON key ordering in tool definitions meant full inference cost on every turn — silently.
If you're running multi-turn agent conversations with prompt caching, this is your bug report from the future. Deterministic prompt assembly is a required invariant, not a nice-to-have. Sort tool definitions, fix configuration order, and validate prefix stability with a hash check before each API call.
Context Compaction
When conversations hit the context window limit, Codex replaces full history with a compressed representation including an encrypted payload carrying the model's latent state. This is only possible because OpenAI controls the full model stack. For anyone building on third-party APIs, your compaction is necessarily lossy. Design for short-lived, task-scoped conversations rather than long-running sessions.
What MCP Still Works For
MCP isn't dead — LangGraph, LlamaIndex, CrewAI, and PydanticAI all support it, and LitServe now auto-generates MCP endpoints. For simple tool invocation (fetch data, call an API), MCP is fine. But the moment you need streaming, approval flows, or bidirectional communication, plan for a custom protocol layer. Microsoft's move of Azure DevOps MCP to cloud-only with plans to kill local reinforces that MCP infrastructure is still in flux.
What to do
Audit all MCP integrations for interaction patterns exceeding request/response — streaming, approval flows, bidirectional communication
Add cache hit rate monitoring to any system using LLM prompt caching with multi-turn conversations; alert on sudden drops
Enforce deterministic prompt assembly via sorted tool definitions, fixed config order, and prefix hash validation before each API call
Evaluate the App Server pattern (bidirectional JSON-RPC over stdio) for any developer tool shipping across multiple surfaces