Skip to main content

How to Do Context Engineering

Guide · about 8 min · refs checked 2026-11-03 (reference links and dates only)

Context engineering is not "stuff more material in". It decides what the model sees each turn, what it does not see, and how to compress the rest.

How to
Fix the must-haves first: current goal, hard constraints, available tools, output format and one or two examples; everything else is optional. Drop irrelevant history and repeated tool output: if the same file was read three times, keep the latest read and the diff. Compress with summaries or structured state: turn a long conversation into "confirmed facts / open tasks / unresolved questions" rather than truncating verbatim. Govern tool output: paginate, truncate, extract only relevant passages and keep source references instead of pasting whole pages. Draw memory boundaries: in-session state, cross-session facts and external retrieval are three layers; do not treat retrieval results as memory. Acceptance looks at two numbers: task success rate up and tokens per turn down; only both count as effective.

Example and interpretation

A teaching scenario, not a measured or executed site test.

Checking an event date does not need the entire meeting history. Keep confirmed facts, relevant constraints and source references; remove unrelated chat. Ensure removed constraints remain recoverable when still needed.

How to check your practice

Explain the example in your own words, inspect input constraints, then verify against the source. Revisit concepts if you cannot explain why; supply missing dates, fields or permissions; withdraw unsupported conclusions.

For this topic, start with missing input · See all six scenarios and their reasoning

Sources
  • Anthropic · Effective context engineering for AI agents ↗
  • Lost in the Middle: How Language Models Use Long Contexts ↗
  • LangGraph · Persistence ↗