Agentic Context Engineering: Letting Agents Manage Their Own Context
Agentic context engineering is a design approach where an AI agent manages its own context with tools: it searches an index and loads only the knowledge it needs, writes notes or memory to keep important facts, summarises or clears old material, and hands work to sub-agents with fresh contexts. It replaces the approach of assembling one large fixed context before the agent starts.
Basic context engineering happens before the call: code decides what goes into the window. That works for single steps. For agents that run many turns on open tasks, nobody can predict up front everything the agent will need. Agentic context engineering hands part of that decision to the agent, through tools.
The tools that make it work
- Search and load. The agent reads a compact index and fetches specific entries on demand. Knowledge enters the window only when the agent asks for it.
- Step-specific guidance. A tool that returns the instructions for the current stage of work, so the agent does not carry instructions for every stage at once.
- Notes and memory. Tools to record a fact or decision outside the window and read it back later.
- Summarise and clear. When the window grows, older turns are compacted into a summary of conclusions.
- Delegate. Hand a focused subtask to a sub-agent that starts with a clean window and returns only its result.
An example from production
The page builder I run gives its builder agent a small always-loaded core prompt and a set of knowledge tools: find entries by keyword, get an entry by code, get the guidance for the current build step, and list a section. The knowledge base has around 850 entries. On a typical build the agent reads the index lines it needs and pulls a handful of entries per step. It also has memory tools to read and write facts per brand. The window stays small for the whole build, and the agent still has the full knowledge base available.
Design rules
- Make the index cheap to read. One short line per entry, with a "use when" description, so the agent can scan it without loading the entries.
- Return small results. Tools return the entry or the fields asked for, not whole documents.
- Tell the agent the rules for fetching. The core prompt should say: never load everything, search first, fetch only what the current step needs.
- Keep the stable core cacheable. Fetched content comes after the core prompt so caching still applies.
- Bound the loop. Limit fetches per step and total turns so a confused agent cannot read the whole base one entry at a time.
- Log fetches. Record which entries were loaded for each output. It explains most quality problems.
When to use it
Use agentic context engineering when the knowledge is large, the task is multi-step, and different runs need different subsets of knowledge. For a short, fixed task, assembling the context in code is simpler and just as good. It pairs with agent memory and well indexed retrieval.
A worked example: a build step
When the page builder agent reaches the hero section, the sequence looks like this:
- It calls the step guidance tool for "hero". It gets back a short checklist and the codes of the relevant knowledge entries.
- It reads the brand memory summary already in its context: tone, offer, proof points.
- It fetches two entries by code: one on hero headline structure, one on above-the-fold proof.
- It writes the hero, which code then checks for length and required elements.
- Before the next section, older tool results are dropped from the window; the plan and decisions remain.
At no point does the agent hold the whole knowledge base, the whole intake chat or every past tool result.
Effective context engineering for AI agents: the checklist
- A compact, always-loaded core prompt that states the fetching rules.
- An index with one line per entry.
- Fetch tools that return small results by code or keyword.
- Step guidance that loads only the current stage's instructions.
- Memory tools for durable facts.
- Compaction of older turns into a summary.
- Limits on fetches and turns.
- Logs of every fetch.
Where it came from
The approach follows the direction Anthropic's engineering team set out in its writing on effective context engineering for AI agents: just-in-time retrieval, compaction, structured notes and sub-agents. I apply it in the products on my systems page, and it is the design behind the line on my homepage about every token pulling its weight.
Agentic context engineering vs prompt engineering
Prompt engineering improves the words in a fixed prompt. Agentic context engineering designs a system in which the agent assembles its own context as it works, through tools and rules about when to use them. The prompt still matters, especially the small core that teaches the agent how to fetch, but most of what the model reads on any turn was chosen by the agent at that moment.
Signs your agent needs it
- The knowledge base is too large to fit comfortably in every call.
- Different runs need very different subsets of knowledge.
- Long runs degrade as the window fills.
- Costs grow with the length of each task.
Frequently asked questions
What is agentic context engineering?
Agentic context engineering is giving an AI agent tools to manage its own context window: searching an index and loading only needed knowledge, saving and reading notes or memory, summarising old material and delegating subtasks to agents with fresh contexts.
How is agentic context engineering different from RAG?
Classic RAG retrieves a fixed set of chunks before the model answers. Agentic context engineering lets the agent decide when to search, what to load, what to remember and what to drop, across many turns.
Does agentic context engineering reduce tokens?
Yes, when designed well. The agent loads only the knowledge each step needs instead of carrying everything for the whole task, so each call stays small even when the knowledge base is large.
What is just-in-time context retrieval?
It means the agent fetches information at the moment a step needs it, using tools, instead of receiving everything up front. It keeps the context window small and focused.
What is context compaction?
Replacing older parts of an agent's context, such as earlier turns and tool results, with a short summary of conclusions and decisions, so the agent can continue a long task without its window overflowing.
Is agentic context engineering the same as agentic RAG?
They overlap. Agentic RAG focuses on letting the agent decide when and what to retrieve. Agentic context engineering also covers memory, compaction, step-specific instructions and delegation to sub-agents.
Want an AI system designed this way?
I design and build AI systems where each agent has one job, sees only what it needs, and hands clean context to the next. Five are running in production right now. See what I have shipped, or book a call and bring the process you want automated.