Repository navigation
fix(worktree): 隔离子代理按自己的工作目录取值,越界可观测 - #434
Merged
Merged
Conversation
withAgentCwd 只改 ALS、不 chdir,子代理里直接读 process.cwd() 的地方 拿到的都是主仓根。本机轨迹(2026-10-16~22,11 个隔离子代理): 529 次带路径工具调用里 501 次打在主仓绝对路径,D13 隔离提示零次出现。 逻辑: - 子代理系统提示词 / spawn workdir / teammate cwd 改用 getCwd(); 隔离提示点名 worktree 根与主仓根 - 子代理 JIT 以 getAgentRoot() 为项目根,jit-telemetry 相对路径按根解析 - bash 在子代理里 cwd 失效时回退到自己的 root,root 也没了就报错不执行 - checker 的 sed 目标与 LLM 分类器共用同一 cwd 口径 - 隔离 worktree 路径判定收口到 cwd-context.splitIsolatedWorktreePath - 自定义子代理新增 cwd 字段 - lockfile 一致性告警覆盖 monorepo 子包 node_modules 可观测 / 数据: - SubagentStart 带 isolation / agent_cwd(agent_cwd 上传前剥离) - jit_context 带 isolated_worktree - sidechain_start 落盘子代理系统提示词与 cwd(仅本地) - digest 子代理段新增隔离越界口径 mainRepoPathCalls/absPathCalls Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
背景
withAgentCwd只改 ALS、不 chdir,子代理里直接读process.cwd()的地方拿到的都是主仓根。本机轨迹实测(2026-10-16~22,4 个会话、11 个
sub_agent(isolation:"worktree")):改动
② 进程层(逻辑)
workdir/ teammate cwd 改用getCwd();隔离提示点名 worktree 根与主仓根getAgentRoot()为项目根(原先加载的是主仓那份规则文件);jit-telemetry相对路径按项目根解析process.cwd())cwd-context.splitIsolatedWorktreePath,W12 / D13 / digest 共用executeCustom)新增cwd字段③ 运行时层
node_modulessymlink(原先只认顶层)可观测 / 数据层
SubagentStart新增isolation/agent_cwd(agent_cwd列入上传剥离名单)jit_context新增isolated_worktreesidechain_start落盘子代理实际收到的系统提示词与 cwd(sidechain 仅本地,不上传)mainRepoPathCalls / absPathCalls,修复后应接近 0trade-off:sidechain 多存一份系统提示词,本地磁盘略增(更省 ↔ 可观测);bash 在 root 失效时直接报错,比原先多一次失败(更安全优先)。
验证
packages/core/tests/agent/isolated-subagent-cwd.test.ts(13 条),digest / advisories 补用例bun run typecheck:gate(66/66 无新增)、lint、format:check、lint:boundary、lint:command-system、docs:gen-reference --check、make build全部通过bun test:17556 pass / 2 fail,两条均已举证与本改动无关:R14 alt-screen并发下 301s 超时,单独重跑 17/17 绿prune-branch-builds在origin/main上 5/5 绿;本地失败是因为分支最近几个 commit 恰是本机其它分支的 HEAD 被判 protected,CI 无这些分支Agent Note:
.agents/notes/implemented/bug-fix/2026-10-24-隔离子代理工作目录口径与可观测.md🤖 Generated with Claude Code