Dumb Game Lab

Blog · Behind the scenes

Solo dev token log

I wasted 25% of a day's tokens, and 14.4% went to rewarming the cache

Justin Lee, Dumb Game Lab ·

First line of the October 28 diary entry. It reads tokens 90.6M, waste 22.7M, 25%

On October 28 I was billed for 90.6M tokens, and 22.7M of them (25%) landed in my waste buckets. The biggest bucket was cache rewarming at 13.0M, or 14.4% of the day, which is more than half of all the waste. Two chat sessions I had opened on my phone stayed open all day, and every time I sent one more message, the whole earlier conversation was written to the cache again from scratch.

The daily log first

I make games by running several AI agents all day. At night, when I write my diary, I collect the session logs and sort that day's tokens into buckets. This is what October 28 looked like.

The billed total was 90.6M. That is 33K of input plus 9.6M of output plus 80.9M of cache writes, and cache writes filled almost the whole thing, so the first time I opened this log I assumed I had done the math wrong. Cache writes are 89.4% of it. Cache reads came to 2.61B, but they are priced so low that I keep them out of this total and list them separately.

Waste bucketTokensShare of daily bill
Cache rewarming13.0M14.4%
No merge6.7M7.4%
Idle long sessions2.7M3.0%
Stop hook re-calls0.28M0.3%
Total22.7M25%
The “today's tokens” part of the diary. Billed total, per-model usage, waste buckets, the biggest leak and the reason are each on their own line
The diary's “today's tokens” section. The yellow lines are the waste buckets and why they leaked.

What is cache rewarming?

A chat AI rereads the entire earlier conversation every time you send a message. Prompt caching keeps the part that was already processed for a short while, so the next request can pull it back cheaply.

The catch is how long it is kept. According to Anthropic's documentation, a cache entry lives for 5 minutes by default and the timer resets each time it is used, and you can opt into a 1-hour version. Talk to the model after that window and the whole earlier conversation has to be written to the cache again.

The price gap is large. A cache write costs 1.25x the base input price (5-minute cache) or 2x (1-hour cache), while a cache read costs 0.1x. Writing the same earlier conversation again costs 12.5 to 20 times what reading it would.

How tokens are processedMultiple of base input price
Base input1x
Cache write (5-minute lifetime)1.25x
Cache write (1-hour lifetime)2x
Cache read0.1x
Header comment of the token log code. It says the cacheRewarm bucket holds tokens spent rewriting the whole context to the cache after a break
The rule the log uses to split waste buckets. For a main session that comes back after more than 60 minutes idle, the cache it rewrites is counted here.

The culprit: two phone sessions open all day

My log counts it as “cache rewarming” when a main session sits idle for over an hour, comes back, and rewrites its whole context to the cache. On that day, the bucket grew because of two sessions I had left open on my phone.

One was open for 1,379 minutes and the other for 1,161, and since a day has 1,440 minutes, both windows were opened in the morning and never properly closed until late at night. Nearly the whole day. I dropped a line into them from my phone whenever something came to mind, and each time a cold conversation got warmed up again from the start.

The biggest leak was a bottleneck session that started with “Why did it stop?”. In 160 minutes it spent 4.8M on cache rewarming. That is close to two thirds of the 7.5M this session used that day.

Number one four days running, and promises didn't fix it

Cache rewarming was the top waste bucket four days in a row, starting October 25. I wrote it down in the diary every day and even filed a ticket to fix it. The number still did not come down.

A promise to “keep sessions short” is forgotten the moment I pick up my phone. When I want to hand off something that came to me on the move, adding one more line to the chat I already have open is much easier than opening a new window and explaining everything from the beginning. A rule that depends on human habit keeps leaking in the same spot.

The “today's waste” part of the diary. It says cache rewarming 13.0M, the same bucket for the 4th day since 10-25
“Same bucket for the 4th day since 10-25.” The same sentence showed up in the diary four days running.

Second bucket: no merge, 6.7M

The second biggest waste was no merge at 6.7M (7.4%). This bucket holds sessions that used a lot of tokens yet never got their work into the main code.

A Seoul status session (103 minutes) and a Chichi brawl session (47 minutes) were caught here. The Seoul one handed the work to a sub-agent, replied “in progress”, and ended there. Counting both no merge and cache rewarming, the Seoul status session used 2.4M.

What I changed

The first lesson in that day's diary is that sessions don't get shorter because you tell them to. So I chose a mechanism over another promise. When a session passes a set time limit, it saves a summary of everything so far and hands off to a new session.

The new session starts with one short summary, so there is very little earlier conversation to rewarm. If you are in the same spot, I'd suggest measuring in this order first.

  • Write down each day's tokens split into input, output, cache writes and cache reads.
  • If the cache write share is high, suspect conversations you came back to after a break.
  • Count the minutes your longest-open session has been running.
  • When a session passes a set time, leave a summary and open a fresh one.
  • If the same bucket tops the list several days in a row, stop making promises and add a mechanism.
The “lessons” part of the diary. The sentence saying session length does not shrink by words alone is in bold
The first line of the diary's “lessons”.

FAQ

What is prompt caching?

It keeps the start of a prompt that was already processed for a short time and reuses it on the next request. In Anthropic's documentation the default lifetime is 5 minutes, it is extended each time it is used, and you can choose a 1-hour version instead.

How much does prompt caching cost in Claude?

By the multipliers in the official documentation, a cache write costs 1.25x the base input price (5 minutes) or 2x (1 hour), and a cache read costs 0.1x. Writing the same content again costs 12.5 to 20 times what reading it would.

Why does keeping a Claude Code session open use so many tokens?

If you send a message after the cache lifetime has passed, the whole earlier conversation is written to the cache again. In my case, two phone sessions left open all day sent 13.0M of a 90.6M daily bill out this way.

How do I check my Claude Code token usage?

I gather the Claude Code session log files left on my computer for each day, split them into input, output, cache writes and cache reads, and count waste buckets separately, such as cache writes after a break or sessions that ended with no result. Only once the numbers were broken down by bucket could I see where the leak was. When I only looked at the total, I knew I had used a lot but not why.

More from the blog

New games and small updates, about once a month.

Read inEnglish한국어日本語繁體中文