[KongchangAI]
· 3 min read· 1,607 words

AI Agent's Four-Layer Architecture Explained: How LLM + Harness Can Replace Your Work

AI Agent's Four-Layer Architecture Explained: How LLM + Harness Can Replace Your Work

An Agent consists of an LLM brain and a Harness body; its four-layer architecture lets it complete tasks autonomously.

Based on a video by Bilibili creator Hua Lun, the article explains why Agents can turn AI from a chat tool into a productivity tool. The core formula is Agent = LLM + Harness: the large model does the thinking but has three flaws—it can't act, its knowledge has a cutoff, and its memory is poor—so it needs the Harness body to read/write, call tools, retry, and remember. The criterion distinguishing chat from an Agent is "who decides the next step," and autonomous progress relies on the ReAct Loop. The Harness is divided into four layers: orchestration advances tasks and decides when to stop; memory assembles each round's information package and manages long-term memory; tools prepare callable tools and the execution environment; permissions define what can be used and recommend sandbox isolation. Finally, it offers troubleshooting methods for four types of problems: task breakdown, context compression, adding tools, and adjusting permissions.

From Chat Tool to Productivity Tool: The Evolution of Agents

In a video, Bilibili creator Hua Lun pointed out that Agents are turning AI from a chat-based search tool into a true productivity tool. From ordering takeout to making money automatically 24/7, Agents can amplify or even replace your work. NVIDIA has launched an AI computer designed specifically for Agents, and more and more software is opening up interfaces so AI can do things for us directly. So what exactly is an Agent? Why can it complete tasks autonomously?

AI Agent concept illustration

The Core Formula: Agent = LLM + Harness

To understand an Agent, start with a common formula: Agent = LLM + Harness. The LLM (large language model) is the thinking brain behind it, such as the model behind Doubao. It knows everything, but has three drawbacks:

  • It can only answer, not act: it cannot directly do things for you.
  • Its knowledge has a cutoff date: it knows nothing about events after that point, and its information may be inaccurate.
  • Its memory is poor: it forgets easily when there is too much information, and opening a new chat window makes it forget everything before.

To make up for these shortcomings, we give the brain a "body" — the Harness. This body lets the Agent read and write on its own, call tools, retry after failures, search for the latest information, and have memory.

But a body alone is not enough — it also needs space to operate: a computer. The computer's configuration determines how many tools the Agent can dispatch, whether locally or in the cloud.

Agent needs space to operate

LLM (large language model) is a neural network trained on massive amounts of text, whose core capability is predicting the next token based on the preceding context to generate coherent text. Through "pretraining + instruction fine-tuning + alignment," it acquires question answering, reasoning, summarization, and other abilities, but it remains essentially a stateless text generator: each call is an independent computation that retains no memory across turns and cannot directly operate on the external world. The so-called "knowledge cutoff date" means the training data only covers up to a certain point in time, and later events are not in the parameters. Understanding this makes it clear why a Harness is needed to supply memory, tool calling, and execution capabilities.

The Key Difference: Who Decides the Next Step?

With an ordinary large model, you ask a question and it answers; when you ask it to write a weekly report, it only gives you text, and you still have to copy, format, and send it to your boss yourself. An Agent is different: you just say "organize this week's materials into a weekly report and put it on the desktop," and it finds the files, reads them, writes the report, saves it, and tries other methods if it fails. This whole process is called the ReAct Loop in the industry.

Judgment criterion: if you decide the next step, it's chat; if it decides by itself, it's an Agent.

ReAct Loop comes from the 2022 paper "ReAct: Synergizing Reasoning and Acting in Language Models," whose core idea is to have the model alternate between "Reasoning" and "Acting." In each round, the model first outputs a piece of reasoning explaining what should be done now, then outputs a tool-call instruction; the Harness executes the tool and feeds the result back to the model as a new observation, and the model continues reasoning on that basis until it judges the task complete or a stopping condition is triggered. This loop of "think one step, act one step, look at the result" is exactly the mechanism that lets an Agent advance tasks autonomously and retry with different methods after failure.

The Harness Four-Layer Architecture: A Beginner's Guide

There is currently no universally accepted unified architecture for the Harness; each Agent has its own design. For easier understanding, Hua Lun divides it into four layers that cover all Agents on the market.

Layer 1: Orchestration Layer — Managing How Things Progress

The orchestration layer handles two things: first, advancing the task, executing according to the brain's instructions and deciding whether to split it into subtasks run serially or in parallel, which tools to use next, and when to ask the brain again; second, when to stop, stopping only when done, and also stopping after multiple retries on errors, to avoid spinning idly. This is the loop mentioned earlier.

Layer 2: Memory Layer — Managing What the Brain Sees Each Round

The brain itself has no memory; each time a message is sent, the system packs the previous chat history together with the new message and sends it to it again. So each round the brain can only see that round's "information package." This package includes not only the chat history but also the rules you set, the Agent's built-in rules, available tools, methods tried before and their results, new tasks, and so on. The package has limited capacity, so after long conversations it must be compressed or summarized, otherwise the Agent will forget things too.

Content that needs to be remembered across conversations (such as your name, usage habits, and rules) can be stored separately as long-term memory and placed into the package in the next conversation.

The information package concept of the memory layer

The large model's context window refers to the maximum number of tokens it can receive in a single call, commonly ranging from tens of thousands to millions. Content beyond the window is truncated and becomes "invisible" to the model. Therefore, the memory layer must carefully assemble the "information package" within the window capacity: prioritizing information relevant to the current task, and summarizing historical conversations or recalling them via vector retrieval. Long-term memory is usually implemented with external storage (such as a vector database or key-value store), retrieved as needed and spliced into the context, so that the Agent can remember user preferences and rules across sessions without expanding the window.

Layer 3: Tool Layer — Managing What You Have on Hand

The brain doesn't act; it only says "which tool I want to use and what to do with it." What actually executes is the Harness program on the local computer. So tools must be prepared in advance: search, file reading and writing, computer control, and so on. Tools can be built yourself, borrowed from others, or connected externally.

The execution environment (i.e., which computer does the work) determines which tool capabilities the Agent can actually realize — what software is installed, what accounts are logged in, whether it can connect, and so on.

Layer 4: Permission Layer — Managing What Is Approved for Use

Once the tools are ready, they can't be used freely. Just as mobile apps pop up a prompt when they want to use your photo album or location, the Agent also needs rules on which tools can be used directly, which files can be read, and which actions involving payment or sending messages externally must stop and ask you. Permissions vary from person to person; beginners are advised not to grant too-high permissions, especially on the computer they use regularly. You can run the Agent on a cloud computer or in a local sandbox, which is like locking it in a small cage so that problems won't affect the main computer's data.

Sandbox is an isolated runtime environment that, by restricting access to the file system, network, and system calls, confines a program's operable surface within preset boundaries. Common implementations include containers (such as Docker), virtual machines, and OS-level sandboxes. When an Agent executes code or calls tools in a sandbox, even if it is induced to perform dangerous operations, the impact is confined inside the sandbox and will not affect the main computer's data. A cloud computer is essentially an independent instance allocated to each Agent, likewise providing isolation and rollback.

Common Troubleshooting Guide

Once you understand the four layers, you can pinpoint problems when they arise:

  • The task keeps getting revised and is never satisfactory: most likely the task is too big or the completion criteria are unclear. Break down the task, clarify the completion conditions, and set when to stop and ask you.
  • After a long conversation, the Agent forgets earlier things: the conversation is too long and the information package is too full, or the materials are cluttered. Compress the context or start a new context; ideally, one context should solve only one thing.
  • The Agent says it can't do it or execution fails: usually a missing tool. First ask whether it lacks a tool, check whether one is available on the computer, and if not, have it find an external tool to connect.
  • The Agent keeps popping up to ask you, or finishes on its own without asking: a permission setting issue. Set permissions as needed; beginners should understand each step's permissions first and then gradually open them up.

Task breakdown and permission settings

Summary: The Large Model Thinks, the Harness Acts

In one sentence: the large model is responsible for thinking, and the Harness is responsible for doing. There are many Agents on the market; how do you choose the right one to start learning with? Hua Lun said that each future video will explain and popularize Agent-related topics, so those interested can follow along.

For beginners, understanding this four-layer architecture makes it clear what the Agent is doing at each step and where problems come from, so you can hand over tasks to it with more confidence.

#AI Agent#LLM#Harness#ReAct Loop#four-layer architecture#context window#sandbox#permissions
Share:

Related articles