Skip to content

Claude Code long session tokens: the cost of leaving a chat open

Every request carries the history, so an old session costs more than a new one even when the work is identical.

3 min read

The most expensive Claude Code session is rarely the one with the hardest problem. It is the one left open all afternoon, answering a short question with a conversation that has grown to fill the window. Claude Code long session tokens work that way: each request carries the whole history, so cost rises with the age of the session as much as with the work inside it.

Why an idle session keeps spending

Anthropic's cost guidance lists the causes, and most are easy to miss:

  • a cache miss after a break longer than the cache lifetime, which reprocesses the full context
  • a scheduled task or /loop that fires while you are away, sending the context each time
  • a goal check-in that asks Claude to look at background work
  • subagents and agent teams, each with its own window
  • compaction, which reads the conversation in order to summarise it

None of those need you to type anything.

Signals worth acting on

Signal What it suggests First move
Context percentage climbs with no new files The session has drifted /context, then compact or clear
Cache hit ratio falls Long gaps or changed tools Start fresh for the next task
Wall clock far exceeds the work Idle turns are running Check /tasks and scheduled loops
One day dominates the weekly bar A single session ran long /usage, 7 day view, compare
Output tokens rise with every reply A verbose loop or repeated retries Stop and narrow the prompt

A three-minute check

Run /context and note the percentage and the largest category. Run /usage and switch to the 7 day view. Compare today with the same weekday last week. If today is far ahead, look for a session that never closed, a loop still firing, or a subagent left running.

One number is easy to misread: the token count beside the spinner measures only the current turn's output. It falls back to zero at the start of each turn, so it says nothing about how heavy the session has become.

Cap the damage without losing work

  • Rename the session before you leave it, then /clear. /resume brings it back.
  • Compact with the decisions you need rather than letting the automatic pass guess.
  • Lower effort or move routine edits to a smaller model. Anthropic notes that both change how quickly a plan is consumed.
  • Send log reading to a subagent so the bulk stays out of the main window.
  • Turn off loops you no longer need, and stop teammates when their task ends.
  • Set an alert at a threshold that leaves time to act.

The habit that pays

Treat a session like a desk: clear it when the task changes, not when it fills. The saving is not only money. A shorter context is easier for the model to use well, which is the point behind Anthropic's warning about context rot.

Watching it over weeks

UsageAtlas gives the long view: daily tokens, models, requests, estimated cost, supported limits and reset times for Claude Code and the other coding tools it covers. It is a free and open source desktop app, and local tracking needs no account. It can alert once per reset cycle when a window passes the threshold you set. Prompts and responses are not read, and every dollar figure is an estimate rather than a bill.

The live commands still do the close work. /context for this session, /usage for this account, and a tracker for the pattern across a month. Each answers a different question, and a runaway usually shows up in all three.

FAQ

Does closing the terminal stop the work?

Not always. A background session, an agent team or a cloud scheduled task can keep running after the window is gone. Check /tasks and the agent list before assuming the meter stopped.

Why does a short question cost so much?

Because the request includes the conversation, not just the question. After a long enough break the cache is cold, and the full history is processed again.

Which number should I trust for cost?

None of them as a bill. /usage computes an estimate at list price, and a subscription is an allowance rather than a charge. Use the figures to compare days, not to predict an invoice.

FAQ

Does an idle session keep costing tokens?

Not while it is idle. Cost lands on each request, and an old session makes every later request larger because the history travels with it.

Does clearing a session lose my work?

No. /clear empties the conversation, not the files. Commits and edits stay where they are, and a summary can be written first if the reasoning matters.

How do I notice a runaway session early?

Watch the context figure in the status line or run /context, and keep an eye on the tokens per request that a local tracker such as UsageAtlas records.

Originally published on claudegpt.si