If you use Claude Code, Codex, or similar terminal coding agents all day, you eventually run into the same annoying tradeoff with session length.

Keep one conversation running all afternoon and it gets sluggish and expensive. The context fills up with old tool output, half-abandoned debugging branches, and files you stopped caring about an hour ago. Worse, if you step away for lunch or a meeting and the provider's prompt cache expires, the very next message pays to re-write that whole history from scratch.

So the obvious reaction is to start a fresh session for every single task. That fixes cache-write spikes, until you realize the agent is burning tokens re-reading the same five files just to make a ten-line follow-up edit you literally just discussed two minutes ago.

Neither extreme is great. What actually worked for me was treating "continue warm" vs. "start fresh" as a per-step decision instead of a global habit.

The simple rule of thumb

Before sending a follow-up in an existing session, I look at three things:

  • Is the prompt cache still warm? If the last turn finished a couple of minutes ago and we are still inside the cache TTL window, continuing is cheap because the prefix hits cache instead of full input pricing. If the session has been sitting idle for ten or fifteen minutes, that advantage is already gone.
  • Are we still touching the same files? Tightly coupled follow-ups ("fix the failing test you just added", "rename that helper and update the two callers") benefit a lot from warm context. Pivoting to a new feature or a separate bug does not.
  • Has the session gone through a messy debugging detour? Even if the cache is warm, thirty turns of failed stack traces and dead-end hypotheses pollute the model's attention. Starting clean usually produces better code on the next step anyway.

Make fresh starts cheap with a tiny handoff note

The reason people hesitate to start fresh is the fear of re-explaining everything. In practice, the next agent rarely needs the whole transcript. It needs about ten lines:

  • What changed so far (or the current branch/diff)
  • Which 2–4 files actually matter
  • Any non-obvious constraint or decision already settled
  • The concrete next step

Keeping that note as plain Markdown in the project folder has a nice side effect: you are not locked into one agent. You can let one model do the fast implementation pass, write out a short summary of what changed, and hand the fresh review pass to a completely different model without copy-pasting terminal logs back and forth.

Putting it into practice

Even if you do this manually, just pausing before hitting Enter on a stale terminal tab saves a surprising amount of money and keeps outputs sharper.

I work on PenEcho (open source, plain local Markdown), where we wired this fresh-vs-warm check directly into each job alongside a per-job cost view and one-click handoffs between Claude Code, Codex, and other local agents. In our own daily runs it cut roughly a fifth off token spend compared to blindly keeping every session going, mostly just by avoiding idle cache rebuilds and letting fresh runs start from a tight handoff.

The underlying trick does not need a special tool, though. Watch the idle timer, reset after messy debug loops, and keep your handoffs short enough to read in ten seconds.