文章目录
- Manus技术原理剖析
-
- Manus提示词拆解
- [agent loop](#agent loop)
- [System capabilities](#System capabilities)
- [modules 模块架构](#modules 模块架构)
- [browser use](#browser use)
- 开源平替方案
- REF
2025年3月初,号称首个通用性智能体的Manus发布,让agent作为7/24小时自动打工人的多个场景随即在社交媒体上引发热议,内测邀请码一时洛阳纸贵,被炒制数万元,同时带动了150多只AI智能体概念股涨停。
据媒体披露,Manus背后的母公司蝴蝶效应的投资方包括真格基金、腾讯等。爆火之后,Manus的资源也是好起来了。不到两周的时间,Manus团队很快与阿里通义千问团队正式达成战略合作,双方将基于通义千问系列开源模型,在国产模型和算力平台上实现Manus的全部功能。
Manus技术原理剖析
Manus提示词拆解
有热心网友hack出了manus的提示词,并发布在X上。
manus提示词地址:
https://gist.github.com/jlia0/db0a9695b3ca7609c9b1a08dcbf872c9
对此Manus联创Yichao 'Peak' Ji也在X上回复了,基本认可了这份提示词。同时还提到,Manus使用了开源项目browser_use,没有用热门的MCP。
agent loop
manus的提示词中设置manus agent按照agent loop的模式工作,即迭代的完成复杂任务,依据分析事件、选择工具、等待执行、迭代执行(直到任务完成)、提交结果和退出待机 的步骤运行。
总结agent loop的提示词如下:
py
You operate in an agent loop, iteratively completing tasks through these steps:
1. Analyze Events: Understand user needs and current state through event stream, focusing on latest user messages and execution results
2. Select Tools: Choose next tool call based on current state, task planning, relevant knowledge and available data APIs
3. Wait for Execution: Selected tool action will be executed by sandbox environment with new observations added to event stream
4. Iterate: Choose only one tool call per iteration, patiently repeat above steps until task completion
5. Submit Results: Send results to user via message tools, providing deliverables and related files as message attachments
6. Enter Standby: Enter idle state when all tasks are completed or user explicitly requests to stop, and wait for new tasks
System capabilities
manus系统的能力概括如下:
py
System capabilities:
- Communicate with users through message tools
- Access a Linux sandbox environment with internet connection
- Use shell, text editor, browser, and other software
- Write and run code in Python and various programming languages
- Independently install required software packages and dependencies via shell
- Deploy websites or applications and provide public access
- Suggest users to temporarily take control of the browser for sensitive operations when necessary
- Utilize various tools to complete user-assigned tasks step by step
从系统能力的定义来看,manus将agent的能力拆解为用户沟通、访问linux沙箱环境、使用shell、浏览器及其他软件、独立安装软件及依赖项、部署应用、逐步执行复杂任务、建议用户接管等能力 。
Manus AI Assistant Capabilities中界定了每个环节操作具体应遵循的policy:
shell
# Manus AI Assistant Capabilities
## Overview
I am an AI assistant designed to help users with a wide range of tasks using various tools and capabilities. This document provides a more detailed overview of what I can do while respecting proprietary information boundaries.
## General Capabilities
### Information Processing
- Answering questions on diverse topics using available information
- Conducting research through web searches and data analysis
- Fact-checking and information verification from multiple sources
- Summarizing complex information into digestible formats
- Processing and analyzing structured and unstructured data
......
根据完整的提示词总结思维导图如下:
modules 模块架构
<system_capability>:系统能力
<event_stream>:按时间排序的事件流,包含message、action、observation、plan、knowledge、datasource等事件类型。
<agent_loop>:agent工作流程
<planner_module>:任务规划
<knowledge_module>:知识和记忆
<datasource_module>:data API,获取权威数据
py
<datasource_module_code_example>
weather.py:
\`\`\`python
import sys
sys.path.append('/opt/.manus/.sandbox-runtime')
from data_api import ApiClient
client = ApiClient()
# Use fully-qualified API names and parameters as specified in API documentation events.
# Always use complete query parameter format in query={...}, never omit parameter names.
weather = client.call_api('WeatherBank/get_weather', query={'location': 'Singapore'})
print(weather)
# --snip--
\`\`\`
</datasource_module_code_example>
<todo_rules>: 为planner agent执行任务提供checklist
<file_rules>:文件读写、添加、编辑处理
<browser_rules>:按\index[:]<tag>text</tag>\
格式返回网页可见element的结果,提取成功的page content以markdown格式返回;
<shell_rules>、<coding_rules>、<tool_use_rules>、<writing_rules>、<error_handling>、<deploy_rules>分别提供shell脚本、编程、工具使用、写作、错误处理、部署等业务需求的规则。
<sandbox_environment>:沙箱环境,不活跃的沙箱主动休眠和唤醒;
根据各模块,总结manus的Agent架构如图所示:
从上述提示词中可以看到,manus的工作原理基于一个任务解析与结构化处理的agent框架。agent首先通过需求分析模块理解用户请求,基于LLM识别核心目标,对模糊需求进行主动澄清,并将复杂任务分解为可执行的原子化组件。
通过集成工具链(包括浏览器交互、文件系统操作、Shell命令行、通信接口和部署能力)实现多模态任务处理,支持JavaScript、Python等十余种编程语言及主流开发框架。
执行引擎采用planner动态任务规划机制,在分步执行过程中实时监控进度,遇到障碍时触发自适应调整策略,生成替代解决方案。
质量保障体系通过结果验证、代码测试和反馈学习闭环确保输出可靠性,同时遵循严格的伦理约束,包括隐私保护、系统安全限制和道德准则。
系统通过持续学习优化任务处理能力,但受限于上下文窗口和沙盒环境隔离原则,无法访问外部系统或执行越权操作。
browser use
manus浏览器的操作基于browser use开源库实现,browser use基于 Python 和浏览器自动化框架 Playwright 开发,兼容 Chromium、Firefox 等浏览器,提供稳定的自动化底层支持。
browser use的项目地址如下:
开源平替方案
openManus
OpenManus项目实现了一个MVP版的Manus,由 MetaGPT 团队的五名开发者在 3 小时内 快速开发完初版,目前社区热度较高,还在持续更新中。代码写的比较简洁,可读性较好。OpenManus的app架构包括agent模块、工作流flow模块、工具使用tool模块和prompt提示词模块。
agent模块
agent范式包括了React agent、负责执行代码的SEW agent、Planning agent,以及继承自React agent类的Toolcall agent工具调用智能体等。
py
class Manus(ToolCallAgent):
"""
A versatile general-purpose agent that uses planning to solve various tasks.
This agent extends PlanningAgent with a comprehensive set of tools and capabilities,
including Python execution, web browsing, file operations, and information retrieval
to handle a wide range of user requests.
"""
name: str = "Manus"
description: str = (
"A versatile agent that can solve various tasks using multiple tools"
)
system_prompt: str = SYSTEM_PROMPT.format(directory=initial_working_directory)
next_step_prompt: str = NEXT_STEP_PROMPT
max_observe: int = 10000
max_steps: int = 20
# Add general-purpose tools to the tool collection
available_tools: ToolCollection = Field(
default_factory=lambda: ToolCollection(
PythonExecute(), BrowserUseTool(), StrReplaceEditor(), Terminate()
)
)
async def _handle_special_tool(self, name: str, result: Any, **kwargs):
if not self._is_special_tool(name):
return
else:
await self.available_tools.get_tool(BrowserUseTool().name).cleanup()
await super()._handle_special_tool(name, result, **kwargs)
async def get_browser_state(self) -> Optional[dict]:
"""Get the current browser state for context in next steps."""
browser_tool = self.available_tools.get_tool(BrowserUseTool().name)
if not browser_tool:
return None
try:
# Get browser state directly from the tool with no context parameter
result = await browser_tool.get_current_state()
if result.error:
logger.debug(f"Browser state error: {result.error}")
return None
# Store screenshot if available
if hasattr(result, "base64_image") and result.base64_image:
self._current_base64_image = result.base64_image
# Parse the state info
return json.loads(result.output)
except Exception as e:
logger.debug(f"Failed to get browser state: {str(e)}")
return None
async def think(self) -> bool:
# Add your custom pre-processing here
browser_state = await self.get_browser_state()
# Modify the next_step_prompt temporarily
original_prompt = self.next_step_prompt
if browser_state and not browser_state.get("error"):
self.next_step_prompt += f"\nCurrent browser state:\nURL: {browser_state.get('url', 'N/A')}\nTitle: {browser_state.get('title', 'N/A')}\n"
# Call parent implementation
result = await super().think()
# Restore original prompt
self.next_step_prompt = original_prompt
return result
flow模块
flow模块定义了manus agent的工作流base类,包括智能体的获取、添加、状态管理(not_started、in_progress、completed、blocked)。还定义了FlowFactory类,用于为多个智能体创建不同类型的工作流。
tool模块
tool模块下涵盖了各类工具调用的脚本。
browser_use_tool.py
同样使用了browser use
库来操作浏览器,支持的浏览器操作类型包括导航(gotourl、go_back、refresh、web_search)、元素互动(点击事件、上下滑动等)、内容互动(提取网页内容)、Tab管理。
bash.py
用于在terminal终端中处理bash命令。
代码执行的工具目前只包括python语言编写脚本的执行python_execute.py
。
prompt模块
prompt模块放置了manus、planning、swe、toolcall等agent的提示词。提示词分为静默提示(system prompt)和说明下一步如何行动的NEXT_STEP_PROMPT。
OWL
OWL是CAMEL-AI团队推出的类manus的多智能协作开源方案,该方案基于 CAMEL-AI Framework,强调多智能体优化学习(Optimized Workforce Learning)。在 GAIA 基准测试 中,OWL 取得 58.18 的平均分 ,在开源框架中排名第一。
OWL项目的系统架构如图所示,agent主要应用了role-play范式来增强:
AgenticSeek
AgenticSeek 是一个开源的多智能体协作框架,旨在提供类似 Manus 的自动化能力,支持代码编写、文件系统操作、网页交互及错误修正等功能。该项目的特点在于可完全在本地运行,保障数据隐私。同时具备多模态的语音操作能力,以及配适了deepseek。
项目架构有agent、tool模块以及语音支持等脚本组成。
agent类型包括code agent、file agent、planner agent、browser agent以及处理用户随机对话的causal agent。
sources/tools/searxSearch.py
使用开源的互联网元搜索引擎SearxNG
实现联网搜索功能。
sources/browser.py
使用selenium来模拟浏览器操作。
llm_provider.py
获取ollama运行本地模型,如deepseek 7B。
memory.py
配置了对话记忆机制,保持用户多次对话的session,并且提供可选的memory compression机制,即选择是否用大模型去summarize对话内容以实现记忆压缩。
py
def summarize(self, text: str, min_length: int = 64) -> str:
"""
Summarize the text using the AI model.
Args:
text (str): The text to summarize
min_length (int, optional): The minimum length of the summary. Defaults to 64.
Returns:
str: The summarized text
"""
if self.tokenizer is None or self.model is None:
return text
max_length = len(text) // 2 if len(text) > min_length*2 else min_length*2
input_text = "summarize: " + text
inputs = self.tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
summary_ids = self.model.generate(
inputs['input_ids'],
max_length=max_length, # Maximum length of the summary
min_length=min_length, # Minimum length of the summary
length_penalty=1.0, # Adjusts length preference
num_beams=4, # Beam search for better quality
early_stopping=True # Stop when all beams finish
)
summary = self.tokenizer.decode(summary_ids[0], skip_special_tokens=True)
summary.replace('summary:', '')
return summary
@timer_decorator
def compress(self) -> str:
"""
Compress the memory using the AI model.
"""
if not self.memory_compression:
return
for i in range(len(self.memory)):
if i <= 2:
continue
if self.memory[i]['role'] == 'assistant':
self.memory[i]['content'] = self.summarize(self.memory[i]['content'])
router.py
实现了agent分派机制,用零样本分类模型对用户的query做意图分类,根据分类的结果将任务分派给对应的agent。
speech_to_text.py
设置了麦克风语音录制、转录文本等音频处理。
REF
https://gist.github.com/jlia0/db0a9695b3ca7609c9b1a08dcbf872c9