C

Context

Everything the model can see while it answers: your instructions, the conversation so far, attached files and tool results. It has a hard size limit.

6 chapters6 tutorials

01 · Introduction

What context is

When a model answers, it reads one long block of text and writes a continuation. That block is the context. It contains, in order:

  1. The system instructions (who it is, the rules, the format).
  2. The conversation so far, every message from both sides.
  3. Attachments and tool results: files you added, pages it fetched, search results.
  4. Your latest message.

The block has a maximum size, the context window, measured in tokens. Models today hold a few hundred thousand tokens, roughly a few hundred pages. Anything outside the window does not exist for the model.

This explains most "the AI forgot" complaints: the fact was never in the context, or it scrolled out.

02 · When to use it

When context is the problem

  • A long chat gets slower, pricier and starts contradicting itself: the window is filling up.
  • A big PDF "was not read properly": it did not fit, or the important part was in the middle.
  • An agent loses track halfway through a task: too many tool results piled up.
  • The same question gives different answers in different chats: the context differed, not the model.

03 · Setup

Managing it on purpose

  1. Put the important things first and last. Models pay the most attention to the start and the end of the context.
  2. Give instructions once, in the system prompt, not scattered through the chat.
  3. Summarize before you continue. After a long discussion, ask for a summary, start a new chat, paste the summary.
  4. Attach, do not paste, long material; let the tool chunk it. For very long material, use a knowledge base so only the relevant pages enter the context.
  5. Trim tool output in agents: keep the fields you need, drop the rest before the next step.

04 · How to use it

Day-to-day habits

  • One topic per chat. New topic, new chat.
  • Before a complex question, paste the two or three facts it depends on, even if you said them earlier.
  • Ask the model what it currently knows about the task; the answer shows what is in its context.
  • In automations, log the full prompt once in a while and read it; you will find stale instructions and duplicated text.
  • Use the provider's prompt caching for the parts that repeat on every call; it is cheaper and faster.

05 · Pitfalls

Pitfalls

  • A bigger window is not free: every token in it is billed on every turn, and very full windows answer worse, not better.
  • "It read the whole document" usually means it skimmed. Ask about a specific section to check.
  • Instructions hidden inside attached content (a web page, an email) land in the context like anything else. Tell the model to treat attachments as data.
  • Different models have different windows; a prompt that fits one may not fit another.

06 · Resources

Where to go next

Context is the size of the desk; memory is what you keep in the drawer; the knowledge base is the filing cabinet.

My notes

Sign in to keep private notes on this handbook.Sign in