The Agentic Loop Tax: Why Claude Code Sessions Get Expensive
There's a structural reason Claude Code sessions get expensive fast. It's not a bug. It's just how stateless APIs work when they're used in an agentic loop.
What happens on every tool call
When Claude Code reads a file, edits a line, or runs a grep, it makes an API call to Claude. That call includes:
- The full system prompt
- The entire conversation so far (every message, every tool result)
- The new tool call
Because Claude's API is stateless — it has no persistent memory between calls — every single request must include this complete history to give the model context.
Why the cost multiplies
Imagine your conversation history is 5,000 tokens at the start of a task. Claude reads three files, each adding ~2,000 tokens of file content to the context:
| Call | History sent | |---|---| | Read file 1 | ~7,000 tokens | | Read file 2 | ~9,000 tokens | | Read file 3 | ~11,000 tokens | | Edit file 1 | ~13,000 tokens | | Edit file 2 | ~15,000 tokens | | Verify file 1 | ~17,000 tokens |
You don't pay for 5,000 tokens six times. You pay for 7k + 9k + 11k + 13k + 15k + 17k = 72,000 tokens for what felt like one task. And that's before Claude notices something is wrong and starts a correction loop.
This is the agentic loop tax.
It compounds with complexity
Simple tasks stay cheap. But the tax gets brutal on:
- Multi-file refactors — every file read inflates the context for every subsequent call
- Long debugging sessions — each hypothesis, tool call, and result adds to the pile
- Iterative generation — write code, run it, read the error, fix it, repeat
For complex tasks, it's not unusual to pay 10–15× what you'd expect based on the code volume alone.
The only real fix
You can't make Claude's API stateful. But you can reduce the number of calls.
Instead of reading ten files with ten Read() calls, read them all with one brozi_smart_search call. Instead of three Edit() calls plus verification reads, batch everything into one brozi_batch_edit call.
Fewer calls → less history re-sent → lower bill.
Ready to cut your Claude bill?
Install BroziCode in 2 minutes — free, open source, MIT licensed.