# Core Components of an AI Agent: Understanding the LLM + Context + Tools Architecture

> Discover the core components of an AI agent: LLM, Context, and Tools. Learn how this Agent = LLM + Context + Tools architecture powers intelligent systems.

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

---

**An AI agent consists of three core components: an LLM serving as the reasoning engine, Context providing the working set of information, and Tools enabling action interfaces, collectively expressed as Agent = LLM + Context + Tools.**

The `bojieli/ai-agent-book` defines an AI agent not merely as a language model, but as a unified system where these three elements interact to enable autonomous reasoning and action. This model-centric architecture separates decision-making from execution, allowing developers to build agents that go beyond passive text generation to actively manipulate external systems.

## The Three Core Components

According to Chapter 1 of the book, every AI agent implementation requires these fundamental logical building blocks to function. The repository explicitly maps these to specific architectural responsibilities in [`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md).

### LLM (Large Language Model): The Reasoning Engine

The **LLM** serves as the decision-making core that interprets user intent, plans execution steps, and selects appropriate actions. As implemented in `bojieli/ai-agent-book`, the LLM provides the "policy" that drives the agent's behavior, effectively acting as the brain that determines *what* should happen next based on the current situation【Chapter 1‑11‑18】.

In the source code structure described in [`book-en/chapter8.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter8.md), this component can be fine-tuned or reinforced to improve reasoning capabilities, distinguishing the agent's cognitive architecture from standard chatbot implementations.

### Context: The Working Set of Information

**Context** represents the information available to the agent at each decision point. This includes the system prompt, tool definitions, user messages, prior assistant responses, and tool results. According to the book's definition in [`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md), Context supplies the observations and history the LLM requires to reason effectively, functioning as the agent's working memory and perceptual field【Chapter 1‑37‑45】.

The Context component dynamically assembles the state required for each LLM prediction, ensuring the reasoning engine has access to relevant historical interactions and environmental observations.

### Tools: Action Interfaces

**Tools** are the programmable APIs, scripts, or services that the agent invokes to affect the external world. The book defines these in [`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md) as the mechanism that transforms the agent from a passive text generator into an autonomous system capable of file operations, web searches, code execution, and messaging【Chapter 1‑61‑74】.

As detailed in [`book-en/chapter2.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter2.md), Tools provide the concrete API shapes that define how the agent interacts with external systems, bridging the gap between the LLM's decisions and real-world effects.

## How the Components Interact: The ReAct Loop

The book illustrates how these three components interact through the classic ReAct (Reasoning and Acting) loop pattern. Below is the minimal Python-style implementation from [`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md) that demonstrates this interaction【Chapter 1‑73‑90】:

```python

# ---- Core components -------------------------------------------------

llm = LLM()                     # reasoning engine

tools = {                       # action interfaces

    "search": web_search,
    "read_file": read_file,
    "write_file": write_file,
}
context = Context(               # working set of information

    system_prompt="You are a helpful assistant.",
    tool_definitions=tools,
)

# ---- ReAct loop -------------------------------------------------------

trajectory = [{"role": "user", "content": "Summarize the latest report"}]

while True:
    # Build the full context (static prefix + dynamic trajectory)

    full_context = context.build_prefix() + trajectory

    # LLM decides what to do next

    decision = llm.predict(full_context)

    # Append the LLM's response to the trajectory

    trajectory.append(decision)

    # If the response includes a tool call, execute it

    if decision.get("tool_calls"):
        for call in decision["tool_calls"]:
            result = tools[call["name"]](**call["arguments"])
            # Feed the tool result back into the trajectory

            trajectory.append({"role": "tool", "content": result})
    else:
        # No tool call → final answer reached

        print("Answer:", decision["content"])
        break

```

In this loop, the **Context** builds the prompt prefix, the **LLM** generates the decision, and **Tools** execute the actions—creating a closed feedback system where tool results are fed back into the Context for subsequent reasoning steps.

## The Agent Harness: Engineering Beyond the Core

While the LLM, Context, and Tools form the logical foundation, the book distinguishes a fourth engineering layer called the **Harness**. According to `bojieli/ai-agent-book`, this layer manages context window optimization, tool execution safety, verification logic, error correction, and resource constraints. The Harness wraps the three core components with production-grade reliability features without changing the fundamental architecture.

This separation allows developers to swap LLM providers, modify tool sets, or adjust context strategies while maintaining consistent operational guarantees through the Harness layer.

## Implementation Details in the Source Code

The theoretical framework maps directly to specific files in the repository:

- **[`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md)**: Introduces the three-component formula (Agent = LLM + Context + Tools) and establishes the architectural boundaries【Chapter 1‑11‑18】
- **[`book-en/chapter2.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter2.md)**: Details concrete API implementations for Context construction and Tool definitions, including the ReAct loop implementation patterns
- **[`book-en/chapter8.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter8.md)**: Explores advanced techniques for fine-tuning and reinforcing the LLM reasoning engine component
- **[`book-en/chapter10.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter10.md)**: Discusses scaling strategies for all three components when building larger, more capable agent systems

## Summary

- **Agent = LLM + Context + Tools** is the fundamental formula defined in `bojieli/ai-agent-book` for building AI agents
- The **LLM** functions as the reasoning engine that makes decisions and plans actions
- **Context** provides the working set of information including history, system prompts, and tool definitions required for effective reasoning
- **Tools** are the action interfaces that allow the agent to affect external systems and move from planning to execution
- The **ReAct loop** demonstrates how these components interact in a continuous cycle of observation, reasoning, and action
- The **Harness** provides the engineering infrastructure supporting these core components in production environments

## Frequently Asked Questions

### What distinguishes an AI agent from a standard LLM chatbot?

An AI agent adds **Tools** and managed **Context** to the base LLM capability. While a chatbot only generates text responses, an agent can invoke external APIs, execute code, and modify files through its Tools component, then feed those results back into its Context for further reasoning. According to `bojieli/ai-agent-book`, this闭环 (closed-loop) capability transforms the system from passive responder to autonomous actor.

### How does Context differ from long-term memory in agent architectures?

**Context** refers to the immediate working set of information available to the LLM during a single prediction call—essentially what fits in the current prompt window. While the book mentions that Context includes prior messages and tool results, long-term memory would require external storage systems that compress and retrieve information outside the active Context. The Context component manages what the LLM can *currently* see, not what it *knows* from previous sessions.

### Can an AI agent function without Tools?

Technically yes, but it would lose its agency. As defined in [`book-en/chapter1.md`](https://github.com/bojieli/ai-agent-book/blob/main/book-en/chapter1.md), Tools are what "turn the agent from a passive text generator into an autonomous system." Without Tools, the system relies solely on the LLM's parametric knowledge and cannot verify facts, execute code, or interact with external systems. Such a configuration would be a chatbot rather than an agent in the book's architectural definition.

### What role does the Harness play in the core architecture?

The **Harness** is the engineering layer that manages the operational aspects of the three core components. It handles context window management, tool execution safety, error recovery, and verification logic. While the LLM, Context, and Tools represent the *logical* architecture of what an agent is, the Harness represents the *practical* implementation of how these components operate reliably in production environments, as discussed in the book's systems-oriented chapters.