GuidesUpdated

Why does my coding agent show so many sent tokens?

Understand large sent-token totals: growing context, cache reads and writes, output tokens, and what to check before you switch models.

On this page

A short request can sit inside a very large model input. Coding agents resend instructions, tool definitions, earlier messages, file excerpts and tool results on each turn, and some may come from a prompt cache. A large sent-token total is a reason to check the breakdown, not proof of a matching bill.

Canopy usage view with model, CLI, and session token totals
Canopy usage view with model, CLI, and session token totals · Illustrative data; displayed costs are estimates, not provider bills.

Start with direction, window and source

Sent or input tokens go to the model; received or output tokens come back. Neither is a price category. First identify the CLI, account, model, session, time window and when the record last updated. Canopy combines what supported CLIs report, and their detail differs. Check the CLI's own usage view, then the provider account for limits or charges. Don't compare a plan's 7-day bar with an API invoice.

A reading guide, not a price list. Provider reports and model rates change.
What you seeWhat to askWhat it cannot prove alone
Large sent or input totalDid many turns reuse a growing context?An equal number of fresh, full-price input tokens
Small received or output totalWere responses short, or did tool calls dominate?The task was efficient or correct
Cache-read countHow much prior input was reused?That every request hit cache or cost nothing
Cache-write countWhat reusable prefix was stored?The final charge without current rates
Estimated dollarsWhich categories and rates were used?The amount charged to a subscription or API account

Why a short prompt produces a huge input total

The next request can carry far more than your sentence: system and project instructions, tools, previous turns, file excerpts and command output. Anthropic's docs explain that earlier conversation is included in later input, and split input into ordinary, cache-creation and cache-read tokens. OpenAI documents reuse of a stable prompt prefix too. If a 20,000-token context rides along on 5 turns, input approaches 100,000 tokens even though your messages were short.

  • Cached prefixes may be cheaper but still count in totals.
  • Long tool results and broad searches grow the next turn.
  • Retries and extra agents are separate work.

Separate fresh input, cache reads, cache writes and output

For the Claude API, total input is ordinary input plus cache creation plus cache reads. OpenAI reports input and cached input, with model-specific cache writes. These categories have different rates, so one total times one rate won't rebuild a bill. Output is separate, and reasoning work can count as output even when the visible answer is short. Subscriptions use different accounting again.

Illustrative counts for one request; no model price or account charge is assumed.
CategoryExample tokensInterpretation
Fresh input1,000New material processed in this request
Cache creation4,000Prefix written for possible reuse
Cache read15,000Previously cached prefix used again
Total input20,000Sum of the three input categories
Output500Model-generated tokens, counted separately

Diagnose a surprising session before restarting it

Record the session or task, model, start and end time, total and last update, and compare one interval. Did a command retry repeatedly? Did a log dump enter the conversation? Did the agent start subagents or switch models? Did the CLI compact context and lose cache reuse? Find the same interval in the provider's record, and note any mismatch rather than forcing agreement.

  • Pause a loop that's still doing the wrong work.
  • OpenCode's CLI has a stats command with model and project filters.

Optimize the finished task, not the token count

Cut irrelevant file dumps, repeated failed commands and unbounded requests. Keep project rules short and stable. When switching sessions, hand over the goal, branch, decisions, checks and next action, not the transcript. Compact or reset when stale context causes mistakes. Compare approaches by attempts, review time, rework and result; fewer tokens for a broken PR isn't a win.

Want to check the arithmetic? Enter your own token counts and rates in the session cost calculator →

Copyable resources

Copyable usage investigation

Use totals from your own CLI and provider view; keep private prompts and account details out of public issues.

Task and accepted result: [ ]
CLI / model / account label: [ ]
Session ID and time window: [ ]
Usage observed at: [timestamp]
Input or sent: [ ]; output or received: [ ]
If available: fresh input [ ]; cache read [ ]; cache write [ ]
Provider plan limit or API billing for that interval: [ ]
Repeated errors, tool output, retries, subagents or model switches: [ ]
Decision: continue, narrow the task, compact, or stop and hand off
Evidence to keep: branch/PR, exact failure, tests, decisions, next action

Frequently asked questions

Does a billion sent tokens mean I typed a billion tokens?

No. Sent or input totals include instructions, tools, files, prior conversation and repeated or cached context across many requests and sessions. Check the reporting scope and category breakdown.

Are cached tokens free?

Usually not in API pricing. Providers publish separate cache-read and sometimes cache-write rates. Subscription plans have their own limit rules; check the provider account for actual charges.

Why are output tokens so much lower than input tokens?

Each request can carry a large project and conversation context while the model returns a short answer or tool call. The ratio says nothing about code quality or task completion.

Should I clear context whenever sent tokens rise?

Only after checking whether the context is useful, cached or stale. Clearing it can lose decisions and trigger repeated research. Keep a short handoff and compare the accepted result.

More questions and answers →

Sources and further reading