Coding Agent Cost: Why Sessions Get Expensive
Keep the project on disk, treat lunch as a bill, and score the first finished tasks rather than dollars per million tokens

- API models are stateless, so every turn re-sends the whole thread: a one-word "hi" after a 1 million token session bills as 1 million input tokens, $1 at the teaching rate of $1 per 1M, and $5 on Opus 5 when the stored copy is gone versus $0.50 on a hit.
- The default cache lifetime is 5 minutes, so coming back from lunch re-bills the entire prefix at full input price (200,000 uncached Opus 5 tokens cost $1.00 versus $0.10 on a hit), while holding the copy costs 1.25x base input for 5 minutes and 2x for 1 hour.
- Cache-hit discounts are provider-specific: Anthropic 0.1x, the OpenRouter agent blend about 1/5, Grok 4.6 at 0.25x, DeepSeek V4-Flash off-peak about 0.03x, and a16z puts more than 85% of agentic OpenRouter tokens on cached prompt (OpenRouter's head of insights: about 70% of July sessions).
- Cheap list price lies twice: one mid-session model switch cost 5.1x to 11.1x a warm turn because prompt cache is model-specific, and the fair scoreboard is the first two or three finished tasks, not Artificial Analysis's $0.84 per Intelligence Index task for Grok 4.6 that drifted to $0.94 (about 12%) in six days.
- Claude Code and Codex compact around 200,000 to 300,000 tokens, not the advertised 1 million, so the project has to live on disk as a byte-stable prefix (
ARCHITECTURE.md, skills, a stable system prompt), because aCLAUDE.mdthat injectsgit statusor a clock is a miss engine.
You left a long coding-agent thread over lunch.
Then the stored copy of that history is already gone which was cheap, so the first message you send when you come back re-sends every prior turn at full input price, which is why you run coding work as session, task, and project, and why walking away is a bill.
The models you call via API are stateless and do not keep the conversation in memory between calls, so every turn re-sends the whole thread, and a one-token tool result still pays that whole history.
Arena AI's recent lecture "The Real Cost of Agentic AI: Tokens, Caching & Context Costs Explained" is the 26-minute walkthrough of that bill.
It walks through:
- Why the model re-sends the whole thread every turn,
- Why the bill still grows even when most of that thread is stored cheaply (cached),
- Why walking away can make one message cost more than the afternoon (cache-miss),
- How coding apps shorten the thread when it gets huge (compaction),
- Why the first finished jobs beat dollars per million tokens.
The worked example is a one-word "hi" after a 1 million token session. So if the model costs $1 per 1M input tokens, that "hi" is priced at $1.
Opus 5 bills that same input million at $5 when the stored copy is gone, and $0.50 when the provider still has it, on Anthropic's pricing page.
Pin the model and the provider so that stored copy stays cheap to re-read, because the project does not live in the thread.
What follows is the session lifetime and the lunch bill, how to score a finished task, where the project lives, four cache prices, and how to mix cheap models without paying twice.
What happens when you leave a long agent session
Coming back after the cheap stored copy dies bills the whole prefix at full input price. The session is scratch paper with a lifetime, so pin the model and the provider.
Providers store a cheap copy of the prefix, the start of the prompt that is everything already in the thread, for a short window.
A hit is a later turn that still finds that copy. A miss is a later turn that does not find it, so you pay the full input price to send the whole history again.
If you pinned Opus 5 on Anthropic in the morning and started a failing test, then left for lunch, the default 5-minute cache is already dead when you sit back down.

Why a cache miss can cost more than an afternoon of hits
Miss spikes can beat the rest of an afternoon of cheap hits. Those dollars are arithmetic on Anthropic's pricing page, not a session I sat through.
On that page, 200,000 uncached Opus 5 input tokens are $1.00 and a hit is $0.10. One million uncached is $5.00, and a hit is $0.50.
By default, Anthropic keeps the cache for five minutes and drops it if you do not use it. Storing a copy with a 5-minute life costs 1.25x the base input price, and a 1-hour life costs 2x.
I ran these tests in Model Routing Layers and the Prompt Cache Tax: 12-turn coding sessions through OpenRouter on the same synthetic prefix, and the cache died mid-run.
Grok 4.5 (not 4.6), at a 30,000-token prefix, paid a full-price re-read twice (turns 2 and 10) after the 5-minute cache expired, which is shorter than lunch. The expensive turn is the first one after you walk back in.
Don't miss what's next in AI
Join 300,000+ engineers and researchers who get the signal, not the noise. Create a free account to read the rest of this story.
- Full access to in-depth AI research breakdowns
- Be the first to know what's trending before it hits mainstream
- Daily curated papers, repos, and industry moves