All courses

Cost and usage limits

Explain what drives usage: tokens read and written, long contexts, repeated tool loops, and stronger or slower models. Explain how subscription limits and pay-per-use differ in general, and why focused tasks waste less.

Builds on: The context window: the agent's working memory, The agent loop: act, observe, repeat

Read it card by card Start the whole course

One message, a whole usage allowance

You type `▸ You: look through the whole project and fix anything that seems off`. The agent reads dozens of files, runs the tests, sees failures, edits, and runs them again, and again. Forty minutes later the tool says you have reached your usage limit for now. You only sent one message. What did you actually use up, and why so much of it?

Every step re-reads everything

The model keeps nothing between steps. At each turn of the loop, the tool sends it the **whole context so far**: instructions, your messages, every file read, every command output. The model reads all of it again to choose the next step. So a step late in a long session costs far more than an early one. Writing is billed too. Replies, edits and hidden reasoning (thinking text some models write before answering, which you may not see) are all output tokens. Output tokens are usually priced several times higher than input tokens.

What drives usage

Usage ≈ tokens read + tokens written, **summed over every step**. - **Context size**: big files, long logs and long sessions make *each* step heavier. - **Number of steps**: retries, failing test runs and wandering searches add steps. - **Output**: long replies, big rewrites, long reasoning. - **Model**: stronger models cost more per token. They often reason longer, which adds output tokens and makes them slower. Waiting itself is not billed. Many tools cache repeated context. That makes re-reading it cheaper, not free.

Subscription vs pay-per-use

**Subscription**: a fixed monthly fee buys an allowance, usually measured over time windows (say, a few hours or a week). Stronger models use it up faster. When it runs out, you wait for the reset or the tool limits you. Unless you choose to buy extra, the bill does not grow. **Pay-per-use**: the tool connects with an API key (a secret code tied to your account with the model provider), and every token is billed. Often there is no ceiling except one you set. A runaway loop (the agent retrying for hours without finishing) costs real money unless you set a spending limit. Both are driven by the same tokens, so the same habits save in both.

Same bug, vague vs focused

Rough numbers, ignoring caching. The focused request wins twice: **fewer steps**, and a **smaller context at every step**. Because each step re-reads the context, those two savings multiply. On a subscription, the same gap decides whether you hit your limit by lunch or not at all.
▸ You: fix anything that seems off
  30 steps, context 10k → 90k tokens
  read: 30 × ~50k avg = ~1,500k
  write: ~40k

▸ You: fix the crash in src/report.py
  when the CSV is empty; run its test
  6 steps, context 8k → 20k tokens
  read: 6 × ~14k avg = ~84k
  write: ~5k

At $3/M read, $15/M write (example):
  vague ≈ $5.10   focused ≈ $0.33

Remember

Usage is the tokens read and written at **every** loop step, and each step re-reads the whole context. Number of steps × context size multiply. Lots of output and stronger models add more on top. A focused task keeps both the steps and the context small. That holds whether you run into a subscription limit or pay per token.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.