所有实例 Agent 都是继承 ToolCallAgent,所以只列出额外的参数字段,继承的见 ToolCallAgent
Manus 是一个多功能通用Agent,使用多种工具解决各种任务,提供了包括 Python 执行、网络浏览、文件操作和信息检索等功能。
属性名 | 默认值 |
---|---|
name | Manus |
description | A versatile agent that can solve various tasks using multiple tools |
system_prompt | SYSTEM_PROMPT,prompt/manus.py |
next_step_prompt | NEXT_STEP_PROMPT,prompt/manus.py |
max_observe | 2000 |
max_steps | 20 |
available_tools | PythonExecute(), WebSearch(), BrowserUseTool(), FileSaver(), 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)
功能:处理特殊工具执行和状态变化。
实现细节:
_handle_special_tool()
方法PlanningAgent 是一个创建和管理计划来解决任务的Agent,使用规划工具创建结构化计划,并跟踪各个步骤的进度直到任务完成。
属性名 | 默认值 |
---|---|
name | planning |
description | An agent that creates and manages plans to solve tasks |
system_prompt | PLANNING_SYSTEM_PROMPT |
next_step_prompt | NEXT_STEP_PROMPT |
available_tools | PlanningTool(), Terminate() |
tool_choices | ToolChoice.AUTO |
special_tool_names | [Terminate().name] |
step_execution_tracker | {} |
current_step_index | None |
max_steps | 20 |
属性名 | 类型 | 描述 | 默认值 |
---|---|---|---|
active_plan_id | Option[str] | 当前 plan 的ID | None |
step_execution_tracker | Dict[str,Dict] | 跟踪每个工具调用的步骤状态 | {} |
current_step_index | Option[int] | 当前步骤索引 | None |
功能:初始化Agent,设置默认 plan ID并验证所需工具。
async def think(self) -> bool:
"""Decide the next action based on plan status."""
prompt = (
f"CURRENT PLAN STATUS:\n{await self.get_plan()}\n\n{self.next_step_prompt}"
if self.active_plan_id
else self.next_step_prompt
)
self.messages.append(Message.user_message(prompt))
# Get the current step index before thinking
self.current_step_index = await self._get_current_step_index()
result = await super().think()
# After thinking, if we decided to execute a tool and it's not a planning tool or special tool,
# associate it with the current step for tracking
if result and self.tool_calls:
latest_tool_call = self.tool_calls[0] # Get the most recent tool call
if (
latest_tool_call.function.name != "planning"
and latest_tool_call.function.name not in self.special_tool_names
and self.current_step_index is not None
):
self.step_execution_tracker[latest_tool_call.id] = {
"step_index": self.current_step_index,
"tool_name": latest_tool_call.function.name,
"status": "pending", # Will be updated after execution
}
return result
功能:基于计划状态决定下一步行动。
实现细节:
think()
方法act()
功能:执行步骤并跟踪其完成状态。
实现细节:
act()
方法执行工具get_plan()
功能:检索当前计划状态。
实现细节:
run()
功能:运行Agent,可选初始请求。
实现细节:
run()
方法update_plan_status()
功能:基于已完成的工具执行更新当前计划进度。
实现细节:
_get_current_step_index()
功能:解析当前计划以识别第一个未完成步骤的索引。
实现细节:
create_initial_plan()
功能:基于请求创建初始计划。
实现细节:
结构化问题解决:
进度跟踪:
自适应执行:
初始化与验证:
SWEAgent 是一个自主 AI 程序员 ,能够直接与计算机交互来解决任务。它继承自 ToolCallAgent,专注于软件开发和代码执行任务。
属性名 | 类型 | 描述 | 默认值 |
---|---|---|---|
name |
str | Agent的唯一名称 | “swe” |
description |
str | Agent的描述 | “an autonomous AI programmer that interacts directly with the computer to solve tasks.” |
system_prompt |
str | 系统级指令提示 | SYSTEM_PROMPT |
next_step_prompt |
str | 确定下一步行动的提示 | NEXT_STEP_TEMPLATE |
available_tools |
ToolCollection | 可用工具集合 | Bash(), StrReplaceEditor(), Terminate() |
special_tool_names |
List[str] | 特殊工具名称列表 | [Terminate().name] |
max_steps |
int | 最大执行步骤数 | 30 |
bash |
Bash | Bash 工具实例 | Bash() |
working_dir |
str | 当前工作目录 | “.” |
属性名 | 类型 | 描述 | 默认值 |
---|---|---|---|
bash |
Bash | Bash 工具实例 | Bash() |
working_dir |
str | 当前工作目录 | “.” |
think()
功能:处理当前状态并决定下一步行动。
实现细节:
next_step_prompt
think()
方法环境感知:
开发工具链:
自主性:
特性 | SWEAgent | Manus | PlanningAgent |
---|---|---|---|
主要功能 | 软件开发 | 通用任务解决 | 任务规划与执行 |
工具集 | 命令行、文件编辑 | Python执行、网络搜索、浏览器、文件保存 | 规划工具 |
特殊能力 | 环境感知(工作目录) | 多功能信息获取 | 计划创建与跟踪 |
最大步骤 | 30 | 20 | 20 |
设计重点 | 代码操作 | 信息获取与处理 | 结构化执行 |