Context engineering and agents
Prompt engineering is how you ask. Context engineering is what the model knows, sees and remembers at the moment it acts. The symptom that you have outgrown prompting: your template has grown past roughly 2,000 tokens of business rules and exceptions, and each new edge case adds a paragraph. That is knowledge encoded in the wrong place.
The maturity signal in the agent half of this chapter is restraint. A single agent with good tools beats a multi-agent system in most production cases, and an explicit state machine beats a free-form loop because it is testable, observable and bounded.
What this chapter covers
- [done] Context engineering vs prompt engineering, and the six-stage pipeline
- [done] Budgeting a context window
- [done] Lost in the middle, and context rot
- [done] Sub-agent isolation as cost and pollution control
- [done] Prompts in git, prompts with tests
- [done] Knowledge graph vs vector index
- [done] Compaction
- [done] ReAct, Plan-and-Execute, Reflexion, router, supervisor, handoff
- [done] Tool registry design; tool descriptions as prompt surface
- [done] MCP as the tool-exposure standard
- [done] Agent memory: short-term, long-term, episodic, semantic
- [done] Tracing, replay and checkpointing
- [done] LangGraph-style state machines, with code
- [done] GraphRAG: extraction, communities, local vs global search
- [done] Entity resolution
- [done] Agent failure modes
Source: §16, §44.3.