← Back to library

Track input tokens and cache expiry in agent sessions

Roark66, running Claude Code, reports about 1.3 billion input tokens a week against only seven or eight million output, with roughly eighty percent cached. Cloud caches last five minutes or an hour; when they lapse, a large context is billed in full again. He runs models on local GPUs so he can keep caches as long as he likes.

  • OutcomeMeasure how much of your agent spend is reread context, and plan sessions so caches do not expire mid-task.
  • SetupUnder an hour
  • LevelAdvanced
  • CreditRoark66 on Hacker News
View original
Works with
Claude CodeCustom agent

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

When should you use it?

  • Your agent bills keep rising
  • You run many long sessions
  • You are weighing local hardware

Not for: Light occasional use; Teams without usage data

What do you need, and what do you get?

You need

  • Usage logs
  • Session list
  • Price sheet

You get

  • Input versus output breakdown
  • Cache hit rate
  • Session habits to change

How does it work, step by step?

  1. Pull usageExport a week of token counts by session.
  2. Split input and outputCompare how much is reread context.
  3. Check cache hitsFind sessions where long idle gaps forced full rereads.
  4. Adjust habitsClose idle sessions or compact context before breaks.
  5. Price localEstimate whether local inference would pay back.

The prompt

Our own prompt, inspired by Roark66 on Hacker News and written to work in Claude Code and Custom agent. Values in lime are placeholders.

Fill in the blanks (optional; the copied prompt uses your values)

Prompt2 variables
From my usage export {usage_file}, total input and output tokens per session for the past week.
Estimate the cached share and flag sessions where idle gaps longer than {cache_window} likely caused full rereads.
Suggest three habit changes and estimate the savings for each.

Inspired by Roark66 on Hacker News: Comment in JetBrains reports revenue growth, net financial loss for 2025. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.

What can go wrong?

  • Idle gaps longer than the cache window reset costs.
  • Huge contexts magnify every miss.
  • Hardware math must include power and your time.

Our take

Most people watch output length when the money is going to input. Roark66's numbers make the point starkly: the reread context dwarfs what the model writes. You do not need local GPUs to act on this. Look at cache hits per session, notice where a coffee break reset a huge context and triggered a full rebill, and compact or close sessions before stepping away for longer than the cache window. Prefer smaller, focused sessions over one giant context that must be reloaded often. If you run many long sessions every day, pricing a local setup against cloud spend is fair, but count electricity, hardware wear and your own upkeep time honestly. Ask your provider for usage exports that split input, output and cache hits, since the dashboard summary alone can hide the pattern. Merging, deploying and deleting stay with a person regardless of where the model runs. A five-minute cache means even a short walk can erase savings.

Where the time goes back: You find the expensive habits in your agent use before they hit the bill.

FAQ

Why does input dominate?
Agents reread the whole context on every turn.
Why local?
He can keep caches indefinitely and save them to disk.

Source and credit

Inspired by Roark66 on Hacker News. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.

Inspired by
Comment in JetBrains reports revenue growth, net financial loss for 2025
Creator
Roark66 on Hacker News
Published on
Hacker News
Original date
Oct 7, 2026
License
Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
Originally for
Custom agent
AI dry run
Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends, bookings or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails.
Verified
Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.

Are you the creator? Claim or correct this page.

More in IT & Security

All 82 IT & Security playbooks →

Related playbooks

IT & SecurityWorkflow✓ AI dry run

Get consent first, then audit with a second agent

Have a different coding agent review your work in an isolated copy with editing turned off, and require it to ask before using any account or login.

Credit: u/Bulldagshunter on r/ClaudeCode

Under an hour
IT & SecurityWorkflow✓ AI dry run

Turn a public advisory into a tested exploit in a lab

See how fast an agent can go from a patched vulnerability to a working proof of concept inside an isolated lab, so you can judge real patch urgency.

Credit: Kev Breen

An afternoon+
IT & SecurityWorkflow✓ AI dry run

Clean up after coding agent sessions

Wrap every agent run in a process group that gets killed when the task ends, and clear old temp files on a schedule.

Credit: _matthew_ on Hacker News

Under an hour