The direct answer: coding-agent loops structurally use more requests, context, and output than a single model answer. Prompt caching can sharply discount repeated prefixes, but it does not erase context-window occupancy or make history free. There is no source-backed universal Codex multiplier, no documented “five recently edited files / 50K tokens” rule, and no controlled evidence that OpenCode is always more efficient.
Prompt caching is reusable prefix computation
Prompt caching reuses the provider-side computation for an exact prompt prefix: stable instructions, tool definitions, examples, files, and earlier turns placed before changing content. The model still generates a new answer.
It is not:
- response caching, which returns a previously saved answer;
- memory, which stores selected facts across sessions;
- RAG, which retrieves documents for the current request;
- context compaction, which replaces older history with a summary; or
- a local package, container, or build cache.
OpenAI enables automatic caching on eligible prompts of at least 1,024 tokens. Exact prefix order matters: put stable material first and changing task data last. A stateful Responses chain can simplify request construction, but OpenAI still bills previous input in the chain as input. Eligible reuse may receive a cache discount; statefulness alone does not make it free.
Seven numbers that should not be mixed
| Measure | What it answers | What it does not prove |
|---|---|---|
| Total input tokens | How much input crossed model context across requests | How much was recomputed at full price |
| Cached reads | How much repeated prefix used an existing cache entry | That those tokens left the context window |
| Cache writes | How much prefix was stored for possible later reuse | That a later request actually hit it |
| Output and reasoning | How much new model work was generated | Whether the result was accepted |
| Context occupancy | How full the current model window is | API cost or subscription quota |
| API billing | Dollar cost under model, cache, tier, and long-context rules | ChatGPT/Codex plan consumption |
| Subscription quota or credits | Product-specific allowance consumed | A portable API token price |
Why agent loops multiply work
A coding harness repeatedly asks a model to inspect, decide, act, and verify. A model response, client-managed tool result, retry, compaction recovery, or subagent turn can add another model request and another growing prefix. A provider-managed loop can be different: OpenAI’s Responses API can execute several built-in or custom tool calls within one client request.
Either way, more loop steps mean more model work. Codex’s current documentation explicitly says subagent workflows consume more tokens than comparable single-agent runs because each subagent performs its own model and tool work. That supports the structural claim—not universal figures such as “3–5×,” “8–12 calls,” or “40–80% waste.”
The widely repeated 40–80% number points the other way. OpenAI says Responses produced a 40–80% improvement in cache utilization versus Chat Completions in internal tests. It is not a measured Codex inflation rate.
Caching and compaction solve different problems
Caching discounts a repeated prefix while leaving it in the request and context. Compaction replaces older history with a shorter representation so the conversation can continue within its window.
Compaction can be beneficial and still have a cost. If its summary drops the exact file already inspected, the failed hypothesis, a test result, or the next edit, the agent may rediscover that information. The new compacted prefix may also need a new cache write before later turns can reuse it.
This is a failure mode to measure, not a universal diagnosis. A closed Codex v0.118 report initially blamed a lower compaction threshold; the reporter’s controlled test reversed that claim, and the issue was closed as not a bug. A separate July 24 Desktop report remains open and describes repeated compaction and rereads in one session. It has no maintainer-confirmed root cause.
OpenAI and Anthropic price caches differently
OpenAI prompt caching is automatic for eligible exact prefixes. For GPT-5.6 and later families, the API also supports explicit breakpoints with a current 30-minute minimum TTL. Cache writes are reported separately and billed at 1.25× uncached input; cached reads use the model’s cached-input rate. Cached tokens still count toward OpenAI token-per-minute limits.
Anthropic prompt caching offers automatic caching or explicit breakpoints. Its standard five-minute write costs 1.25× base input, the one-hour write costs 2×, and reads cost 0.1×. For most current Claude models, cache reads do not count toward input-token rate limits; exceptions exist, so check the model-specific rule.
Worked example: traffic is not billed cost
Assume four GPT-5.6 Terra tool turns. Each sends an unchanged 8,000-token prefix, 1,000 changing tokens, and produces 500 output tokens. Use the current standard Terra rates: $2.50/M uncached input, $0.25/M cached read, $15/M output, and a derived $3.125/M cache write.
| Portion | Raw traffic | Billing treatment | Cost |
|---|---|---|---|
| First stable prefix | 8,000 | Cache write | $0.0250 |
| Four changing inputs | 4,000 | Uncached input | $0.0100 |
| Three reused prefixes | 24,000 | Cached read | $0.0060 |
| Four outputs | 2,000 | Output | $0.0300 |
| Total | 38,000 tokens | Mixed | $0.0710 |
Without caching, the 36,000 input tokens would cost $0.0900; with the same output, total cost would be $0.1200. The raw traffic and context are unchanged, but only 12,000 input tokens are newly processed across the sequence. This simplified example excludes long-context, Batch, Priority, and data-residency modifiers—and it assumes all three later prefixes hit.
Reduce cost without starving the agent
- Keep project instructions concise, scoped, and stable.
- Put stable instructions, tools, and examples before changing task content.
- Search first; read targeted ranges instead of dumping whole repositories.
- Bound logs, test output, and MCP responses.
- Expose only the tools and MCP schemas needed for the task.
- Set retry, subagent, time, and token budgets explicitly.
- Compact at natural phase boundaries with decisions, evidence, diff state, and the exact next action.
- Stop when acceptance criteria pass—or when the next step requires user authority.
Codex versus OpenCode: run the same test
Do not compare Codex on GPT-5.6 Sol with OpenCode on a cheaper model and call the result harness efficiency. Use this card for several representative tasks:
| |
Hold model, provider, commit, prompt, tools, effort, timeout, and acceptance criteria constant. Report distributions and failure notes, not a permanent winner.
Frequently asked questions
What is prompt caching?
It reuses provider-side computation for an exact prompt prefix. It is not response caching, memory, RAG, or a local dependency cache.
Do cached tokens still cost money?
Usually yes. A cache hit discounts eligible repeated input under provider-specific rules; it does not make the whole conversation free.
Do cached tokens count toward the context window?
Yes. Caching changes serving and billing, not the amount of context the model attends to.
What does compaction do?
It replaces older history with a shorter summary. Missing execution detail can lead to cache reconstruction or targeted rereads.
Why do coding agents reread files?
Possible causes include compaction, omitted or truncated tool output, weak state preservation, and poor search strategy. A reread is behavior to measure, not proof of one universal defect.
Is OpenCode more token-efficient than Codex?
Not proven. Run the same model, provider, commit, prompt, tools, effort, timeout, and acceptance test, then compare cost per accepted result.
Did OpenAI reset Codex usage to compensate for caching defects?
No first-party evidence currently links the community-observed July 25 reset to prompt caching, compaction, or compensation.
Related links
- /verify/codex-claims/
- /posts/codex-banked-resets-gpt-5-6-preview/
- /compare/pi-vs-zcode-vs-opencode/
- /tools/codex/
- /tools/opencode/
- /coding-tools/
Sources and archive state
- OpenAI: Prompt caching (Archive) —
validated - OpenAI: GPT-5.6 Terra pricing (Archive) —
validated - OpenAI: Responses migration benefits (Archive) —
validated - Anthropic: Prompt caching (Archive) —
validated - OpenAI Status: Codex usage limits depleting faster than expected (Archive) —
validated - OpenAI Codex issues: #16812 (Archive) and #35226 (Archive) — dated reports;
validated
Last verified: July 26, 2026. Cache prices, TTLs, product quota rules, and issue states can change independently.