feat(agent-core, desktop): run_subagent worktree 隔离#131
Merged
Conversation
为 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
added a commit
that referenced
this pull request
Jul 1, 2026
feat(agent-core, desktop): run_subagent worktree 隔离与阻塞 SubAgent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run_subagent增加worktree: true参数,支持在独立 git worktree 中运行子 Agent,同轮可并行多个工具块,父 turn 仍阻塞等待全部完成。Test plan
packages/agent-core:npm run buildnode --test覆盖 subagent-worktree-meta、tool-agent-basic-info-scope、subagent-workspace-scope 单测apps/desktop:npx tsc --noEmitrun_subagent保持阻塞批处理语义