Skip to content

feat(agent-core, desktop): run_subagent worktree 隔离#131

Merged
N123999 merged 12 commits into
mainfrom
feat/subagent-worktree
Jun 16, 2026
Merged

feat(agent-core, desktop): run_subagent worktree 隔离#131
N123999 merged 12 commits into
mainfrom
feat/subagent-worktree

Conversation

@N123999

@N123999 N123999 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • run_subagent 增加 worktree: true 参数,支持在独立 git worktree 中运行子 Agent,同轮可并行多个工具块,父 turn 仍阻塞等待全部完成。
  • agent-core 实现 bootstrap 回调、子 runtime 工作区 scope、worktree 结果 meta,以及 host-bridge CLI bootstrap。
  • Desktop 实现 worktree 命名、bootstrap、scoped tool executor,并修复子会话 basic info、hook 上下文、审批继承与 bootstrap 失败回滚。

Test plan

  • packages/agent-core: npm run build
  • node --test 覆盖 subagent-worktree-meta、tool-agent-basic-info-scope、subagent-workspace-scope 单测
  • apps/desktop: npx tsc --noEmit
  • 确认无 Concurrent / sleep / read_subagent 残留;run_subagent 保持阻塞批处理语义

N123999 added 12 commits June 16, 2026 16:59
为 run_subagent 增加 worktree 开关、会话摘要 worktree 字段与 SubagentWorkspaceBootstrap 回调类型;宿主工具解析 worktree 布尔参数。
runtime 在 worktree 请求时调用 bootstrapSubagentWorkspace 创建子会话;host-bridge 暴露 bootstrap RPC;工具结果前置 worktree 路径与分支 meta。
Desktop 复用 worktree 命名与 scoped tool executor,经 bootstrapSubagentWorkspace 为子会话创建隔离 git worktree。
bootstrap 后将 worktree 根写入子 runtime 的 config、hook 上下文并 patch [SPIRIT_BASIC_INFO],避免模型按主工作区构造绝对路径。
buildScopedSubagentToolExecutor 新建 scoped executor 时从父 tool executor 快照继承 Composer 审批设置,避免 full-approval 仍弹窗。
子 worktree runtime 通过 resolveWorkspaceFilesForRoot 与 appendLlmUserLlmMessage 重绑工作区根;Desktop 与 CLI host-bridge 注入 ForRoot 解析器。
runSubagentStart/End hook 在 worktree 子会话传入 bootstrap 后的 workspaceRoot,避免 hook 仍看到主工作区。
与 Desktop 对齐:已在 worktree 会话中时拒绝嵌套 worktree subagent。
worktree 已创建但 buildScopedToolExecutor 失败时 best-effort 执行 git worktree remove,避免孤立目录残留。
抽取 patchBasicInfoWorkspaceRootInSystemText,支持 CRLF 并仅替换 buildBasicInfo 格式的 Current workspace 块。
审批继承已在 buildScopedSubagentToolExecutor 处理,deps 类型与调用处删除冗余字段。
为 AgentRuntime 与 SubagentWorkspaceBootstrap 补齐 DesktopToolRequest 泛型,去除 as DesktopRuntime 强转。
@N123999 N123999 merged commit 786e879 into main Jun 16, 2026
@N123999 N123999 changed the title feat(agent-core, desktop): run_subagent worktree 隔离与阻塞 SubAgent feat(agent-core, desktop): run_subagent worktree 隔离 Jun 16, 2026
N123999 added a commit that referenced this pull request Jul 1, 2026
feat(agent-core, desktop): run_subagent worktree 隔离与阻塞 SubAgent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant