LESSON 07 / 215·2 min readFoundation

Context window and context construction

Must knowConcept lesson
01 Understand02 Recall03 Prepare

Words made simple

A few useful meanings before you read the explanation.

Context window
The amount of input and output a model can handle for one request. Think of it as the available space on its working desk.
RAG
Find relevant information first, then give it to a model to help answer the question. The answer is only as reliable as the information and checks used.
Agent
An application that uses a model to choose its next action within defined limits. It can use tools and continue through several steps.
More words from this lesson
Persistence
Saving information so it remains available after a request ends or a process restarts.

Overview

  • A context window is the amount of model input and generated content a model can handle within its documented limits.
  • Context is the particular information you provide for one call: instructions, messages, evidence, and tool results.
  • A large window gives capacity, not a guarantee that the model uses every detail correctly.

Why this matters

The model needs enough information to answer the current question without overflowing limits or receiving irrelevant distractions.

An everyday example

A support employee can only keep a limited number of pages on their desk and still work efficiently.

A technical example

Keep the latest five messages, an approved summary, and the three most relevant policy sections instead of all previous chats.

How it works

  1. Identify required instructions
  2. Select recent messages
  3. Retrieve current evidence
  4. Preserve tool-call/result pairs
  5. Reserve response space
  6. Trim low-value material.

Architecture and flow

History + retrieved facts + task → context builder → bounded model request.

The insurance assistant example

The assistant includes the active policy version and current claim status, not ten unrelated expired policies.

When to use it

Every conversation, RAG application, and agent benefits from explicit context budgeting.

When to avoid it

Do not use context as permanent storage or assume the provider remembers content you did not send or persist.

Interview answer

“The context window is the model's capacity; context engineering is choosing the right information within that capacity.”

Benefits, trade-offs, and production considerations

  • Trim based on relevance and provenance, not just oldest-first.
  • Summaries can silently lose conditions or invent facts.
  • Keep canonical business data outside the summary and refresh it through tools.
PAUSE & RECALL

Can you explain it without the notes?

Context window and context construction

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

A context window is the amount of model input and generated content a model can handle within its documented limits. Context is the particular information you provide for one call: instructions, messages, evidence, and tool results. A large window gives…

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Temperature and top-p

Adapted from 13_AI.MD · “Context window and context construction”. Examples are study fragments; framework behavior can depend on your version.