liveBook · Manning

What you will learn in Context Engineering

Build consistent, accurate, predictable AI systems

by Boni García · Manning Early Access Program (MEAP)

Chapter by chapter

Chapter 1: Introduction to context engineering

The chapter introduction defines context engineering as supplying an LLM with the information needed for a task while respecting its context-window limit.

1.1 Defining context engineering · 1.1.1 The context window · 1.1.2 The context engineering stack · 1.2 Evolution of LLM-based systems · 1.2.1 LLMs, the foundational models · 1.2.2 AI workflows · 1.2.3 AI agents · 1.2.4 Agentic systems · 1.3 Limitations of LLMs · 1.3.1 Information integrity · 1.3.2 Technical and architectural constraints · 1.3.3 Bias, safety, and privacy · 1.4 Benefits of context engineering · 1.5 Taxonomy for context sources · 1.5.1 Instructions · 1.5.2 External knowledge · 1.5.3 Tools · 1.5.4 Memory · 1.5.5 State · 1.5.6 User prompt · 1.6 Hands-on · 1.6.1 Exploring context through an AI assistant interface · 1.6.2 Programmatic access to LLMs · 1.6.3 Installing and using a local LLM · 1.7 Summary

What you learn in chapter 1 →

Chapter 2: Instructions for AI agents

Introduces instructions as the context source that sets rules and behavioral expectations for LLM-based systems.

2.1 Instructions · 2.2 The system prompt · 2.2.1 Content of the system prompt · 2.2.2 System prompts in products and APIs · 2.3 Agent skills · 2.3.1 The anatomy of a skill · 2.3.2 Best practices for designing agent skills · 2.4 Instruction artifacts · 2.4.1 Instruction artifacts in coding agents · 2.4.2 Best practices for designing instruction artifacts · 2.5 Hands-on · 2.5.1 Using system prompts · 2.5.2 Creating custom agent skills · 2.5.3 Using existing agent skills · 2.5.4 Creating custom instruction artifacts · 2.6 Summary

What you learn in chapter 2 →

Chapter 3: External knowledge and retrieval

This introduction explains why LLM-based systems use external knowledge and distinguishes retrieval, caching, and direct injection as ways to supply it.

3.1 External knowledge · 3.2 Retrieval-augmented generation · 3.2.1 The indexing pipeline · 3.2.2 The generation pipeline · 3.2.3 Chunking strategies · 3.2.4 Retrieval models and vector databases · 3.2.5 RAG in production environments · 3.2.6 RAG tools · 3.3 Knowledge graphs · 3.3.1 Graph structure and modeling · 3.3.2 Graph RAG · 3.4 Hybrid RAG · 3.5 Agentic RAG · 3.6 Vectorless RAG · 3.7 Cache-augmented generation · 3.8 Context stuffing · 3.9 Choosing an approach · 3.10 Hands-on · 3.10.1 A minimal RAG implementation with an OpenAI model · 3.10.2 RAG with an open-source generation model · 3.10.3 Fully local RAG system · 3.10.4 RAG with RAGFlow · 3.10.5 Agentic RAG with LangChain · 3.10.6 Vectorless RAG with PageIndex · 3.10.7 KV-cache optimization example · 3.10.8 Context stuffing · 3.11 Summary

What you learn in chapter 3 →

Chapter 4: Tools in AI agents

Introduces tools as a way for AI agents to act on external systems and explains how tool use dynamically changes the context window.

4.1 Tools · 4.2 Function calling · 4.2.1 Tool definitions as contracts · 4.2.2 Strengths, limits, and failure modes · 4.2.3 Built-in functions in AI agents · 4.3 Command-line interface · 4.3.1 Strengths and failure modes · 4.3.2 CLI tools in agent skills · 4.4 Agent protocols · 4.5 Model context protocol · 4.5.1 MCP architecture · 4.5.2 MCP servers · 4.5.3 MCP server ecosystem · 4.5.4 MCP in production environments · 4.6 Hands-on · 4.6.1 Function calling with an OpenAI model · 4.6.2 CLI with an agent skill · 4.6.3 Using an existing MCP server · 4.6.4 Implementing a custom MCP server · 4.7 Summary

What you learn in chapter 4 →

Chapter 5: Memory and state in agentic systems

The introduction identifies memory and state as context sources an LLM-based system maintains across turns, distinguishing retained information from current status.

5.1 Memory · 5.1.1 Short-term memory · 5.1.2 Long-term memory · 5.1.3 Memory vs state · 5.2 Memory management · 5.2.1 Memory selection · 5.2.2 Memory compression · 5.2.3 Memory writing · 5.2.4 Failure modes and safeguards · 5.2.5 Memory management tools · 5.3 State · 5.3.1 Categories of state · 5.3.2 State scoping · 5.3.3 Multi-agent state architectures · 5.4 State management · 5.4.1 State representation · 5.4.2 State update · 5.4.3 State propagation · 5.4.4 State selection and projection · 5.4.5 State persistence and checkpointing · 5.5 Hands-on · 5.5.1 Long-term memory with Mem0 and Qdrant · 5.5.2 Graph-based long-term memory with Cognee · 5.5.3 Short-term memory curation with the OpenAI Agents SDK · 5.5.4 Session state with a structured scratchpad · 5.5.5 Shared workflow state between planner and executor · 5.6 Summary

What you learn in chapter 5 →

Chapter 6: User prompts for LLMs

Introduces user prompts as the context source that expresses a user’s immediate intent and guides the model toward a specific outcome.

6.1 User prompt · 6.2 Best practices for prompt design · 6.2.1 Core design principles · 6.2.2 Production considerations · 6.3 Prompting techniques · 6.3.1 Role prompting · 6.3.2 Few-shot prompting · 6.3.3 Chain-of-thought prompting · 6.3.4 ReAct prompting · 6.3.5 Prompt chaining · 6.3.6 Other prompting techniques · 6.3.7 Prompting and reasoning models · 6.4 Prompt frameworks · 6.4.1 10-step prompt structure · 6.4.2 Lightweight frameworks · 6.5 Prompting tools · 6.6 Hands-on · 6.6.1 Few-shot ticket normalizer · 6.6.2 Prompt chaining for support replies · 6.6.3 Prompting with DSPy: CoT vs ReAct · 6.6.4 Using prompt frameworks · 6.7 Summary

What you learn in chapter 6 →

Chapter 7: Context management and orchestration

The introduction distinguishes the six sources of context from the two layers that handle context during execution: management for a single model call and orchestration across a multi-step execution.

7.1 Context management · 7.2 Context selection · 7.2.1 Principles · 7.2.2 Techniques · 7.3 Context writing · 7.3.1 Principles · 7.3.2 Techniques · 7.4 Context compression · 7.4.1 Principles · 7.4.2 Techniques · 7.5 Context isolation · 7.5.1 Principles · 7.5.2 Techniques · 7.6 Context orchestration · 7.6.1 Orchestration models · 7.6.2 Coordination and interoperability · 7.7 Patterns for multi-agent coordination · 7.7.1 Sequential · 7.7.2 Parallel · 7.7.3 Loop · 7.7.4 Router · 7.7.5 Network · 7.7.6 Hierarchical · 7.8 Interoperability protocols · 7.8.1 Agent-to-agent (A2A) protocol · 7.8.2 Agent-user interaction (AG-UI) protocol · 7.8.3 Agent client protocol (ACP) · 7.8.4 Language server protocol (LSP) · 7.9 Hands-on · 7.9.1 Context compression with LLMLingua · 7.9.2 Filesystem context with OpenViking · 7.9.3 Multi-agent system based on the router pattern with LangGraph · 7.9.4 Collaborative agents with CrewAI · 7.9.5 Orchestration with DeepAgents · 7.9.6 Simplified A2A communication in practice · 7.10 Summary

What you learn in chapter 7 →

Chapter 8: Evaluation and observability

The introduction positions evaluation and observability as assurance disciplines that help diagnose context problems and assess whether LLM-based systems behave as intended.

8.1 A taxonomy of context failures · 8.1.1 Context rot · 8.1.2 Context staleness · 8.1.3 Context drift · 8.1.4 Context poisoning · 8.1.5 Context pollution · 8.1.6 Context distraction · 8.1.7 Context confusion · 8.1.8 Context clash · 8.1.9 Context overflow · 8.2 Evaluation · 8.2.1 Evals · 8.2.2 Evaluation metrics · 8.2.3 Evaluation datasets · 8.2.4 Benchmarks · 8.2.5 LLM-as-judge · 8.3 Observability · 8.3.1 Traditional observability foundations · 8.3.2 Active telemetry · 8.3.3 Context graphs · 8.3.4 Observability tools · 8.4 Hands-on · 8.4.1 Metrics with DeepEval · 8.4.2 Evals with Promptfoo · 8.4.3 LLM-as-judge with Ragas · 8.4.4 Observability with Langfuse · 8.4.5 Observability with LangSmith · 8.5 Summary

What you learn in chapter 8 →

Chapter 9: Governance and operations

Introduces governance and operations as the assurance disciplines that help context-aware AI systems run reliably and responsibly in production.

9.1 Governance · 9.1.1 Privacy · 9.1.2 Safety and security · 9.1.3 Accountability · 9.1.4 Transparency · 9.1.5 Fairness · 9.1.6 Human oversight · 9.1.7 Governance in practice · 9.2 Human-in-the-loop · 9.3 Operations · 9.3.1 Adoption models · 9.3.2 DevOps for AI systems · 9.3.3 LLMOps · 9.3.4 PromptOps · 9.3.5 RAGOps · 9.3.6 AgentOps · 9.3.7 Context as code · 9.3.8 Deployment · 9.4 Hands-on · 9.4.1 Automated PII redaction with Microsoft Presidio · 9.4.2 Output validation with JSON Schema · 9.4.3 Bias detection for fairness · 9.4.4 Basic HITL interaction pattern · 9.4.5 AI gateway with LiteLLM · 9.4.6 Context as code with versioned prompt templates · 9.5 Summary

What you learn in chapter 9 →

Chapter 10: AI frameworks for context engineering

The introduction explains why framework choice matters for context engineering: frameworks package capabilities that teams rarely build entirely from scratch, while affecting visibility and control over the context lifecycle.

10.1 Understanding the framework landscape · 10.2 Choosing a framework for your AI application · 10.3 AI application frameworks · 10.3.1 LangChain · 10.3.2 LlamaIndex · 10.3.3 Haystack · 10.3.4 Spring AI · 10.3.5 LangChain4j · 10.3.6 Pydantic AI · 10.3.7 DSPy · 10.3.8 AI SDK · 10.4 Agent orchestration frameworks · 10.4.1 LangGraph · 10.4.2 CrewAI · 10.4.3 Agent Development Kit · 10.4.4 Microsoft Agent Framework · 10.4.5 Agno · 10.4.6 Embabel · 10.4.7 Parlant · 10.4.8 DeepAgents · 10.4.9 Claude Agent SDK · 10.5 AI application platforms · 10.5.1 Dify · 10.5.2 LangFlow · 10.5.3 Flowise · 10.5.4 Zapier · 10.5.5 n8n · 10.5.6 OpenClaw · 10.5.7 Temporal · 10.5.8 Amazon Bedrock AgentCore · 10.5.9 Gemini Enterprise Agent Platform · 10.6 Hands-on · 10.7 Summary

What you learn in chapter 10 →

Chapter 11: Context engineering for software development

Introduces software development as a domain where dependable AI assistance depends on context flowing across the development lifecycle, not just stronger models.

11.1 AI-assisted coding · 11.1.1 Stage 0: traditional development · 11.1.2 Stage 1: autocomplete · 11.1.3 Stage 2: conversational copilots · 11.1.4 Stage 3: AI-native IDEs · 11.1.5 Stage 4: coding agents · 11.1.6 Stage 5: agentic systems · 11.2 AI-driven software development lifecycle · 11.3 Context engineering applied to software development · 11.3.1 Agent skills for the SDLC · 11.3.2 Instruction artifacts in coding agents · 11.3.3 External knowledge for software development · 11.3.4 MCP servers for the SDLC · 11.3.5 Memory for coding agents · 11.3.6 Reusable prompts as context assets · 11.3.7 Specification-driven development · 11.3.8 Context management for coding agents · 11.3.9 Context orchestration for coding agents · 11.4 Cross-cutting concerns for software development · 11.4.1 Evaluation · 11.4.2 Observability · 11.4.3 Governance · 11.4.4 Operations · 11.5 Hands-on · 11.5.1 SDD with Spec Kit · 11.5.2 Claude Code with agent skills · 11.5.3 Cursor with instructions · 11.5.4 Codex with Context7 · 11.5.5 OpenCode with Superpowers · 11.5.6 Antigravity with Open GSD · 11.5.7 Specialized agents with the BMAD Method · 11.5.8 Comparing the hands-on workflows · 11.6 Summary

What you learn in chapter 11 →

Chapter 12: The state of the art in context engineering

This chapter introduction previews a synthesis of context engineering’s mathematical foundations, research challenges, technical frontiers, applications, and future directions.

12.1 Mathematical foundations · 12.1.1 Context formalization · 12.1.2 Context optimization · 12.1.3 Context selection and compression · 12.1.4 Context inference · 12.1.5 Context quality · 12.1.6 Putting the formulations together · 12.2 Research challenges · 12.2.1 Context selection · 12.2.2 Context grounding · 12.2.3 Stale memory · 12.2.4 Governance · 12.3 Technical frontiers · 12.3.1 Long-context models · 12.3.2 Context caching · 12.3.3 Memory architectures · 12.3.4 Multi-agent context sharing · 12.3.5 Context observability · 12.4 Domain-specific applications · 12.5 Future directions · 12.5.1 Interoperable context · 12.5.2 Memory infrastructure · 12.5.3 Governed agent ecosystems · 12.5.4 Loop engineering · 12.5.5 Graph engineering · 12.5.6 Context-aware evaluation · 12.5.7 Self-improving context pipelines · 12.6 Hands-on · 12.6.1 Building a context engineering radar · 12.6.2 Building a base knowledge · 12.7 Summary

What you learn in chapter 12 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.