> Agent-ready spec from Diff of the Day (2026-12-02, idea 1). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Prompt-cache pause bill

## Problem Statement
A coding agent pays full price to rebuild its prompt cache when you pause longer than the cache lifetime. Requesty reports this took 23.1% of one provider's bills in its customer traffic. Most engineers never measure the share on their own work, so they cannot tell if a keep-alive ping or a longer cache would save money.

## Goals
- Report the share of one week of spend that went to cache rebuilds after pauses.
- Split that share by pause length: 5 to 30 minutes and over 30 minutes.
- Estimate the saving of a keep-alive ping and of a 1-hour cache on the same week, within 2 percentage points of a replay.
- Run on a week of logs in under 1 minute.

## Non-Goals
- Sending live keep-alive pings: the first version only replays logs, because a live ping costs money and needs its own safety checks.
- Support for every agent: one log format is enough to test the idea.
- A web dashboard: a printed report is enough for one evening.

## User Stories
- As an engineer on a metered plan, I want to see how much I pay for pauses so that I can decide whether to change my cache setting.
- As a team lead, I want the same report for several people so that I can compare habits without reading prompts.
- Edge case: as an engineer, I want a session with no usage data in some turns to be counted and listed as skipped, so that missing data does not change the totals without a warning.

## Requirements
### P0
- A parser that reads agent session logs and outputs one row per turn: session id, time, input tokens, cache read tokens, cache write tokens, model.
  - [ ] Rows contain counts only and no prompt text.
  - [ ] Turns with missing counts are listed as skipped with the reason.
- A pause-miss detector: a turn that follows a gap over 5 minutes and reads under 10% of the previous prompt from cache.
  - [ ] The 5 minute and 10% limits are options with these defaults.
  - [ ] A unit test covers a gap of exactly 5 minutes.
- A price table in a config file and a report of the share of spend caused by misses.
  - [ ] Prices come from the config file and not from code.
  - [ ] The report shows totals and the split by pause length.

### P1
- A replay that applies a keep-alive ping every 4 minutes and a 1-hour cache write price to the same week.
  - [ ] The report shows the saving in money and percent.
  - [ ] The report states the assumptions used.

### P2
- A per-model breakdown.
  - [ ] Each model has its own miss share and price.

## Success Metrics
- Share of spend caused by pause misses, per week.
- Estimated saving of each option against the real bill.
- Run time on one week of logs.

## Open Questions
- Which log format does your agent write, and does it contain cache read and write counts?
- Is a ping cheaper than a rebuild once you count the ping tokens?
- Does your plan bill by token or by time window?

## Timeline
One evening: parser and miss detector first, price report second, replay if time remains.

## Agent Instructions
- Suggested stack: Python or TypeScript, a CSV or JSONL reader, no network access.
- Build order: Parser, row format, miss detector, price config, report, replay.
- Safety: Read logs only and never write to them; drop prompt text at parse time; do not call any model API; do not print file paths that contain private names.
- Done when: The report for one real week prints the miss share, the split by pause length and the two replay savings, and the unit tests pass.

## Sources
- https://www.requesty.ai/blog/claude-5-minute-prompt-cache
- https://x.com/lydiahallie/status/2127937350835806672
