LearnThatStack Ace your next interview
Context Engineering · question
Question 5 of 49

In a typical coding agent session, what actually consumes context tokens?

beginner
← All Context Engineering questions
Re-explain
Visual ↓

Nearly everything the agent reads or writes consumes tokens:

  • Standing text: system and project instructions, and the tool definitions.
  • The conversation: your messages, earlier replies, and any summaries.
  • What the agent reads: source files, search results, and documentation.
  • What tools return: command output, error logs, and diffs.

Repeated content can be charged and processed again unless caching applies. Large test logs, generated files and broad searches fill the window fast without adding much value. Ask for focused output, open only the relevant file sections, and filter noisy command results.

Keep standing rules lean, because they appear in many requests. When a task changes direction, start a fresh session instead of carrying unrelated history. Watching tokens saves money, and it also keeps the model's attention on the evidence that matters.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Context Engineering One question at a time. Answer out loud, get graded, see what you missed.
See it - interactive diagram
What the model receives on each request
Request 1
Standing text
Task
Request 2
Standing text
Task
File
Request 3
Standing text
History
Full test log
Lean request 3
Standing text
History
Failures only
Window limit
  • Request 1: Standing text - This is the system prompt, rules and tool definitions.
  • Request 2: Standing text - It goes out again. Caching cuts cost, not window space.
  • Request 3: Standing text - The same text goes out a third time, so keep it short.
  • Lean request 3: Standing text - It goes out every turn, so short rules save tokens.
  • Request 1: Task - This is the task you typed.
  • Request 2: Task - Your task is now history, and it goes out again.
  • Request 3: History - Everything from the first two requests goes out again.
  • Lean request 3: History - The history is the same as in request 3.
  • Request 2: File - The agent read only the lines of the file it needed.
  • Request 3: Full test log - The raw test log fills the window, but few lines matter.
  • Lean request 3: Failures only - The agent asked for failures only, so the window has room.
  • Window limit - This is the most tokens one request can hold.

Every request resends the standing text and the whole history, so one raw test log can crowd the window while adding little.

© LearnThatStack - diagrams may not be republished without permission.

Other questions have diagrams like this too. Sign in to ask for one where it's missing - it's free.

Create a free account
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. Pretty much everything the agent reads or writes costs tokens, not just the messages I type.
  2. Every request carries standing text, meaning the system prompt, the project instructions and the definitions of every tool the agent can use.
  3. Then there's the conversation, so my messages, earlier replies and any summaries, plus everything the agent reads, like source files, search results and docs.
  4. Tool results count too. Command output, error logs and diffs all land in the window, and a full test log or a broad search fills it fast without adding much.
  5. Repeated content gets charged and processed again unless caching applies, so I keep standing rules lean and ask for focused output, like filtered logs or one file section.
  6. When the task changes direction I start a fresh session, because old history costs money and pulls the model's attention away from the evidence that matters.

Weak answers to avoid

  • Says only the prompts and replies count It leaves out the standing text and everything tools return. Name the rules files, tool definitions, file reads and command output too.
  • Treats it as a billing issue only Cost is only one of the two reasons. Noisy context also pulls the model's attention off the evidence that matters. Say both, then give one way you trim.
  • Forgets that standing text repeats every request Instructions and tool definitions go out with each call, so a bloated rules file costs you on every turn. Mention that caching only offsets part of that.
  • Lists sources but no way to cut them Knowing what fills the window only helps with a fix. Name concrete moves, like filtering logs, opening file sections and starting fresh when the task changes.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Context Engineering cheatsheet.

← Back to all Context Engineering questions
Pro · $10/mo

42 of 49 Context Engineering answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime