AI EngineeringInterview preparation
Foundation·Concept·2 min read

Context window and context construction

Practice this question

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.
Adapted from 13_AI.MD · “Context window and context construction”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.