Context engineering
Deciding what goes into the model’s context, in what order and when, across a whole task.
Context engineering is deciding what goes into a model’s context, in what order and at what moment, across a whole task. Prompt engineering is about the wording of one request. Context engineering is about the whole flow: which instructions are always present, which files load on demand, what tool results are trimmed, what gets summarized. For agents it matters more than any single prompt.
Anthropic’s post Effective context engineering for AI agents (September 29, 2025) treats context as a finite “attention budget”: the goal is the smallest set of high-signal tokens that gets the job done. In practice that means a short, stable system prompt, a few well-described tools, and loading data “just in time” by keeping file paths or IDs in context and fetching the contents only when needed. For long tasks the same post names three techniques: compaction, structured notes kept outside the window (see agent memory), and subagents with clean windows.
Most of this work lives in the harness, the code around the model, more than in the prompt text. A common mistake is treating a larger context window as a substitute: stuffing everything in raises cost and invites context rot. RAG and agent skills are two concrete tools of context engineering, because both load material only when the task calls for it.
Sources
- Anthropic: Effective context engineering for AI agents anthropic.com
Related terms
- Context window: The maximum number of tokens the model can read and write in one request.
- Agent Skills: Folders with instructions, scripts and references that an agent loads only when the task needs them.
- RAG (retrieval-augmented generation): Finding relevant documents first and putting them into the prompt, so the model answers from them.
- Agent harness (harness engineering): Everything around the model that makes it an agent: the loop, tools, permissions, instructions, saved state, checks and session handoff.
- Compaction: Replacing the older part of a long conversation with a summary so the agent can keep going.
- Context rot: Model quality drops as the context fills with old, irrelevant or conflicting material.
- Subagent: A separate agent run with its own fresh context, started by a main agent for one subtask.
- Agent memory: How an AI agent keeps information beyond one conversation: notes, facts and preferences it saves and reads back later.
- Fine-tuning (vs RAG and prompting): Further training a model on your own examples so it adopts a style, format or narrow skill; poor at teaching it new facts.
- Research, plan, implement (RPI): Working with a coding agent in three phases, each in a fresh context: research the code into a document, write a plan from it, then implement the plan.
- PRP (Product Requirement Prompt): A PRD rewritten for a coding agent: the goal and why, plus the exact files, patterns to follow and commands that prove the work is done.
