Selaa lähdekoodia

feat:修复了explore不能使用goal工具的问题

elksmmx 3 viikkoa sitten
vanhempi
commit
dccad9fc19
5 muutettua tiedostoa jossa 7 lisäystä ja 10 poistoa
  1. 0 3
      .env.template
  2. 2 2
      agent/tools/builtin/subagent.py
  3. 1 1
      docs/README.md
  4. 2 2
      docs/decisions.md
  5. 2 2
      docs/tools.md

+ 0 - 3
.env.template

@@ -1,3 +0,0 @@
-# OpenRouter API Key
-# 完成配置后,将 .env.template 重命名为 .env
-OPEN_ROUTER_API_KEY=

+ 2 - 2
agent/tools/builtin/subagent.py

@@ -193,7 +193,7 @@ def _format_evaluate_result(result: Dict[str, Any]) -> str:
 def _get_allowed_tools_for_mode(mode: str, context: dict) -> Optional[List[str]]:
     """获取模式对应的允许工具列表"""
     if mode == "explore":
-        return ["read_file", "grep_content", "glob_files"]
+        return ["read_file", "grep_content", "glob_files", "goal"]
     elif mode in ["delegate", "evaluate"]:
         # 获取所有工具,排除 subagent
         runner = context.get("runner")
@@ -278,7 +278,7 @@ async def _handle_explore_mode(
             task=branch,
             trace_id=sub_trace_id,
             agent_type="explore",
-            tools=["read_file", "grep_content", "glob_files"]
+            tools=["read_file", "grep_content", "glob_files", "goal"]
         )
         tasks.append(task_coro)
 

+ 1 - 1
docs/README.md

@@ -370,7 +370,7 @@ AGENT_PRESETS = {
 
 - 使用 `asyncio.gather()` 并行执行所有分支
 - 每个分支创建独立的 Sub-Trace
-- 只读工具权限(read_file, grep_content, glob_files)
+- 只读工具权限(read_file, grep_content, glob_files, goal
 - 汇总所有分支结果返回
 
 ### delegate 模式

+ 2 - 2
docs/decisions.md

@@ -646,10 +646,10 @@ execution trace v2.0 引入了 Blob 存储系统用于处理大输出和图片
 **Explore 模式的并行执行**:
 - 使用 `asyncio.gather()` 实现真并行
 - 每个 branch 创建独立的 Sub-Trace
-- 仅允许只读工具(`read_file`, `grep_content`, `glob_files`)
+- 仅允许只读工具(`read_file`, `grep_content`, `glob_files`, `goal`
 
 **权限隔离**:
-- Explore 模式:只读权限,防止副作用
+- Explore 模式:文件系统只读权限 + goal 工具,防止副作用
 - Delegate/Evaluate 模式:除 `subagent` 外的所有工具
 - 子 Agent 不能调用 `subagent`,防止无限递归
 

+ 2 - 2
docs/tools.md

@@ -720,7 +720,7 @@ print(f"Success rate: {stats['success_rate']:.1%}")
 
 | 模式 | 用途 | 并行执行 | 工具权限 |
 |------|------|---------|---------|
-| **explore** | 并行探索多个方案 | ✅ | 只读(read_file, grep_content, glob_files) |
+| **explore** | 并行探索多个方案 | ✅ | 只读(read_file, grep_content, glob_files, goal) |
 | **delegate** | 委托单个任务 | ❌ | 完整(除 subagent 外) |
 | **evaluate** | 评估任务结果 | ❌ | 完整(除 subagent 外) |
 
@@ -728,7 +728,7 @@ print(f"Success rate: {stats['success_rate']:.1%}")
 - 适合对比多个方案(如技术选型、架构设计)
 - 使用 `asyncio.gather()` 并行执行,显著提升效率
 - 每个分支创建独立的 Sub-Trace,互不干扰
-- 只读权限,防止副作用
+- 只读权限(文件系统层面),可使用 goal 工具管理计划
 
 **Delegate 模式**:
 - 适合委托专门任务(如代码分析、文档生成)