Skip to content
mentoor

Topic 4 of 5 · 5 min read

A per-task context budget plan

Goal: Draft a context plan for a task with a token estimate per item and a rule for what to drop first when the window fills.

Before a big task, write a small budget: what goes into the window, about how many tokens each item costs, and what you will drop first when space runs short.

Check yourself · 1 of 3

What is the purpose of a drop order in a context plan?

Choose one answer

Why it matters

Without a plan, the window fills by accident. A long thread, three files and a tool log arrive, and the instruction you care about gets pushed out or diluted. A budget turns that into a choice. It also stops quality loss from creeping in unseen, because you decided in advance what is allowed to go.

How to build one

  1. List the candidates. Everything that could go in: instructions, reference files, history, examples, tool results.
  2. Estimate the size of each. A token is a piece of a word. As a rough rule for English, one token is a little under one word. Use your tool's token counter when you can, and treat quick estimates as rough. Code and non-English text usually cost more per word.
  3. Give each item a priority. Must keep, should keep, nice to have.
  4. Set the total. Choose a working limit well below the maximum window, because quality can fall as the window fills and you need room for the answer itself.
  5. Write a drop order. The first item to go is the lowest priority and cheapest to rebuild, for example old tool output, then examples, then older history. The task, the rules and the question never go.

Before and after

Task: review a pull request with an assistant.

Weak plan: "paste the diff, the files it touches, the whole ticket history and the style guide."

Budgeted plan:

  • Instructions and review rules: about 400 tokens, must keep.
  • The diff: about 3,000 tokens, must keep.
  • Ticket summary instead of the full history: about 300 tokens, should keep.
  • Style guide, only the sections on naming and errors: about 800 tokens, should keep.
  • Whole touched files: about 12,000 tokens, nice to have; give only the functions the diff changes.
  • Drop order: whole files, then style guide, then ticket summary.

The numbers are estimates. The value is the order of decisions, not the exact count.

Watch the output too

The answer uses the same window. If the model must write a long report, reserve room for it. A request that fills the window leaves little space to answer well.

What goes wrong

  • No drop rule. When space runs out, the tool or you cut at random, often the instruction.
  • Counting only the paste. System prompts, tool definitions and earlier turns also use the window.
  • False precision. Treat estimates as rough and re-measure when the task is large or costly.
  • Planning once. A long task changes. Revisit the plan when the work changes direction.

Examples

A budget table for a contract review

Item Est. tokens Priority Drop order
Review instructions and output format 500 Must keep never
The contract 9,000 Must keep never
Playbook: only the clauses we check 1,200 Should keep 3
Last year's review as an example 2,500 Nice to have 2
Earlier chat about other deals 4,000 Nice to have 1

When the window fills, drop the earlier chat first, then the example, then trim the playbook.

Reserving room for the answer

You want a 3,000-word report from 20 sources. If the sources fill almost all of the window, the report has no space and will come out short or cut off.

Set the working limit lower, cut sources to the excerpts that matter, and keep a fixed amount free for the output.

Key points

  • A context budget lists each item, its rough token cost, its priority and the order of removal.
  • Set a working limit below the maximum window and reserve room for the model's answer.
  • The task, the rules and the question are never in the drop order.
  • Drop first what is cheap to rebuild or least relevant, such as old tool output and extra examples.
  • Token counts are estimates, so use a counter for big jobs and revisit the plan as the task changes.

Common mistakes

  • Not writing a drop order, so the instruction or the question is cut when the window fills.
  • Counting only what you paste and forgetting system prompts, tool definitions and earlier turns.
  • Filling the window to the limit and leaving no room for the answer.
  • Treating a token estimate as exact instead of measuring when the job is large or costly.

Check yourself · 2 of 3

Why keep your working limit below the maximum window size?

Choose one answer

Check yourself · 3 of 3

Your plan has four items: rules (400 tokens), the diff (3,000), whole files (12,000), and a ticket summary (300). Space runs short. What goes first?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic