# How the AI Agent Book Structures Its Curriculum Around the Core Formula Agent = LLM + Context + Tools

> Discover how the AI Agent book structures its curriculum around Agent = LLM + Context + Tools. Learn about building, evaluating, and scaling AI agents.

- Repository: [Bojie Li/ai-agent-book](https://github.com/bojieli/ai-agent-book)
- Tags: architecture
- Published: 2026-08-24

---

**The bojieli/ai-agent-book repository uses the equation Agent = LLM + Context + Tools as its architectural spine, dedicating chapters 1–6 to constructing each component (brain, eyes, hands), chapters 7–9 to evaluating and evolving the assembled system, and chapter 10 to scaling the formula into multi-agent societies.**

The open-source educational repository `bojieli/ai-agent-book` grounds every lesson in a single unifying principle: intelligent agents are the sum of three primitives. This **AI Agent book structure** treats the formula not as a tagline but as a mandatory engineering blueprint that determines chapter ordering, code experiments, and the progression from first principles to production systems.

## The Three Pillars of the Formula

The book adopts a biological metaphor where each term in the equation corresponds to a sensory or cognitive function. According to [`book/introduction.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/introduction.md) at line 29, this "brain, eyes, and hands" model dictates how the curriculum expands from theory to runnable code.

### LLM: The Brain (Chapters 1 & 5)

The **Large Language Model** serves as the reasoning engine. In [`book/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/chapter1.md) at line 13, the text establishes that modern agents require an LLM provider (such as SiliconFlow, Kimi, or OpenRouter) as their fundamental cognitive substrate. Chapter 5 then demonstrates a full-stack *Coding Agent* that relies on the LLM to generate and execute code, proving that the brain alone is insufficient without the supporting pillars.

### Context: The Eyes (Chapters 2 & 3)

**Context** represents everything the model can observe at inference time—prompt history, retrieved knowledge, KV-Cache states, and tool definitions. Chapter 2 (Context Engineering) deep-dives into prompt design, retrieval-augmented generation, and context compression techniques found in [`book/chapter2.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/chapter2.md). Chapter 3 extends this to persistent user memory and external knowledge bases, demonstrating that richer context directly raises the agent’s capability ceiling.

### Tools: The Hands (Chapter 4)

**Tools** are the external capabilities the agent can invoke—search APIs, file I/O, code execution, and computer-use interfaces. As stated in [`chapter4/README.md`](https://github.com/bojieli/ai-agent-book/blob/main/chapter4/README.md) at line 3, "Tools are the Agent’s hands." This chapter details the Model Context Protocol (MCP) and categorizes tools into perception, execution, and collaboration types, providing the concrete implementations that allow the LLM to manipulate the external world.

## Mapping the 10-Chapter Roadmap to the Formula

The repository organizes its ten chapters as a layered expansion of the core equation, moving from construction to evaluation to societal-scale deployment.

**Construction Phase (Chapters 1–6):** These chapters build the agent from the ground up. Chapters 1 and 5 establish the **LLM** configuration (see [`config.py`](https://github.com/bojieli/ai-agent-book/blob/main/config.py) for the central registry of providers and API keys). Chapters 2 and 3 engineer the **Context** pipeline. Chapter 4 installs the **Tools**. Chapter 6 expands both context and tools toward asynchronous, multimodal, and robotic interaction, effectively giving the "eyes" access to audio/video streams and the "hands" control over physical devices.

**Evaluation & Refinement (Chapters 7–9):** Once the three pillars are assembled, the curriculum shifts to measurement and improvement. Chapter 7 introduces evaluation environments and statistical metrics to assess how effectively the LLM, Context, and Tools interact. Chapter 8 covers post-training techniques—supervised fine-tuning (SFT) and reinforcement learning (RL)—to adapt the LLM into a better "brain" for the specific context and toolsets provided. Chapter 9 closes the loop with continual evolution, using execution traces to update knowledge bases, policies, and even tool definitions based on real-world experience.

**Scale (Chapter 10):** The final chapter applies the same formula to multi-agent systems. It describes societies of agents that share context, delegate tools, and co-evolve, proving that even complex multi-agent architectures obey the same Agent = LLM + Context + Tools rule.

## Code Implementation: Materializing the Equation

The repository provides runnable implementations that instantiate the formula directly. The file [`chapter1/context/main.py`](https://github.com/bojieli/ai-agent-book/blob/main/chapter1/context/main.py) contains a `ContextAwareAgent` class that demonstrates the integration of all three components:

```python

# 1️⃣ Create a Context‑Aware Agent (LLM + Context + Tools)

from agent import ContextAwareAgent, ContextMode

agent = ContextAwareAgent(
    api_key="YOUR_API_KEY",          # LLM credential (Brain)

    context_mode=ContextMode.FULL,  # Full context (Eyes + Hands enabled)

    provider="siliconflow",          # LLM provider selection

    model=None                       # Use provider’s default model

)

# 2️⃣ Define a task that needs both context and tools

task = """
Analyze this PDF (https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf):
- Extract all monetary amounts.
- Convert them to USD, EUR and JPY.
- Summarize the total in each currency.
"""

# 3️⃣ Execute – the agent stitches together LLM reasoning, context retrieval,

#    and automatic tool invocation (PDF parser, currency converter)

result = agent.execute_task(task)

# 4️⃣ Inspect the outcome

print("✅ Completed:", result.get("completed"))
print("🛠️ Tool calls:", len(result["trajectory"].tool_calls))
print("🔎 Final answer:", result.get("final_answer"))

```

This snippet demonstrates the **Agent** instantiation combining an **LLM** (via the `provider` parameter), **Context** (via `ContextMode.FULL` and the task description), and **Tools** (automatically invoked during `execute_task`). The trajectory inspection shows the feedback loop—completion status, tool usage metrics, and final answers—that underpins the evaluation methodologies discussed in chapters 7 through 9.

## Summary

- **Architectural Anchor:** The formula Agent = LLM + Context + Tools first appears in [`book/introduction.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/introduction.md) at line 29 and recurs throughout the repository as the mandatory design pattern.
- **Pedagogical Progression:** The AI Agent book structure follows a 10-chapter arc: chapters 1–6 construct the three pillars, chapters 7–9 measure and refine their interaction, and chapter 10 scales the equation to multi-agent societies.
- **Concrete Implementation:** The `ContextAwareAgent` class in [`chapter1/context/main.py`](https://github.com/bojieli/ai-agent-book/blob/main/chapter1/context/main.py) provides a working instantiation of the formula, binding the LLM provider, context mode, and tool invocation into a single executable pipeline.
- **File Locations:** Core logic resides in [`book/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/chapter1.md) (LLM theory), [`book/chapter2.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/chapter2.md) (Context engineering), [`chapter4/README.md`](https://github.com/bojieli/ai-agent-book/blob/main/chapter4/README.md) (Tools), and [`config.py`](https://github.com/bojieli/ai-agent-book/blob/main/config.py) (provider configuration).

## Frequently Asked Questions

### Where is the core formula Agent = LLM + Context + Tools defined in the repository?

The formula first appears in [`book/introduction.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/introduction.md) at line 29, where it is introduced alongside the "brain, eyes, hands" metaphor. It is reiterated and expanded in [`book/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book/chapter1.md) at line 13 as the foundational equation for modern agent design.

### Which chapters explain the Context component in detail?

Chapter 2 (Context Engineering) covers prompt design, KV-Cache optimization, and retrieval-augmented generation, while Chapter 3 focuses on persistent user memory and external knowledge bases. Both chapters elaborate on the **Context** pillar referenced in the core formula.

### How does the book implement the Tools pillar in code?

Chapter 4 details the **Tools** implementation, specifically citing the Model Context Protocol (MCP) and categorizing tools into perception, execution, and collaboration types. The accompanying code in the `chapter4/` directory provides concrete tool definitions that agents can invoke as their "hands."

### Can I see a working example that combines all three formula components?

Yes. The file [`chapter1/context/main.py`](https://github.com/bojieli/ai-agent-book/blob/main/chapter1/context/main.py) contains a complete, runnable `ContextAwareAgent` that accepts an LLM provider (brain), manages conversation history and retrieved documents via `ContextMode` (eyes), and automatically invokes external APIs and parsers (hands) during task execution.