Detailed Analysis
A Reddit thread in r/ClaudeAI surfaces a technical question that has been circulating among developers building agentic coding tools: why does OpenAI's Codex appear to use tokens more efficiently than Claude Code during extended agentic sessions, and what role do differing caching strategies play in that gap? The original poster, working on agentic software generation workflows, observed the discrepancy empirically but did not have a clear technical reference explaining the underlying mechanics—prompting a call for documentation or community expertise on how each tool manages prompt and context caching.
The distinction matters because prompt caching is one of the primary levers available for controlling cost and latency in agentic coding tools, which routinely re-send large amounts of context—file contents, tool definitions, conversation history, system prompts—on every turn of a multi-step task. Anthropic's API-level prompt caching allows developers to mark stable prefixes of a prompt (like system instructions or large codebase excerpts) so that repeated calls reuse cached computation rather than reprocessing everything from scratch, cutting both cost and time-to-first-token substantially. However, how a caching mechanism is exposed and orchestrated at the API level differs meaningfully from how an agent harness like Claude Code or Codex actually structures its calls, decides what to keep in the cache window, and manages cache invalidation as context mutates turn over turn. If Claude Code restructures or appends to context in ways that break cache prefixes more frequently than Codex does—for instance, through more aggressive tool-output injection, different summarization/compaction strategies, or less deterministic ordering of context blocks—it would show up exactly as the poster describes: higher effective token consumption per task despite comparable underlying model capability.
This kind of comparison reflects a broader trend in the agentic AI space where the coding agent "harness"—the orchestration layer that decides what to send the model, when to compact history, and how to leverage caching—has become as consequential to real-world performance and cost as the underlying LLM itself. As agentic workflows scale to longer-running, more autonomous tasks (multi-file refactors, iterative test-and-fix loops, long research-and-build sessions), the efficiency of context management determines whether these tools are economically viable for everyday use or prohibitively expensive at scale. Anthropic, OpenAI, and other labs are competing not just on model quality but on the sophistication of their tooling around context windows, caching, and compaction—areas that are often under-documented publicly, which is why practitioners are left comparing notes on forums like Reddit rather than referencing official architecture docs.
The lack of an authoritative, easily discoverable reference on this topic—evident from the thread's request for pointers—also highlights a documentation gap in the fast-moving agentic coding space. Both Anthropic and OpenAI publish some guidance on prompt caching at the API level, but the specific implementation choices inside their flagship coding agents (Claude Code and Codex CLI/IDE integrations) are less transparent, since those are proprietary orchestration layers built on top of the public APIs. As more developers build their own agentic systems on top of Claude or GPT models, demand for clearer technical documentation on caching, context compaction, and token-efficiency best practices is likely to grow, and could become a differentiator in developer adoption alongside raw model benchmarks.
Read original article →