25年3月重磅--聊聊OpenManus
写在开始:
①本文仅仅用作个人记录学习使用,如何涉及版权等其他问题,辛苦及时联系小编修改或者下架,全文预计4200字左右,阅读时间14min;
②Manus引发轰动:2025年标志着AI Agent时代的开启,3月份科技圈再次迎来了一个不眠之夜,继DeepSeek引起轰动之后,一款名为Manus的AI Agent工具,又一次见证了历史。
③主要分为五个部分,开头总结,第一到四部分架构+流程分析+prompt+测试,最后第五部分openManus启动体验;
总结
OpenManus 是一个基于 Python 实现的智能代理框架,专注于构建自动化、通用型的 AI Agent 系统。它提供了完整的任务自动化、工具集成与调用,以及多步骤规划与执行能力,使各垂直领域能够基于此框架快速构建专业化的 Agent 应用(如 AI 编程助手、数据分析师等)。
- Single Agent: 以 main.py 为入口,OpenManus 实现了基于 ReAct(Reasoning and Acting)模式的单代理框架`
执行流程:接收用户输入 → 循环执行 Think & Act → 生成最终结果
核心优势:简单直观,适合单一领域的专业任务
实现机制:通过 run → step →think → act 循环实现任务的分步处理
- Multi-Agent:通过 Flow 系统实现了基于规划-执行模式的多代理协作框架:
设计理念:与现代可视化 Agent 工作流工具(如 Dify、图灵、LangFlow、阿里百炼)相似
关键差异:执行流程不是人工设计的"工作流",而是由 Planning Agent 自主生成的"计划"
动态特性:生成的计划可根据执行结果动态调整,具有更强的适应性
工作流程: Flow 初始化->计划生成->执行->内存管理
- 能力评估:从能力来看,整个框架设计从工程上看是很好的,扩展性强,模块定义清晰,后续扩展会比较轻松。但效果的提升还是主要依靠如下几个方面:
『大模型本身的能力』:Planning Agent产出的计划、Tool
Agent自主选择工具等都依托于大模型本身的能力,基座大模型越强,效果越好。一个思考是这里Planning
Agent或许可以考虑用推理类模型,例如Deep Seek R1『工具丰富度』工具,也即Tool 越丰富,理论上其能力就会越强,但选择工具、分析工具返回内容的能力依旧是依托于大模型本身的能力
『上下文』会将用户输入内容、系统提示信息(System
Prompt)、LLM响应、工具执行结果等全部追加到上下文中,如果内容超长会截断。这里的处理还是比较粗暴的
一、架构
Prompt
系统提示词 (System Prompt):定义 Agent 的身份、能力和行为准则
下一步提示词 (Next Step Prompt):指导 Agent 如何选择和使用工具
Agent
BaseAgent
ReActAgent
ToolCallAgent
Manus
PlanningAgent
Flow
任务规划分解到Agent来协调;然后执行流程控制,上下文管理
二、流程分析
它分为2个启动命令,一个是Single Agent(main),一个是Multi-Agent(run_flow);简单分析第一个;
2.1 模块拆解
OpenManus 由六个主要模块组成,每个模块负责特定的功能。与Single Agent的核心区别在于多了一个Flow系统,另外包含多Agent:
- Flow 系统:负责整体工作流程的协调和管理
- Agent 系统:实现智能代理的核心逻辑和行为
- 内存系统:管理上下文和对话历史
- LLM 服务层:与大语言模型 API 交互
- 工具系统:提供各种功能工具的集合
- 执行系统:实现 ReAct 循环的执行逻辑
2.1 执行过程
- 开始:run_flow 入口,Flow 实例化,创建 PlanningAgent 和 Manus Agent
- 规划Plan:PlanningAgent 用 PlanningTool 建任务Plan
- 执行do:Manus Agent执行任务,run方法循环调用step(think and act)
- (Think & Act):拿历史记录,LLM决策,act执行,继续下一轮思考
- done:Flow整合结果进行响应
2.3 数据流转
- 用户消息:从入口点输入,存入内存系统
- 助手消息:由 LLM 生成,包含思考过程和工具调用
- 工具结果:工具执行的原始输出
- 工具消息:格式化的工具结果,存入内存系统
三、Prompt
Manus Prompt
SYSTEM_PROMPT = "You are OpenManus, an all-capable AI assistant, aimed at solving any task presented by the user. You have various tools at your disposal that you can call upon to efficiently complete complex requests. Whether it's programming, information retrieval, file processing, or web browsing, you can handle it all."
NEXT_STEP_PROMPT = """You can interact with the computer using PythonExecute, save important content and information files through FileSaver, open browsers with BrowserUseTool, and retrieve information using GoogleSearch.
PythonExecute: Execute Python code to interact with the computer system, data processing, automation tasks, etc.
FileSaver: Save files locally, such as txt, py, html, etc.
BrowserUseTool: Open, browse, and use web browsers.If you open a local HTML file, you must provide the absolute path to the file.
GoogleSearch: Perform web information retrieval
Based on user needs, proactively select the most appropriate tool or combination of tools. For complex tasks, you can break down the problem and use different tools step by step to solve it. After using each tool, clearly explain the execution results and suggest the next steps.
"""
还有其他不列举了
四、测试
核心逻辑:先think-思考,再act-执行,整个step是一个有限循环里,不断执行
think的逻辑是调用大模型接口(llm.ask_tool),返回tool_calls
act的逻辑就是执行工具,以google search为例,query是大模型根据提示词生成的查询内容
五、openManus启动体验
Manus最近有点火,刚好github上有了相似的开源项目,火速体验一下······
步骤
第一步:打开openManus仓库,并clone一下代码地址:
https://github.com/mannaandpoem/OpenManus
第二步:打开Idea工具,拷贝一下项目
第三步:个人用户的appId,这个不方便说;
去DeepSeek官网创建api_key:https://platform.deepseek.com/api_keys,网络上有人这样提示,我目前不是用这个方法,只是给大家建议
第四步:在idea修改config.toml文件的密钥等信息如下
# Global LLM configuration
[llm]
model = "gpt-4o-2024-11-20"
base_url = "https://aigc.sankuai.com/v1/openai/native"
api_key = "这里需修改为你的个人用户的appId"
max_tokens = 4096
temperature = 0.0
# Optional configuration for specific LLM models
[llm.vision]
model = "gpt-4o-2024-11-20"
base_url = "https://aigc.sankuai.com/v1/openai/native"
api_key = "这里需修改为你的个人用户的appId"
第五步:部分idea环境依赖的升级,比如python3.11 及以上
第六步:terminal输入启动命令: python3.11 main.py
(这个项目有两种启动模式:main.py(简单任务)、run_flow.py(复杂任务) ,默认main.py即可)
响应如图
**效果检验:**输入中文:查询上海天气预报
响应分析:唤醒浏览器,然后查询天气预报
终端也有天气响应
以上 完结 撒花!
写在最后 : 码字不易,如果觉得还不错,或者对您有帮助,麻烦动动小手,点赞或关注,谢谢!