feat: 新增子 Agent 插件 (sub_agent) - 多 Agent 协作系统
自研协议,主 AI 可以: - spawn: 创建子 Agent 并分配独立任务 - list/status: 查看所有子 Agent 状态 - result: 获取子 Agent 执行结果 - send: 向运行中的子 Agent 发送消息 - kill/clean: 终止和清理 特性: - 每个子 Agent 独立对话历史 - 后台线程异步执行 - 自动提取并执行工具调用 - 完成信号检测 - 并行多任务支持 测试: 113 个用例全部通过
This commit is contained in:
1 parent
1831cfbcc5
commit
3c8ca42bfa
2 files changed
+570
No files matched your search
@@ -353,6 +353,65 @@ class TestBrowserAuto:
|
||||
assert len(info["keywords"]) > 0
|
||||
|
||||
|
||||
# ══════════════════════════════════════
|
||||
# 引擎加载测试
|
||||
# ══════════════════════════════════════
|
||||
|
||||
class TestSubAgent:
|
||||
"""sub_agent 功能测试"""
|
||||
|
||||
@pytest.fixture
|
||||
def sa(self):
|
||||
mod = load_module("sub_agent", os.path.join(PLUGINS_DIR, "sub_agent.py"))
|
||||
return mod.Plugin()
|
||||
|
||||
def test_list_empty(self, sa):
|
||||
result = sa.handle("list")
|
||||
assert "没有" in result
|
||||
|
||||
def test_stats_empty(self, sa):
|
||||
result = sa.handle("stats")
|
||||
assert "总数: 0" in result
|
||||
|
||||
def test_spawn(self, sa):
|
||||
result = sa.handle("spawn tester 测试任务")
|
||||
assert "已创建" in result
|
||||
assert "agent_tester" in result
|
||||
|
||||
def test_spawn_and_list(self, sa):
|
||||
sa.handle("spawn a 任务A")
|
||||
sa.handle("spawn b 任务B")
|
||||
import time; time.sleep(0.1)
|
||||
result = sa.handle("list")
|
||||
assert "agent_a" in result
|
||||
assert "agent_b" in result
|
||||
|
||||
def test_status(self, sa):
|
||||
sa.handle("spawn x 某任务")
|
||||
import time; time.sleep(0.1)
|
||||
# 获取 agent ID
|
||||
agent_id = list(sa.agents.keys())[0]
|
||||
result = sa.handle(f"status {agent_id}")
|
||||
assert "名称" in result
|
||||
|
||||
def test_kill(self, sa):
|
||||
sa.handle("spawn y 要终止的任务")
|
||||
import time; time.sleep(0.1)
|
||||
agent_id = list(sa.agents.keys())[0]
|
||||
result = sa.handle(f"kill {agent_id}")
|
||||
assert "已终止" in result
|
||||
|
||||
def test_clean(self, sa):
|
||||
sa.handle("spawn z 清理测试")
|
||||
import time; time.sleep(0.1)
|
||||
result = sa.handle("clean")
|
||||
assert "已清理" in result
|
||||
|
||||
def test_invalid_agent(self, sa):
|
||||
result = sa.handle("status nonexistent")
|
||||
assert "未找到" in result
|
||||
|
||||
|
||||
# ══════════════════════════════════════
|
||||
# 引擎加载测试
|
||||
# ══════════════════════════════════════
|
||||
|
||||
Reference in new issue
Block a user