Skip to content

Context size and token cost: why long coding sessions cost more than short ones

Models are billed by tokens, and each turn re-sends the conversation. How context size drives cost, how caching helps, and habits that reduce spend.

Published by Contextingo.

Language models are usually billed per token, for input and for output. A coding session sends the conversation so far with every request, so a long session costs more per turn than a short one.

What drives cost

  • The size of the context: every message, tool result and file read that is still in the session.
  • Large tool outputs: a long log or a big file in the context is paid for on each following turn.
  • The number of turns: each one carries the whole context.
  • The model: larger models cost more per token.

What helps

  • Prompt caching, offered by some providers, makes the repeated start of a request cheaper. Check how your provider prices it.
  • Start fresh when the task changes, instead of continuing a long session.
  • Narrow the input: ask for a function, not a whole file; limit command output.
  • Save state outside the chat, so a restart is cheap. A checkpoint and saved findings take a few lines instead of a long recap.

Measure

Look at usage by session in your provider’s dashboard. A few long sessions often account for most of the spend.

Related: why long agent chats get worse.

Questions

Good to know.

Are output tokens priced the same as input tokens?

Usually not; output is often priced higher. Check your provider’s price list.

Does a subscription remove token costs?

It hides them behind usage limits. Long sessions still use the limit faster.

Nothing learned is lost. Nothing unchecked is done.