Token problems: 5 of 20

By Prof. Tom Yeh

Published: 2026-05-28

URL: https://www.byhand.ai/p/library-agents-tokens-will-it-fit


Token problems: the workbook

  1. Count the Tokens
  1. Subword Splitting
  1. Punctuation Counts
  1. Tokens per Word
  1. Will It Fit?
  1. The Price of a Call
  1. Two Kinds of Token
  1. Input or Output?
  1. The Two-Part Bill
  1. End-to-End Call Cost
  1. Comparing Three Calls
  1. The Average Call
  1. The System Prompt
  1. The System Prompt Tax
  1. Calls in a Budget
  1. Tokens on a Budget
  1. How Long Will It Take?
  1. The Split Matters
  1. Pricing per Million Tokens
  1. Tokens from the Bill

Can an agent always read a document it is given? Not if the document exceeds the space that remains in the context window. The window is shared: the system prompt and conversation history already occupy part of it. Estimate the document size first, then compare it to what is left. If the estimate exceeds the remaining space, the agent cannot read it in one call.

Problem

An agent has a 4,000-token context window. The system prompt and conversation history already use 1,200 tokens. The document to read is 55 paragraphs, each about 50 tokens. Can the agent read the document in this call?

Space available for the document

Estimate the document

Does it fit?

Practice 1

An agent has a 4,000-token context window. The system prompt and conversation history already use 600 tokens. The document to read is 8 pages, each about 500 tokens. Can the agent read the document in this call?

Space available for the document

Estimate the document

Does it fit?

Practice 2

An agent has a 4,000-token context window. The system prompt and conversation history already use 1,000 tokens. The document to read is 18 slides, each about 150 tokens. Can the agent read the document in this call?

Space available for the document

Estimate the document

Does it fit?


Next: 6. The Price of a Call