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
- [todo] Context engineering vs prompt engineering: the distinction that matters
- [todo] The context pipeline: curation, retrieval, ranking, compression, assembly, feedback
- [done] Budgeting a context window
- [todo] Lost in the middle, and context rot
- [todo] Compaction: rolling summarisation, hierarchical, structured state extraction
- [todo] Sub-agent isolation as a cost and pollution control
- [todo] Prompts in git, prompts with tests
- [todo] ReAct, Plan-and-Execute, Reflexion, router, supervisor, handoff
- [todo] Tool registry design, and why tool descriptions are the real prompt
- [todo] MCP as the tool-exposure standard
- [todo] Agent failure modes: loops, injection via tool output, hallucinated calls, non-idempotent retries
- [todo] Agent memory: short-term, long-term, episodic, semantic
- [todo] Tracing, replay and checkpointing
- [todo] LangGraph-style state machines, with code
- [done] Knowledge graph vs vector index
- [todo] GraphRAG: extraction prompts, communities, local vs global search
- [todo] Entity resolution, the hardest part of any real knowledge graph
Source: §16, §44.3.