Context Window

The context window is the token budget a model can attend to during one call. It contains the prompt, instructions, retrieved evidence, conversation state, tool results, and requested output.

If is the maximum context length:

Context is not memory by itself. It is the temporary working set for one model invocation.

The context should be allocated by role:

When context is tight, prioritize current evidence over stale summaries.

Attention Cost

For standard full attention, compute and memory scale roughly with context length:

This is why long context is not the same as free memory. Even if a model can accept a long prompt, irrelevant context can increase latency, cost, and distraction.

Context Allocation

A practical allocation can be treated as an optimization problem:

where is candidate evidence and is the selected subset. Good context packing selects evidence that is current, authoritative, relevant, and non-duplicative.

Recency and Position

LLMs can be sensitive to where information appears. Important constraints should be placed in stable instruction or task sections, while long evidence blocks should be structured with clear labels:

This separation matters for prompt injection boundaries.

Memory Boundary

Context is temporary. Memory is persisted or retrieved across calls:

Do not treat a context summary as authoritative when current source files, tool output, or user instructions contradict it.

Checks

  • What must be in context for the next decision?
  • What can be retrieved later instead of loaded now?
  • Are stale summaries overridden by fresh evidence?
  • Are untrusted documents separated from instructions?
  • Is important evidence being truncated?
  • Is output budget reserved before loading more evidence?
  • Are repeated summaries crowding out direct evidence?
  • Is the context ordered so that high-priority instructions are easy to distinguish from data?
  • Is the task using context as a substitute for durable memory when retrieval would be better?