|
@@ -5,15 +5,20 @@ Agent Presets - Agent 类型预设配置
|
|
|
用户可通过 .agent/presets.json 覆盖或添加预设。
|
|
用户可通过 .agent/presets.json 覆盖或添加预设。
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
-from dataclasses import dataclass, field
|
|
|
|
|
|
|
+from dataclasses import dataclass
|
|
|
from typing import Optional, List
|
|
from typing import Optional, List
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
+from agent.orchestration.models import AgentRole
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@dataclass
|
|
@dataclass
|
|
|
class AgentPreset:
|
|
class AgentPreset:
|
|
|
"""Agent 预设配置"""
|
|
"""Agent 预设配置"""
|
|
|
|
|
|
|
|
|
|
+ # 安全角色;自定义 explicit-validation preset 必须显式继承一个角色
|
|
|
|
|
+ role: AgentRole = AgentRole.LEGACY
|
|
|
|
|
+
|
|
|
# 工具权限
|
|
# 工具权限
|
|
|
allowed_tools: Optional[List[str]] = None # None 表示允许全部
|
|
allowed_tools: Optional[List[str]] = None # None 表示允许全部
|
|
|
denied_tools: Optional[List[str]] = None # 黑名单
|
|
denied_tools: Optional[List[str]] = None # 黑名单
|
|
@@ -36,18 +41,21 @@ class AgentPreset:
|
|
|
# 默认不预置 skills,项目按需在 presets.json 或 RunConfig.skills 中指定
|
|
# 默认不预置 skills,项目按需在 presets.json 或 RunConfig.skills 中指定
|
|
|
AGENT_PRESETS = {
|
|
AGENT_PRESETS = {
|
|
|
"default": AgentPreset(
|
|
"default": AgentPreset(
|
|
|
|
|
+ role=AgentRole.LEGACY,
|
|
|
allowed_tools=None,
|
|
allowed_tools=None,
|
|
|
max_iterations=30,
|
|
max_iterations=30,
|
|
|
skills=[],
|
|
skills=[],
|
|
|
description="默认 Agent,拥有全部工具权限",
|
|
description="默认 Agent,拥有全部工具权限",
|
|
|
),
|
|
),
|
|
|
"delegate": AgentPreset(
|
|
"delegate": AgentPreset(
|
|
|
|
|
+ role=AgentRole.LEGACY,
|
|
|
allowed_tools=None,
|
|
allowed_tools=None,
|
|
|
max_iterations=30,
|
|
max_iterations=30,
|
|
|
skills=[],
|
|
skills=[],
|
|
|
description="委托子 Agent,拥有全部工具权限(由 agent 工具创建)",
|
|
description="委托子 Agent,拥有全部工具权限(由 agent 工具创建)",
|
|
|
),
|
|
),
|
|
|
"explore": AgentPreset(
|
|
"explore": AgentPreset(
|
|
|
|
|
+ role=AgentRole.LEGACY,
|
|
|
allowed_tools=["read", "glob", "grep", "list_files"],
|
|
allowed_tools=["read", "glob", "grep", "list_files"],
|
|
|
denied_tools=["write", "edit", "bash", "task"],
|
|
denied_tools=["write", "edit", "bash", "task"],
|
|
|
max_iterations=15,
|
|
max_iterations=15,
|
|
@@ -55,11 +63,37 @@ AGENT_PRESETS = {
|
|
|
description="探索型 Agent,只读权限,用于代码分析",
|
|
description="探索型 Agent,只读权限,用于代码分析",
|
|
|
),
|
|
),
|
|
|
"evaluate": AgentPreset(
|
|
"evaluate": AgentPreset(
|
|
|
|
|
+ role=AgentRole.LEGACY,
|
|
|
allowed_tools=["read_file", "grep_content", "glob_files", "goal"],
|
|
allowed_tools=["read_file", "grep_content", "glob_files", "goal"],
|
|
|
max_iterations=10,
|
|
max_iterations=10,
|
|
|
skills=[],
|
|
skills=[],
|
|
|
description="评估型 Agent,只读权限,用于结果评估",
|
|
description="评估型 Agent,只读权限,用于结果评估",
|
|
|
),
|
|
),
|
|
|
|
|
+ "planner": AgentPreset(
|
|
|
|
|
+ role=AgentRole.PLANNER,
|
|
|
|
|
+ allowed_tools=["task_plan", "dispatch_tasks", "task_decide", "validate_attempt", "read_file", "glob_files", "grep_content", "get_current_context"],
|
|
|
|
|
+ denied_tools=["agent", "evaluate", "goal", "submit_attempt", "submit_validation"],
|
|
|
|
|
+ max_iterations=100,
|
|
|
|
|
+ skills=[],
|
|
|
|
|
+ description="唯一规划者:创建、派发任务并根据独立验证结果决策",
|
|
|
|
|
+ ),
|
|
|
|
|
+ "worker": AgentPreset(
|
|
|
|
|
+ role=AgentRole.WORKER,
|
|
|
|
|
+ allowed_tools=["read_file", "read_images", "glob_files", "grep_content", "write_file", "edit_file", "bash_command", "submit_attempt"],
|
|
|
|
|
+ denied_tools=["agent", "evaluate", "goal", "task_plan", "dispatch_tasks", "task_decide", "validate_attempt", "submit_validation"],
|
|
|
|
|
+ max_iterations=50,
|
|
|
|
|
+ skills=[],
|
|
|
|
|
+ description="任务执行者:不能规划或创建子 Agent,必须以 submit_attempt 结束",
|
|
|
|
|
+ ),
|
|
|
|
|
+ "validator": AgentPreset(
|
|
|
|
|
+ role=AgentRole.VALIDATOR,
|
|
|
|
|
+ allowed_tools=["read_file", "read_images", "glob_files", "grep_content", "submit_validation"],
|
|
|
|
|
+ denied_tools=["write_file", "edit_file", "bash_command", "agent", "evaluate", "goal", "task_plan", "dispatch_tasks", "task_decide", "validate_attempt", "submit_attempt"],
|
|
|
|
|
+ max_iterations=30,
|
|
|
|
|
+ temperature=0.0,
|
|
|
|
|
+ skills=[],
|
|
|
|
|
+ description="独立验证者:只读核验固定快照,必须以 submit_validation 结束",
|
|
|
|
|
+ ),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -145,5 +179,7 @@ def load_presets_from_json(json_path: str) -> None:
|
|
|
|
|
|
|
|
cfg["system_prompt"] = system_prompt
|
|
cfg["system_prompt"] = system_prompt
|
|
|
|
|
|
|
|
|
|
+ if "role" in cfg:
|
|
|
|
|
+ cfg["role"] = AgentRole(cfg["role"])
|
|
|
preset = AgentPreset(**cfg)
|
|
preset = AgentPreset(**cfg)
|
|
|
register_preset(name, preset)
|
|
register_preset(name, preset)
|