Effective context engineering for AI agents
by Anthropic
Curate the finite token budget that decides how well your agent behaves.
Overview
Published 29 September 2025 by Anthropic's Applied AI team, Prithvi Rajasekaran, Ethan Dixon, Carly Ryan and Jeremy Hadfield, this post argues that prompt engineering has been subsumed by a larger problem. It defines context engineering as the strategies for curating and maintaining the optimal set of tokens during LLM inference, covering everything that lands in the context window rather than the prompt alone, and frames the difference as discrete versus iterative: a prompt is written once, a context is managed every turn. Two concepts do the heavy lifting. Context rot is the observed decay in a model's ability to accurately recall information as token counts rise. Attention budget treats attention as a finite resource depleted by every additional token, analogous to human working memory, which turns "add more context" into a cost rather than a free improvement. From there it becomes prescriptive. System prompts should sit at the right altitude, specific enough to guide behaviour but not brittle hardcoded logic, and should be split into distinct sections using XML tags or Markdown headers such as `<background_information>`, `<instructions>`, `## Tool guidance` and `## Output description`. Tools should be self-contained, robust to error and minimally overlapping, because bloated tool sets create ambiguous decision points. Examples should be diverse and canonical rather than a laundry list of edge cases. The closing section covers three long-horizon techniques: compaction, structured note-taking (illustrated by Claude playing Pokemon across thousands of game steps), and sub-agent architectures whose specialists return condensed summaries of roughly 1,000 to 2,000 tokens to a coordinating agent.
At a Glance
- Topic
- Agentic
- Level
- Intermediate
- Format
- Guide
- Cost
- Free
- Duration
- ~20 min read
- Provider
- Anthropic
- Hands-on
- No
- Certificate
- None
What You’ll Learn
- ✓Treat the context window as a finite attention budget rather than free space
- ✓Recognise context rot and why recall degrades as token counts climb
- ✓Write system prompts at the right altitude: steering heuristics, not hardcoded logic
- ✓Structure a system prompt into XML or Markdown sections the model can navigate
- ✓Design minimal, non-overlapping tools instead of a bloated ambiguous tool set
- ✓Apply compaction to summarise history and reinitialise near the context limit
- ✓Use structured note-taking and sub-agents for tasks spanning thousands of steps
Highlights
- •Written by the Applied AI team behind Claude Code and Anthropic's agent stack, and released alongside Claude Sonnet 4.5
- •Names the failure modes, context rot and the attention budget, rather than only prescribing fixes
- •The sub-agent guidance is concrete: specialists return condensed summaries of roughly 1,000-2,000 tokens to a coordinating agent
- •148 points and 32 comments on Hacker News, and third-party prompt tooling now scores prompts against its metrics
- •Free, about 20 minutes, no signup: the fastest available orientation to the topic
Who It’s For
Best For
- ✓Engineers whose agents degrade on long-running or multi-step tasks
- ✓Anyone designing a system prompt or tool set for a production agent
- ✓Teams weighing a bigger context window against a sub-agent architecture
Prerequisites
- •Understanding of LLM prompting and how a context window works
- •Some experience building an agent or a RAG pipeline
FAQ
What is Effective context engineering for AI agents?
Anthropic's Applied AI team on context engineering: the strategies for curating and maintaining the optimal set of tokens during inference, not just the prompt. It defines context rot and the attention budget, gives prescriptive guidance on system prompts and tool design, and closes with three concrete techniques for tasks that outlive a single context window.
Is Effective context engineering for AI agents free?
Effective context engineering for AI agents is free to access.
What level is Effective context engineering for AI agents for?
Effective context engineering for AI agents is aimed at a intermediate audience. Recommended background: Understanding of LLM prompting and how a context window works, Some experience building an agent or a RAG pipeline.
How long does Effective context engineering for AI agents take?
Expect roughly ~20 min read. Most learners work through it at their own pace.
What will I learn from Effective context engineering for AI agents?
You'll learn: Treat the context window as a finite attention budget rather than free space; Recognise context rot and why recall degrades as token counts climb; Write system prompts at the right altitude: steering heuristics, not hardcoded logic; Structure a system prompt into XML or Markdown sections the model can navigate; Design minimal, non-overlapping tools instead of a bloated ambiguous tool set; Apply compaction to summarise history and reinitialise near the context limit; Use structured note-taking and sub-agents for tasks spanning thousands of steps.
Topics
Sources
This page was written from 2 sources, 1 on domains other than anthropic.com.