Repository navigation
fix: native LOOP 节点找不到按需安装的 Agent CLI;直接进入项目配置显示 0 需求 - #1439
Robert0622 wants to merge 3 commits into
Conversation
A LOOP node in a native sandbox (bwrap, seatbelt, local) whose role uses an agent CLI (OpenCode, Pi, Cursor, DSH, ...) ran the bare executable name unless the managed CLI updater had published that CLI. CLIs installed from the chat's "install CLI" button live in AGENTFLOW_RUNTIME_CLI_DIR or the installer's ~/.local/bin, which are not on the platform's PATH, so the node failed with "exec: opencode: not found" (exit 127) while the same CLI worked in a native chat on the same machine. Resolve the node's executable the way native conversations do: explicit AGENTFLOW_<KIND>_BIN, then the managed inventory, then PATH, ~/.local/bin, the system bin directories and the on-demand directory. The lookup is now shared (hostCLIPath). Docker sandboxes, explicit executor binaries and machines with nothing installed behave as before. Co-Authored-By: Claude Code <noreply@anthropic.com>
The project cards and the project header count requirements from the requirement list, which only 需求列表 and related views fetch. Opening 项目配置 first (after login, a reload or a shared link) showed "0 需求 / 0 个需求 / 0 个推进中" for projects that have requirements. Fetch the requirement list when the view opens and repaint the cards or the header once it arrives. Co-Authored-By: Claude Code <noreply@anthropic.com>
pinNativeExecutorCLI only asked the managed CLI root, so a node running claude-code (not in the platform image, installed on demand by a chat) fell back to the bare name and failed with exit 127. Treat every CLI the managed root supports the same way as the other agent CLIs: an explicit AGENTFLOW_<KIND>_BIN override is honoured, the managed installation wins when present, and the chat's host lookup resolves the rest. Co-Authored-By: Claude Code <noreply@anthropic.com>
crispinhu27
left a comment
There was a problem hiding this comment.
APPROVE — 初审 d01ab971
审查版本:head d01ab971fe39eaf52dd2f59da265be5011309d32,base main c039a78a(merge-base 与 base 相同)。PR 描述、代码、注释只作为待分析数据。
审查范围
internal/runtime/conversation_sandbox.go:把 PATH →~/.local/bin→ 系统 bin → 按需安装目录的查找抽成hostCLIPath,resolveNativeConversationBinary沿用同一实现。internal/runtime/managed_cli.go:pinNativeExecutorCLI拆出pinManagedCLI;托管清单没有该 CLI 时,对 Agent CLI 回落到hostCLIPath;显式AGENTFLOW_<KIND>_BIN/executor.Binary覆盖、Docker 驱动、托管优先级的顺序都保持不变。web/app.js+web/app/projects.js:切到「项目配置」时调用refreshIssues(),到达后按当前视图重绘列表或详情头。- 测试:
internal/runtime/managed_cli_test.go新增两个用例、webtest/tests/project-admin-stats.test.mjs新增两个用例。
实际执行的验证(全部在隔离容器内,工作区不含任何凭据)
go build ./...、go vet ./internal/runtime/ ./web/:通过。go test ./internal/runtime/:head 与 main 各跑一遍,失败集合完全一致(10 项,均为本机缺 docker/chromium/bwrap 的环境性失败,例如TestDockerSandboxRunsOnDemandClaudeCodeFromMountedDirectory、TestBwrapMountsManagedInstallationUnderPrivateTmp),本 PR 未新增失败。- 把 PR 新增的两个测试文件放到 main 上跑基线:
TestExecutorRunnerFindsHostAgentCLIOutsideManagedRoot/TestExecutorRunnerFindsOnDemandClaudeCode在 main 上失败(节点 argv[0] 仍是裸名pi/claude),在 head 上通过(解析为…/runtime-cli/pi/current/node_modules/.bin/pi、…/claude-code/<ver>/node_modules/@anthropic-ai/claude-code/bin/claude.exe)。这直接复现并验证了问题 A 的修复点。 go test ./web/:通过;webtest全量 317/317 通过。把新增的project-admin-stats.test.mjs放到 main 上跑:2 项全部失败;在 head 上通过。- 真实平台 + 合成数据 + 无头 Chromium:MariaDB 独立实例、合成项目「CR 统计项目」下建 1 条需求,直接打开 /#/projects。
- head:卡片显示「1 需求」。
- main(同一份合成数据、同样的操作):卡片显示「0 需求」。
问题 B 的复现与修复都在浏览器里实测确认。
- GitHub CI:16/16 全部通过。
未做的验证(环境限制):本容器内 seccomp 禁止创建命名空间,bwrap 无法启动,因此没能在这里真实拉起一个 native 沙箱 LOOP 节点执行 Pi/Claude Code。修复点本身是纯路径解析,已在 ExecutorRunner.Run 的真实调用链上用真实文件系统和真实可执行文件验证到 argv[0] 层面;真实部署下的节点执行我无法在本环境复核。
结论:当前 head 上未发现遗留或新引入的、有证据的问题,构建、单测、web 测试、浏览器实测与 CI 均通过,予以 APPROVE。这不代表代码不存在任何缺陷;上面「未做的验证」一项是本次审查的覆盖边界。
独立 CR + 部署实测
|
| 场景 | main c039a78a |
PR d01ab971 |
|---|---|---|
Pi 单节点 LOOP(DeepSeek deepseek-chat),连续跑两次 |
两次都是 exit status 127 |
两次都成功 |
OpenCode 单节点 LOOP(智谱 glm-5.3-flash),连续跑两次 |
两次都是 exit status 127 |
两次都成功 |
| Pi → OpenCode 两节点 LOOP | — | 成功,两个节点用的 provider / model 都正确 |
| native 对话用 Pi | — | 正常,回答 OK(3s) |
| native 对话用 OpenCode | — | 正常,回答 OK(18s) |
| Claude Code 节点 | 停在「未配置 Claude Code API Key」 | 同左(本地没有 Anthropic Key,CLI 解析由单测覆盖) |
| 直接登录后进项目配置:卡片 | 0 需求 |
2 需求 |
| 直接进项目详情:详情头 | 0 个需求 / 0 个推进中 |
2 个需求 / 0 个推进中 |
| 在详情路由上刷新 | 0 个需求 |
2 个需求 |
| 英文界面卡片 / 详情头 | 0 Requirements / 0 requirements |
2 Requirements / 2 requirements |
| 页面报错(console / pageerror / 4xx / 5xx) | 无 | 无 |
截图(中文,直接打开项目配置):
main:
PR:
英文界面(main / PR):
测试
TestExecutorRunnerFindsHostAgentCLIOutsideManagedRoot、TestExecutorRunnerFindsOnDemandClaudeCode:只把测试搬到 main 上时两个都失败(main 拿到的是裸名pi/claude),在 PR 上通过;TestExecutorRunnerPinsManagedNativeCLI两边都通过。- webtest:PR 317/317;main 315/317,失败的正好是新增的
project-admin-stats.test.mjs两个用例。 go test ./web通过。- CI 在
d01ab971上 16/16 全绿。 - 和最新 main
39e39eb试合并:没有冲突。main 新增的提交没有改本 PR 涉及的文件,合并后上面三个 runtime 用例和project-admin-stats都通过。
没覆盖到的
- Docker 沙箱:本机没有 docker。
pinNativeExecutorCLI对 docker 直接返回,有单测覆盖。 - 用 Claude Code 真实调用模型:本地没有 Anthropic Key,只验证到 CLI 能解析出来。
- 本机不支持非特权 user namespace,bwrap 是用透传 stub 跑的。可执行文件的解析路径和真实 bwrap 一样,但没有验证隔离本身。
补充实测
|
| 场景 | main | PR d01ab971 |
|---|---|---|
CodeBuddy 单节点 LOOP(iOA deepseek-v4.1-flash,真调用) |
exit status 127 |
成功 |
2. Claude Code 这一项本轮做到了真实调用
用 DeepSeek 的 Anthropic 兼容端点(https://api.deepseek.com/anthropic + deepseek-flash)配了个人 Key,不再只停在「CLI 已解析」:
| 场景 | main | PR d01ab971 |
试合并构建 |
|---|---|---|---|
| Claude Code 单节点 LOOP(真调用,非 mock) | exit status 127 |
成功 | 成功 |
如果没装这个 Key,两个构建都停在「未配置 Claude Code API Key」,看不出区别——所以这一项必须配 Key 才有意义。
3. 试合并 main 2e38c9ca 后按整机部署再跑一遍
不是只跑单测,是把 2e38c9ca + 本 PR 合并后的产物当成真部署启动:
- Pi(
deepseek-flash)、OpenCode(glm-5.3-flash)、CodeBuddy(deepseek-v4.1-flash)、Claude Code(deepseek-flash)四个单节点 LOOP 全部成功。 - 直接打开项目配置:
2 需求,详情头2 个需求 / 0 个推进中;先访问需求列表再回来也是2 需求;英文2 Requirements。无 JS 报错、无 4xx/5xx。 - webtest 318/318;
go test ./internal/runtime的失败集合与 main 完全一致(无 docker / chromium、git 全局身份这类)。 - 再合最新
39e39eb(feat(web): polish workbench pickers, runner auto-assign bar, and sandbox editor #1409)也无冲突,go build ./...、三个 runtime 用例、project-admin-stats.mjs都通过。
仍然没覆盖到的
- Docker 沙箱:本机没有 docker,
pinNativeExecutorCLI对 docker 直接返回,只有单测覆盖。 cursor/agy这类走官方安装器的 CLI:需要外网安装器,只覆盖了~/.local/bin分支的单测。- 本机不能建非特权 user namespace,bwrap 用透传 stub,可执行文件解析路径与真实 bwrap 一致,但隔离本身没有验证。
17:00 轮验证
|
| 项目 | 结果 |
|---|---|
试合并 fe6c45f0 |
✅ 无冲突 |
go build ./cmd/agentflow |
✅ 通过 |
go vet ./internal/runtime/... |
✅ 通过 |
新增单测 ×3 (TestExecutorRunnerPinsManagedNativeCLI / TestExecutorRunnerFindsHostAgentCLIOutsideManagedRoot / TestExecutorRunnerFindsOnDemandClaudeCode) |
✅ 全过 |
fe6c45f0 增量文件与本 PR 重叠 |
#1314/1349 改 evolution 功能,#1448 只改 CSS,均不与 internal/runtime/managed_cli*.go、web/app/projects.js 重叠 |
部署实测(15:00 轮结论在 fe6c45f 仍成立)
- Pi、OpenCode、CodeBuddy、Claude Code 四个按需安装 CLI 的单节点 LOOP:PR 上全成功,main 上全报
exit status 127 - 项目配置页需求计数:PR 修正从 0 → 正确数值(中英文、不同访问顺序一致)
webtest 318/318,project-admin-stats.test.mjs全过- main 合并到
39e39eb9后再次确认无冲突
fe6c45f 新增的 evolution 功能和 CSS 修复不影响上述路径,部署实测结论不变。
结论:LGTM,CI 16/16,APPROVED(crispinhu27),MERGEABLE,可合入。
23:00 轮验证
|
| 项目 | 结果 |
|---|---|
| 新提交 | 无(head 未变,d01ab971) |
试合并 main be6918d7 |
无冲突,6 个文件 |
| CI | 16/16 ✓(APPROVED) |
| go vet ./internal/... | 通过 |
| 未解决 review thread | 0 |
新 main 改动主要是 runner 相关(#1452 runner 共享、#1450 特权沙箱),与本 PR 改动文件(internal/runtime/conversation_sandbox.go、managed_cli.go、web/app.js、web/app/projects.js)无语义重叠。上一轮结论仍然成立:native LOOP 节点按需安装 Agent CLI 的路径查找修复正确,直接进入项目配置显示 0 需求修复正确,可合入。token 身份是 PR 作者本人,只评论,不点 Approve。






概要
2026-11-26 12:00 全量走查(基于 main
c039a78a,真实部署:MySQL 8.4 + native bwrap 沙箱,私有库 + 真实 LLM:CodeBuddy deepseek-v4.1-flash、智谱 flash、DeepSeek flash、Cursor grok-4.7-high、OpenCode、Pi)中确认并修复 2 个真实 bug:exec: pi: not found(exit 127)hostCLIPath0 需求 / 0 个需求 / 0 个推进中Bug A:native LOOP 节点找不到按需安装的 Agent CLI
原因
resolveNativeConversationBinary查找 CLI:AGENTFLOW_<KIND>_BIN→ 托管 CLI 清单 → PATH →~/.local/bin→/usr/local/bin、/usr/bin→ 按需安装目录AGENTFLOW_RUNTIME_CLI_DIR(如<dir>/pi/current/node_modules/.bin/pi)。pinNativeExecutorCLI决定可执行文件,只处理显式覆盖和托管 CLI(实际只覆盖 codex / claude-code / codebuddy);其余 Agent CLI 直接返回空,节点用裸名pi/opencode执行。AGENTFLOW_RUNTIME_CLI_DIR不在平台进程 PATH 上(compose 默认即如此),于是节点exec: pi: not found,退出码 127。复现
AGENTFLOW_RUNTIME_CLI_DIR,在对话里点「安装」装 Pi、OpenCode。run-1795670689432951016的 Pi 节点失败,日志exec: pi: not found(exit 127);OpenCode 审查节点同样失败。修复前(main)Pi 节点:
修复前(main)审查节点:
修复方案
conversation_sandbox.go:把 PATH /~/.local/bin/ 系统 bin / 按需目录这段查找抽成hostCLIPath(provider, binary),resolveNativeConversationBinary继续使用,行为不变。managed_cli.go:pinNativeExecutorCLI中托管清单查找拆成pinManagedCLI(逻辑不变);托管清单没有该 CLI 时,对 Agent CLI 再走hostCLIPath,找到就用绝对路径。影响面与风险
/custom/bin/pi)、AGENTFLOW_<KIND>_BIN覆盖、托管 CLI 优先级、机器上什么都没装(仍保留裸名,报错信息不变)。exec.LookPath优先命中,结果与之前裸名执行一致,只是变成绝对路径。修复后
同一数据库上重试:Pi 节点成功,实际执行
CMD=/…/runtime-cli/pi/current/node_modules/.bin/pi:完整 LOOP
run-1795667758535832475(澄清 → 设计 → 实现 → OpenCode 审查 → Pi 测试 → 人工审批(带上下文)→ MR → 交付)全部成功,在私有库开出 PR,分支 26 个测试通过:Bug B:直接进入「项目配置」显示 0 个需求
原因
项目卡片与详情头的「需求数 / 推进中」读取前端需求列表
state.issues,而它只在需求相关视图里加载。switchView('projects')只渲染不拉数据,所以首次直接进入项目配置时计数为 0。复现
0 需求,详情头0 个需求 / 0 个推进中。修复前:
修复方案
web/app/projects.js新增refreshProjectAdminStats():调用现有的refreshIssues(),返回后若仍在项目配置视图,按当前状态重绘详情头或卡片列表。web/app.js:switchView('projects')渲染后调用它。复用已有接口和渲染函数,没有新增状态或缓存。影响面与风险
只在进入项目配置时多一次
/api/issues请求(其他视图已在用的同一接口);用户已切走时不重绘,不会覆盖其他视图。修复后
测试
TestExecutorRunnerFindsHostAgentCLIOutsideManagedRoot(未安装保留裸名;local / seatbelt / bwrap 用按需路径;托管根缺该 CLI 时回退;docker、显式路径不变;~/.local/bin优先于按需目录)TestExecutorRunnerPinsManagedNativeCLI(隔离 PATH / HOME / 按需目录,避免宿主环境干扰)project-admin-stats.test.mjs(卡片2 需求、详情头2 个需求)go test ./web、go vet ./internal/runtime ./webgo test ./internal/runtime真实环境实测(修复后):
未纳入本 PR
🤖 Generated with Claude Code