AI Agent Core Components
AI Agent Core Components
Why can an AI Agent understand tasks, call tools, and continue working based on execution results? The key lies in its internal modules such as models, tools, memory, and planning, as well as the execution logic responsible for organizing these modules.
For example, if you ask an Agent to "read Excel sales data, generate statistical charts, and save the report," the entire process may involve:
- Understanding the user's task requirements and determining the files that need to be processed.
- Reading the Excel data and identifying the table structure.
- Planning the analysis steps and determining the metrics that need to be calculated.
- Calling tools like Python to process data and generate charts.
- Check the execution results, save the report, and return the file location.
These operations are not entirely performed directly by the large language model, but are achieved through the collaboration of the model, external tools, and execution programs.
Understanding the core components of an AI Agent helps us further understand how Agents work and how to develop our own Agent applications.

Overall Architecture of AI Agent
From a functional perspective, a typical LLM Agent can be divided into the following parts:
| Components | Main Responsibilities |
|---|---|
| Perception | Receives user input, environment information, and tool return results. |
| Model (LLM) | Understands the task, analyzes information, and decides the next step. |
| Tools | Executes tasks such as searching, file operations, code execution, and API calls. |
| Memory | Stores conversation context, task status, and information that needs long-term use. |
| Planning | Decompose complex tasks, determine execution steps, and adjust the plan based on the results. |

It should be noted that these five parts are a functional division for easier understanding and do not mean that all Agents must adopt the same architecture.
Simple Agents may only require a large language model and several tools; complex Agents may incorporate capabilities such as long-term memory, task scheduling, multi-Agent collaboration, and runtime state management.
1. Perception
Perception is responsible for receiving the information that the Agent needs to process while executing a task, including user input, file content, external data, and tool return results.
For traditional text Agents, the input is usually text; for multimodal Agents, the input can also include images, audio, video, and other content.
Common input types include:
- **Text:** User instructions, chat history, documents, and program code.
- **Images:** Screenshots, photos, design drafts, etc.
- **Speech:** User voice commands or audio content.
- **Structured Data:** JSON, CSV, database query results, etc.
- **Environmental Information:** Browser page, file directory, software running status, etc.
- **Tool Results:** Search results, code execution output, API responses, and error messages.
For example, when a browser Agent executes "open webpage and fill form," it may need to read the webpage DOM structure or page screenshots, determine the position of input fields and buttons, and then decide the next step.
Different Agents obtain environmental information in different ways. Some obtain structured data via APIs, while others interact with software through screenshots and computer operation tools.
The information perceived is organized into context that the model can process for subsequent reasoning and decision-making.
2. Models (LLM)
Large Language Models (LLM) are usually the core reasoning component of an Agent, primarily responsible for understanding tasks, analyzing context, and deciding the next action to take.
Common models include GPT, Claude, DeepSeek, Qwen, and other series models.
In an Agent system, the model mainly performs the following tasks:
- **Task Understanding:** Identifying what the user wants to achieve and what constraints the task has.
- **Information Analysis:** Making judgments by synthesizing the current context, history, and tool return results.
- **Action Selection:** Determining whether to answer directly or call an external tool.
- **Parameter Generation:** Generating the parameters required for calling based on the tool definition.
- Process feedback: read the execution result and determine if further operations are needed.
How does the model decide to call a tool?
For example, the user requests:
Check tomorrow's weather in Beijing, and remind me to bring an umbrella if it rains.
The model can identify that the task involves two steps: first, obtaining the weather forecast, and then deciding whether to generate a reminder based on the weather.
However, the model itself cannot obtain reliable real-time weather data out of thin air; it needs to call a weather query tool.
The model generates a call request based on the tool's name, parameter description, and the current task, and the Agent's execution program performs the actual call.
After the tool returns the weather data, the model decides on subsequent operations based on the result.
Therefore, the model is mainly responsible for judging and generating invocation instructions; the actual operation is performed by external programs or tools.
**Note:** The model's capabilities affect the Agent's task understanding and decision quality, but the Agent's actual performance is also related to factors such as tool quality, system prompts, execution environment, permission control, and result verification mechanisms.
3. Tools
Tools are an important way for the Agent to interact with the external environment.
Large language models are good at understanding and generating content, but actual work often involves accessing files, querying databases, running programs, or operating other software, all of which require external tools.
For example, if an Agent needs to analyze an Excel file, it needs file reading and data processing capabilities; to send an email, it needs to be able to access the corresponding mail service.
Common tools can be divided into the following categories:
| Tool Types | Common Tools | Purpose |
|---|---|---|
| Information Retrieval | Search engine, web reading, database query | Obtaining external information and business data |
| Code Execution | Python, Shell, code sandbox | Data analysis, computation, and program execution |
| File Processing | File Reading, File Writing, Document Parsing | Document Organization, Table Processing, and File Generation |
| Content Generation | Image Generation, Speech Synthesis, and Document Generation | Generating Images, Audio, and Other Files |
| System Interaction | API, Email, Calendar, and Browser Operations | Interacting with external applications and business systems |
Function Calling
Function Calling is a common way for Agents to call external tools.
Developers first define the tool's name, functionality, and required parameters; the model selects the appropriate tool based on the user's task and generates structured calling parameters.
For example, a developer defines a weather query tool:
Original prompt (Chinese, left untranslated)
{
"name": "get_weather",
"description": "查询指定城市的天气",
"parameters": {
"city": "string",
"date": "string"
}
}
When the user requests the weather for Beijing tomorrow, the model might generate tool calling parameters similar to the following:
Original prompt (Chinese, left untranslated)
{
"city": "北京",
"date": "2026-10-11"
}
The dates above are for demonstration only. In actual applications, the query date should be calculated based on the current date and the user's timezone.
After the Agent's execution program receives the call request, it calls the corresponding weather API and returns the query results to the model.
The entire process can be summarized as follows:
Original prompt (Chinese, left untranslated)
用户提出任务
↓
模型选择工具
↓
生成调用参数
↓
程序执行工具
↓
返回执行结果
↓
模型继续处理
It should be noted that a model generation tool call request does not mean that the tool has been executed successfully. Actual execution, permission checking, exception handling, and result return are usually handled by the Agent's runtime environment.
In addition to Function Calling, developers can also integrate external tools and data sources through methods such as MCP (Model Context Protocol).
4. Memory
When an Agent performs a task, it needs to retain a certain amount of context information to know at which step the current task is and what results the previous operations yielded.
This mechanism for saving and using information is generally called Memory.
Depending on the storage time and purpose, memory can be divided into the following categories.
Short-term memory
Short-term memory primarily saves information about the current conversation and the task being executed.
For example, if the user first says "Help me analyze this Excel file" and then says "Generate a bar chart from the results," the Agent needs to combine the previous context to know which data the second instruction refers to.
Short-term memory usually relies on the model's context window or session state maintained by the application.
Because the model context window has a length limit, long-running Agents may need to truncate, summarize, or store historical information externally.
Long-term memory
Long-term memory is used to save information that needs to be used across sessions, such as user preferences, historical task records, and project materials.
Common implementation methods include:
- Using a database to save user preferences and history.
- Use files to save task execution results and project status.
- Use a vector database to store information that can be semantically retrieved.
- Read relevant historical content when needed through the retrieval mechanism.
Long-term memory does not necessarily require a vector database. For structured data such as user configurations and task statuses, a standard relational database or key-value database is often more direct.
Episodic Memory and Semantic Memory
In some Agent designs, memory content is further categorized:
- **Episodic Memory:** Stores past tasks executed, operational processes, and results.
- **Semantic Memory:** Stores facts, concepts, rules, and other knowledge information.
For example, recording "which parameters were used when generating the last report" belongs to task experience, while saving "the project uses a PostgreSQL database" belongs to project knowledge.
These classifications are mainly used to help developers design memory systems, and do not mean that all Agents must implement independent memory modules.
RAG and Agent Memory
RAG (Retrieval-Augmented Generation) is a technique that retrieves relevant content from external data sources before the model generates an answer, and then generates the answer based on the retrieved results.
RAG is often used to allow Agents to query internal documents, knowledge bases, historical data, and other information.
For example, if a user asks "What is the company's reimbursement policy?", the Agent can first search for relevant documents in the enterprise knowledge base and then answer based on the retrieved content.
A typical RAG workflow is as follows:
Original prompt (Chinese, left untranslated)
用户提问
↓
查询知识库
↓
检索相关内容
↓
将内容加入模型上下文
↓
生成回答
RAG can be implemented through vector retrieval, keyword retrieval, or hybrid retrieval, and is not limited to vector databases.
Note: RAG is not equivalent to an Agent's long-term memory. RAG mainly solves the problem of external information retrieval and utilization, while long-term memory also involves information storage, updating, expiration management, and cross-task usage.
In actual development, RAG can serve as a way for an Agent to access long-term knowledge or historical information.
5. Planning
Planning is responsible for transforming the task proposed by the user into executable operational steps.
For simple tasks, such as "query today's weather," the Agent might only need to call a tool once.
For complex tasks, such as "generate a competitor analysis report," multiple steps are usually required to complete it.
For example:
- Determine the product to be analyzed and the comparison metrics.
- Look up product pricing, features, and technical documentation.
- Organize the differences between various products.
- Generate comparison tables and analysis content.
- Check citation sources and final results.
An Agent can generate a complete plan first, or decide on the next step incrementally during execution.
Common reasoning and planning methods
In Agent development, concepts such as CoT, ReAct, ToT, and Reflection are often seen.
These methods focus on different aspects; some are used to organize model reasoning, some are used to combine tool execution, and others are used to check and correct results.
| Method | Basic idea | Applicable scenarios |
|---|---|---|
| CoT | Chain-of-Thought, decomposing complex problems into intermediate reasoning steps | Mathematical, logical, and complex problem analysis |
| ReAct | Combining reasoning with tool operation to continue decision-making based on execution results | Search, tool calling, multi-step tasks |
| ToT | Tree of Thoughts, exploring and evaluating multiple candidate reasoning paths | Solving complex problems, exploring solutions |
| Reflection | Checking and correcting existing results based on feedback | Code modification, content checking, task optimization |
Note that CoT, ToT, ReAct, and Reflection are not at the same level of technology, nor do they necessarily need to be used simultaneously.
In actual development, the appropriate method should be chosen based on task complexity, avoiding the design of overly complex execution flows for simple tasks.
ReAct execution example
Assume the user requests: "Check tomorrow's weather in Beijing, and send a reminder if it rains."
The Agent can execute according to the following process:
- Analyze the task and determine that weather must be queried first.
- Call the weather API to get forecast data.
- Read the weather query results.
- Determine if the rainy condition is met.
- If the conditions are met and sending permissions are available, call the message tool to send a reminder.
- Check the execution result of the message tool and provide feedback to the user.
If the weather API returns an error, the Agent can re-query within the allowed retry range or prompt the user that the query failed.
This method of adjusting subsequent operations based on tool feedback is a key characteristic of the ReAct pattern.
6. Agent Loop
Perception, model, tools, memory, and planning are not independent of each other. Agents usually need an execution loop to connect these capabilities.
This execution loop is commonly called the Agent Loop.
Its basic process can be summarized as follows:
Original prompt (Chinese, left untranslated)
接收任务
↓
分析当前状态
↓
决定下一步操作
↓
调用工具
↓
获取执行结果
↓
判断任务是否完成
↓
未完成则继续执行
↓
完成后输出结果
For example, after a programming Agent receives the task "Fix the login error in the project," it might sequentially perform:
- Read the relevant source code.
- Analyze the cause of the error.
- Modify the code file.
- Execute automated tests.
- Decide whether to continue modifying based on the test results.
- After the tests pass, organize the modifications and return the result.
If the tests fail, the Agent can read the error message, re-analyze, and modify the code again.
However, this feedback mechanism does not mean that the Agent can solve all problems on its own. Complex errors may require human intervention.
When does the Agent Loop end?
The Agent should not loop infinitely. In actual development, reasonable termination conditions need to be set.
Common termination conditions include:
- **Task completion:** The goal requested by the user has been achieved.
- **Execution limit reached:** Exceeding the maximum number of execution steps, running time, or calling budget.
- **Execution failure:** Encountering an unrecoverable error.
- **Human confirmation required:** Certain operations require user approval to proceed.
- User manually stops: The user cancels the current task.
In addition, permission checks, error retries, and result verification mechanisms should be set according to the task type to prevent the Agent from repeatedly executing erroneous operations.
A complete Agent execution example
Previously, we introduced the various components of the Agent. Next, we will understand how these components work together through a complete instance.
Assume the user submits the following task:
Check the weather in Beijing for tomorrow for me, and if it is raining, send a reminder with an umbrella to Xiao Wang.
The entire task can be divided into the following stages:
| Stage | Execution content |
|---|---|
| Perception | Receives user instructions, identifies city, date, weather conditions, and recipient. |
| Model | Understands the task goal, determines whether to query the weather and send a message. |
| Planning | Determines to query the weather first, then decide whether to send a reminder. |
| Tools | Call the weather query API to get the weather forecast. |
| Memory and state | Retain task requirements and query results, and read contact information from the authorized address book as needed. |
| Tools | When the rainy condition is met, call the messaging tool to send a reminder. |
| Result checking | Determine whether the sending was successful based on the return status of the messaging tool. |

This example includes the basic workflow of an Agent: understanding the task, planning operations, calling tools, getting feedback, and deciding whether to continue execution based on the results.
In practical applications, it is also necessary to consider whether the contact exists, whether the messaging tool has sending permissions, and whether the weather query was successful.
For operations such as sending messages externally, a user confirmation step can be added before execution based on the application's security requirements.
Summary
An AI Agent does not complete all tasks relying solely on a large language model, but rather completes tasks through the joint action of the model, tools, memory, planning, and execution control logic.
From a development perspective, each part can be simply understood as:
- **Perception:** Obtaining task and environmental information.
- **Model:** Understanding information and determining the next action.
- **Tools:** Executing specific operations and interacting with external systems.
- **Memory:** Manages task status, context, and historical information.
- **Planning:** Organizes execution steps and adjusts tasks based on feedback.
The Agent Loop is responsible for organizing these components, enabling the Agent to execute continuously until the task is completed or other termination conditions are met.
If you are only developing a simple Agent, you can start withLarge Language Model + Tool Calling + Execution Loopand then add long-term memory, complex planning, and other capabilities based on actual needs.
When designing an Agent, besides focusing on what the model can do, you also need to consider whether the tools are reliable, if the permissions are reasonable, and how to determine if the task is truly complete. These factors directly affect the Agent's stability and security in real-world projects.
Related materials: