一个简单的基于ReAct模式的AI Agent
> 本项目由 [MarkTechStation/VideoCode](https://github.com/MarkTechStation/VideoCode/tree/main/Agent%E7%9A%84%E6%A6%82%E5%BF%B5%E3%80%81%E5%8E%9F%E7%90%86%E4%B8%8E%E6%9E%84%E5%BB%BA%E6%A8%A1%E5%BC%8F) 中的示例转换而来。想进一步学习可前往作者主页(各平台链接见 [该仓库 README](https://github.com/MarkTechStation/VideoCode/blob/main/README.md))。
## 概述
MzAgent 是一个基于 ReAct (Reasoning + Acting) 模式的 AI Agent,通过调用大语言模型来分解和执行用户任务。

## 核心组件
### 1. TReActAgent 类
- 负责与 LLM API 通信
- 管理对话消息历史
- 解析模型输出并执行工具
### 2. TToolList + TBaseTool
- 工具管理器
- 提供三个内置工具:
- `read_file` - 读取文件
- `write_to_file` - 写入文件
- `run_terminal_command` - 执行终端命令
### 3. PromptTemplate
- 系统提示词模板
- 定义了 Agent 的行为规范和输出格式
## 工作流程
```
用户输入任务
│
▼
┌─────────────────────────────────────────┐
│ 1. 初始化
│ - 添加 system prompt
│ - 添加 user question
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 2. 调用 LLM API
│ - 发送消息历史到 API
│ - 接收模型响应
└─────────────────────────────────────────┘
│
▼
│
├─► 提取 <thought> 思考内容
│ (记录日志)
│
├─► 提取 <final_answer> 最终答案
│ (是 → 返回答案,流程结束)
│
└─► 提取 <action> 工具调用
(否 → 继续)
│
▼
┌─────────────────────────────────────────┐
│ 3. 解析 Action
│ - 解析函数名和参数
│ - 查找对应工具
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 4. 执行工具
│ - 调用工具的 Execute 方法
│ - 获取执行结果
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 5. 添加 Observation
│ - 将工具执行结果添加到消息历史
│ - 回到步骤 2 继续循环
└─────────────────────────────────────────┘
```
## 详细流程说明
### 第一步:初始化
```pascal
AddMessage('system', RenderSystemPrompt);
AddMessage('user', '<question>' + UserInput + '</question>');
```
### 第二步:循环调用模型
```pascal
while True do
begin
Content := CallModel; // 调用 API
// 提取各种标签
Thought := ExtractTagContent(Content, 'thought');
Action := ExtractTagContent(Content, 'action');
// 检查是否有最终答案
if PHAL 分层混合模型工作流 — 强模型(Claude)负责理解/拆解/验收,低成本模型(DeepSeek)负责检索/提取/清洗。Hermes Agent skill。
An LLM agent fine-tuned on DeepSeek for spaced repetition, dynamically integrating knowledge points based on the Ebbinghaus forgetting curve.
基于 STM32F103 构建的端到端 AI 智能手表生态。自研“零重定位”原生机器码动态加载引擎与页面栈式 UI 框架;集成生产级 OTA 回滚保护机制与高带宽(921600 baud)串口协议栈。通过 Node.js 中继实现 DeepSeek AI 语义控制及 ASRPRO 语音全双工交互,是一个集成了分布式计算、现代存储管理与 AI Agent 的嵌入式全栈工程。
A Meta-Agent-Driven Self-Evolving Multi-Agent System for UAV Detection and Tracking
One command to run Hermes AI Agent with a browser UI. Zero prerequisites. 一行命令,AI 就位。
网页应用Agent,接入DeepSeek、Mimo等模型