liveBook · Manning

Chapter 1: Introduction to context engineering

What you will learn in chapter 1 of 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.

After this chapter you will be able to

Section by section

Introduction

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

Key terms: context, inference time, context engineering, context window, tokens, generative AI, GenAI, large language models, LLMs

1.1 Defining context engineering

This section distinguishes prompt engineering from context engineering and introduces the limited context window that constrains what an LLM can see.

Key terms: prompt engineering, context engineering, prompt, context window, tokens

1.1.1 The context window

This section explains why LLM performance depends on the information placed in a limited context window and why that information must be chosen carefully.

Key terms: context engineering, context window, tokens, persistent storage, tool calls, token budget, attention budget, reasoning quality per token

1.1.2 The context engineering stack

The section presents the context engineering stack as a conceptual map of how context is sourced, shaped, and routed, with production concerns applying across that work.

Key terms: context engineering stack, functional layers, cross-cutting concerns, context sources, instructions, external knowledge, tools, memory, state, context management

1.2 Evolution of LLM-based systems

1.2.1 LLMs, the foundational models

This section explains how LLMs generate text, distinguishes learned parameters from practitioner-chosen settings, and describes how reasoning models extend generation for multi-step tasks.

Key terms: LLM, transformer architectures, token, prompt, next-token prediction, parameters, weights and biases, hyperparameters, parameter count, mixture of experts (MoE)

1.2.2 AI workflows

This section explains how a predefined AI workflow combines LLM calls with code and external data to handle tasks beyond a single LLM call.

Key terms: standalone LLM call, single inference pass, AI workflow, predefined pipeline, control and data flow, retrieval-augmented generation, RAG, external data sources

1.2.3 AI agents

This section explains what makes an LLM-based system an AI agent, how its model, harness, and runtime differ, and how context supports iterative action.

Key terms: AI agents, autonomy, AI workflows, LLM, model, harness, context, execution state, agent loop, reasoning

1.2.4 Agentic systems

Defines agentic systems as goal-directed architectures that may contain one or more agents, then explains multi-agent coordination, its tradeoffs, and its context demands.

Key terms: agentic system, AI agent, agentic AI, single-agent system, multi-agent system, orchestrator, system boundary, specialization, focused context, coordination

1.3 Limitations of LLMs

This introduction establishes that LLM limitations can become weaknesses in applications built on them.

Key terms: LLMs, limitations, technical barriers

1.3.1 Information integrity

This section explains four ways LLM systems can compromise information integrity and the kinds of safeguards that address each risk.

Key terms: hallucination, instructions, grounding, tools, memory, faithfulness metrics, stale data, training cutoff, retrieval, live data

1.3.2 Technical and architectural constraints

This section explains four technical constraints on LLM-based systems—variable outputs, latency, finite context windows, and uneven attention within long prompts—and why each matters for context engineering.

Key terms: nondeterminism, next token, temperature, exact repeatability, latency, token generation, context window, cache-augmented generation, retrieval, memory

1.3.3 Bias, safety, and privacy

This section explains how training-data bias, unsafe responses, prompt injection, and exposure of sensitive context limit LLM-based systems.

Key terms: biases, training data, mitigation, jailbreaking, prompt injection, context window, guardrails, access control, context, hosted model

1.4 Benefits of context engineering

The section explains how explicitly managing an AI system’s context improves accuracy, consistency, continuity, explainability, efficiency, and scalability without eliminating every LLM limitation.

Key terms: accuracy, parametric knowledge, model context, consistency, predictability, constraints, intermediate decisions, continuity, user preferences, task constraints

1.5 Taxonomy for context sources

This section explains how an LLM-based system selects and assembles six possible context sources for each call, coordinates that work across turns, and lets information move between source roles.

Key terms: context sources, LLM-based system, context window, context selection, context assembly, context curation, context manager, agent harness, context orchestrator, state object

1.5.1 Instructions

Defines instructions as behavior-governing context and distinguishes the system prompt, agent skills, and instruction artifacts as ways to deliver them.

Key terms: instructions, system prompt, agent skills, instruction artifacts, role, tone, output conventions, safety boundaries, AGENTS.md, CLAUDE.md

1.5.2 External knowledge

External knowledge supplies current, domain-specific context to an LLM, but the quality of its answers depends on which source passages retrieval selects.

Key terms: external knowledge, static data, RAG, ground, context window, passages, metadata, retrieval, rank, tokens

1.5.3 Tools

This section explains how tools extend an LLM’s capabilities, what tool-related content enters its context, and three common ways tools are exposed.

Key terms: tool definitions, tool call, tool outputs, current working context, memory, function calling, command-line interface (CLI), model context protocol (MCP), structured invocation, agent harness

1.5.4 Memory

This section explains how memory gives stateless LLM calls continuity, distinguishing model knowledge from the short- and long-term memory managed outside the model.

Key terms: stateless, memory, context source, parametric, non-parametric, model’s weights, short-term memory, current session, curated view, session object

1.5.5 State

This section defines session state, distinguishes it from short-term memory, and explains how a changing state object informs the model’s next context window.

Key terms: state, short-term memory, session, state object, scratchpad, context orchestrator, context manager, context window

1.5.6 User prompt

Defines the user prompt as the end user's immediate task and explains how it sets the goal for other context sources.

Key terms: user prompt, context source

1.6 Hands-on

This hands-on introduction explains why the book uses software examples and where readers can find their complete, runnable code.

Key terms: context engineering, context sources, orchestration capabilities, context engineering stack, companion GitHub repository, code listings, full, runnable implementation

1.6.1 Exploring context through an AI assistant interface

This exercise uses an AI assistant interface to explore which aspects of an LLM’s context are visible to users and which remain hidden.

Key terms: AI assistant, context, opaque, sanitized responses

1.6.2 Programmatic access to LLMs

This section shows why context engineering uses programmatic LLM access and how to interpret a simple script’s responses and output signals.

Key terms: application layer, APIs, SDKs, maximum output tokens, temperature, reasoning, basic model, reasoning model, self-report, observability signals

1.6.3 Installing and using a local LLM

Shows how to run an LLM locally with Ollama and uses that exercise to make context visible as inputs passed to a model on each call.

Key terms: local LLM, quantized models, system memory, GPU memory, Ollama, CLI, GUI, local API server, token streaming, prompt and generation token counts

1.7 Summary

Where this is used later

Concepts explained in this chapter

Chapter 2: Instructions for AI agents →

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.