Commit Graph

3 Commits

Author SHA1 Message Date
a1a9a47446 fix(multi-agent): 终结子智能体改为吸收态,修复终结后复活/停止无效
terminate_sub_agent 彻底化:
- 通过 _sub_agent_instances 找到活实例直接 cancel 其 _task(原实现只查
  _running_tasks,多 manager 并存时拿不到句柄导致 cancel 未送达)
- 实例置 _cancelled 并从注册表移除,防止 inject 找到活实例直接复活
- MultiAgentState 同步标记 terminated(原实现不写,侧边栏一直显示 idle)
- output.json 改写为 terminated 终态快照(原实现保留陈旧 idle 快照,
  会被 _check_task_status 读回复活任务记录)
- 新增 control.json 跨 manager 击杀/软停止信号通道,子智能体运行循环
  每个 idle tick / 每轮开始自行消费

注入/复活路径拒绝终结者:
- inject_message_to_sub_agent 检查最新任务记录,terminated 拒绝注入并
  清理孤儿实例;_revive_sub_agent 排除 terminated 记录
- send_message_to_sub_agent 工具返回明确的'已被终结'错误
- stop_sub_agent / soft_stop_all_agents 跳过 terminated,本地无实例时
  经 control.json 让对端 manager 上的实例自行软停止

terminated 吸收态防护:
- _check_task_status/_handle_running_snapshot 不再用陈旧快照覆盖终结记录
- output.json 为 terminated 时同步本地记录(跨 manager 终结广播)
- reconcile_task_states 的 idle/running 修正跳过终态任务
- MultiAgentState.mark_status 禁止 terminated 被覆盖回 idle/running
- 硬取消路径 output.json 写 terminated 而非 failed,避免 failed 被复活
2026-07-21 15:46:24 +08:00
f652118527 fix(multi-agent): 跨事件循环问答、线程安全取消、任务结束汇报格式、工具参数可选 2026-07-12 15:09:16 +08:00
9ed956518c refactor(sub_agent): 子智能体从 Node.js 子进程改为主进程内 Python 协程
- 重写子智能体执行核心,不再启动 easyagent Node.js 子进程
- 新增 modules/sub_agent/ 包集中管理子智能体逻辑
- 工具调用复用主进程 WebTerminal.handle_tool_call,自然经过沙箱/容器链路
- 子智能体模型独立读取 ~/.agents/<mode>/config/sub_agent_models.json
- 支持 8 个工具:read_file/write_file/edit_file(replacements+replace_all)/run_command/web_search/extract_webpage/search_workspace/read_mediafile
- 修复子智能体进度弹窗:标题颜色、write_file 显示、过滤非 progress 条目、统一滚动条样式
- 更新 AGENTS.md / CLAUDE.md 子智能体描述
- 新增 test/test_sub_agent_regression.py 回归测试
2026-06-20 00:26:45 +08:00