Repository navigation
fix: AI 分支命名只提供已配置的 CLI;执行器失败时 Agent 循环文案准确 - #1470
Robert0622 wants to merge 4 commits into
Conversation
The repository drawer's AI branch-naming picker listed every built-in CLI, including ones the user has no credentials or runner login for. Saving such a CLI succeeded, and from then on every LOOP start in the project failed with "工作分支生成失败:请配置 LOOP 负责人的模型凭据或执行机器登录", because the branch name is generated with the dispatching user's credentials, exactly as role nodes run. Use the role editor's rule (executorConfigured, Tencent#1291): offer configured CLIs only, keep a stored CLI that is not configured for the current editor visible but disabled so editing other repository fields preserves it, and refuse to save a newly chosen CLI that is not configured. Co-Authored-By: Claude Code <noreply@anthropic.com>
When an executor exits with an error on a role with a self-correction loop, no gate decided the failure, so the trace read "门禁失败策略为 ,跳过自修正" (an empty policy) and the hand-off event said "Agent 自修正次数已耗尽" although only one iteration ran. Name the executor failure instead, and claim the loop budget is spent only when every iteration ran. Behaviour is unchanged. Co-Authored-By: Claude Code <noreply@anthropic.com>
Since Tencent#1320 the LOOP switcher in flow-palette.js calls workflowVersionLabel from sops.js, which the harness does not load, so `e2e/run.sh unit` failed on main with a ReferenceError. Co-Authored-By: Claude Code <noreply@anthropic.com>
crispinhu27
left a comment
There was a problem hiding this comment.
初审 d8f6bd4d:APPROVE
审查范围(5 个文件,+131/−11):internal/engine/node_execute.go、internal/engine/core_cases_test.go、web/app/repo_drawer.js、webtest/tests/projects-repos.test.mjs、e2e/unit/flow-designer.test.mjs,并结合角色编辑器 executorConfigured() 的既有约定(#1291)理解调用链。
逐项核验
- Agent 循环文案(问题 B):
agentLoopSkipMessage("")正确区分执行失败(非门禁)与门禁策略为空的场景;agentLoopHumanMessage(lastIteration, maxIterations)在iterations < maxIterations时输出「第 N 轮执行失败,未进入自修正」,仅在真正用尽时保留「次数已耗尽」。调用点传参正确:lastIteration初始化为 0、循环至少跑一轮后被赋值,exhausted路径取lastIteration。事件类型和控制流未变。TestAgentLoopMessagesDescribeExecutorFailures四个断言覆盖全部分支。 - AI 分支命名 CLI 下拉(问题 A):
fillRepoBranchExecutors复用executorConfigured(),只列已配置 CLI;已存未配置项显示为禁用 Option 保留;保存时通过repoDrawerState.branchExecutorId比对拦截未配置选择(不发 PUT);执行器配置加载中显示「检查配置中…」并在executorModelCatalogRequest完成后重渲染。新增 webtest 覆盖三个场景(过滤、拦截、保留),与角色编辑器行为一致。 - e2e 桩:
workflowVersionLabel与sops.js实现一致,修复 main 上 1 项 unit 失败。
验证依据
- CI
core16 项检查全部通过(含 Non-browser Go tests、Real-browser Go tests、Coverage gate、Browser-free UI tests)。 - 审查版本:head
d8f6bd4d(base mainbe6918d7)。未发现本 PR 引入或加重的问题,不构成阻塞。
🤖 Generated with Claude Code
本轮 CR 结论:LGTM,可以合入head: 代码审查5 个文件(+131/−11),改动干净,分三块:
部署实测在本机(MariaDB +
#1469 / #1470 交叉改动两个 PR 都改了 没有发现问题,不需要改代码。 |
…ile the branch-naming CLI list loads - agentLoopHumanMessage now distinguishes an executor failure from a gate (or submit_gate_result) failure whose policy is not "loop", matching agentLoopSkipMessage, instead of calling both "执行失败". - The repository drawer repaints the AI branch-naming CLI picker as soon as the executor catalog request starts, so a saved configured CLI shows "(检查配置中)" rather than "(未配置)", and a prefix repo switched to AI shows "检查配置中…" rather than "无可用 CLI" until the catalog returns. Co-Authored-By: Claude Code <noreply@anthropic.com>
04:00 轮 CR + 部署实测:原修复有效;补了 2 处小问题,新 head
|
| # | 场景 | main be6918d7 |
PR dc5a90a2 |
|---|---|---|---|
| A1 | 前缀仓库切「AI 生成」,看 CLI 下拉(只配了 CodeBuddy) | 列出全部 10 个 CLI | 只有「选择 CLI / CodeBuddy」 ✅ |
| A1b | 选未配置的 Codex 保存 | 「仓库已保存」,存成 codex | 下拉里没有 Codex,选不到 ✅ |
| A2 | 仓库已存 codex(未配置),只改提示词后保存 | — | 显示禁用的「Codex(未配置)」,值仍为 codex;保存后 executorId=codex 保留,prompt 已更新 ✅ |
| A3 | 往下拉里注入未配置的 claude 再保存 | 保存成功(存成 claude) | toast「请选用已配置的 CLI」,没有发出 PUT,已存的值不变 ✅ |
| A4 | 改选 CodeBuddy + deepseek-v4.1-flash 保存 | — | 「仓库已保存」,存成 codebuddy / deepseek-v4.1-flash ✅ |
| A5 | executor-models 人为延迟 6 秒 | — | 加载中显示「CodeBuddy(检查配置中)」,返回后恢复成可选的 CodeBuddy,选中值不丢 ✅(d8f6bd4d 这里显示的是「(未配置)」) |
| A6 | 改回前缀模式 feature/ 保存 |
— | 「仓库已保存」,不受 CLI 校验影响 ✅ |
| A7 | 派发需求(仓库 AI 命名) | 已存未配置的 claude:400「工作分支生成失败:请配置 LOOP 负责人的模型凭据…」 | CodeBuddy flash 真实生成分支 readme-json-output-1,派发 201 ✅ |
| B1 | Agent 循环 3 轮/耗尽转人工,执行器失败(无效模型,exit 3) | 「门禁失败策略为 ,跳过自修正」+「自修正次数已耗尽」 | 「本轮执行失败(不是门禁未通过),不进入自修正」+「Agent 第 1 轮执行失败,未进入自修正,转人工判断」 ✅ |
| B2 | 同上,门禁/Agent 提交 fail | 「自修正次数已耗尽」 | 修复后为「Agent 第 1 轮门禁未通过(失败策略为 fail),未进入自修正」 ✅(d8f6bd4d 显示的是「执行失败」) |
| B3 | 门禁 onFailure=loop,真实跑自修正 | — | 「第 1 轮未通过,进入自修正」,第 2 轮由 Agent 请求人工确认,进入 waiting_approval ✅,走的是原有路径 |
测试
webtest:388/388 通过(含新增用例);e2e/unit/flow-designer.test.mjs13/13 通过;go test ./web/ok。go vet ./internal/engine/clean;go test ./internal/engine -run 'TestAgentLoop|Loop|TestMRGate'ok。不装 bwrap 替身时,TestMRGateRunsInTheNodeLoop报bwrap not found,属于环境问题,装上替身后通过。- CI:新 head
dc5a90a2上 16/16 全部通过,与 mainbe6918d7无冲突。
crispinhu27 在 d8f6bd4d 上的 Approve 已因新推送失效,需要重新评审 d8f6bd4d..dc5a90a2(4 个文件,+66/−8)。
crispinhu27
left a comment
There was a problem hiding this comment.
复审 dc5a90a2:APPROVE
审查版本:head dc5a90a24e517f28124363b47edb846e23f883f4(base main)。上一轮在 d8f6bd4d 上的 APPROVE(6079769095)已被新推送撤销,本次针对增量提交 dc5a90a2 进行复审。
增量范围(1 个提交,4 个文件 +66/−8)
-
node_execute.go:agentLoopHumanMessage新增failedAction参数,区分执行器失败(空串 → 「第 N 轮执行失败」)与门禁策略提前结束(非空 → 「第 N 轮门禁未通过(失败策略为 X)」)两种场景;iterations >= maxIterations路径仍返回耗尽文案,三条分支互斥无遗漏。调用点传参正确。 -
core_cases_test.go:补充门禁策略分支断言,三条分支全覆盖(执行失败、门禁未通过、次数耗尽)。 -
repo_drawer.js:catalog 加载前先调fillRepoBranchExecutors,使已保存 CLI 在 catalog 返回前显示「检查配置中」而非「未配置」;catalog 完成后重渲染,最终状态正确。 -
webtest/tests/projects-repos.test.mjs:新增测试覆盖 catalog 加载中占位、完成后恢复、切换 prefix 仓库为 AI 时同样触发占位。
CI 验证:head dc5a90a2 全部 16 项检查通过(browser、core、platform-required、e2e 全矩阵、e2e-required、e2e-browser、first-run、validate、curl-install、tcmcp、secrets、GITHUB_OPENSOURCE_SCAN),无失败项。
未发现增量引入或加重的阻塞问题。
🤖 Generated with Claude Code
本次全量走查基于最新 main(be6918d7,v0.4.3)。我在本地起了真实环境:MySQL、agentflow 服务、Web 和 Chatbot。然后在私有测试仓库上用真实模型跑了完整 LOOP:OpenCode / Pi / dsh 用 DeepSeek flash,Cursor 用 grok,CodeBuddy 用 deepseek flash。过程包括派发需求、AI 分支命名、审批、返工、重试和合并请求,并用 Playwright 点遍各页面的按钮。共确认并修复 2 个产品问题,另外修了 1 处过期的测试桩。
问题 A:仓库抽屉的「AI 生成工作分支」CLI 下拉列出了未配置的 CLI,保存后每次派发都失败
现象
仓库…的工作分支生成失败:请配置 LOOP 负责人的模型凭据或执行机器登录。根因
executorConfigured()为真的 CLI,但web/app/repo_drawer.js的分支命名下拉漏了这一步:它直接列出state.data.executors里所有带kind的执行器,保存时也不校验。复现
修复(
web/app/repo_drawer.js)fillRepoBranchExecutors(),复用角色编辑器的executorConfigured(),下拉只列已配置的 CLI。影响和风险
修复后
tl/1795718493368256911-readme-json,后续 LOOP 跑通并提交了 PR。问题 B:开启自修正的角色执行器失败时,轨迹文案错误
现象
门禁失败策略为 ,跳过自修正(策略为空)Agent 自修正次数已耗尽,转人工判断根因
internal/engine/node_execute.go中,执行器失败时failedAction为空,跳过消息直接拼接空串。复现
tl-broken-loop:角色使用 dsh,模型设为deepseek-no-such-model,loop maxIterations=3,onExhausted=human。修复
agentLoopSkipMessage(failedAction):agentLoopHumanMessage(iterations, max):修复后:事件为
Agent 第 1 轮执行失败,未进入自修正,转人工判断:exit status 1和本轮执行失败(不是门禁未通过),不进入自修正。C:e2e 单测桩过期
e2e/unit/flow-designer.test.mjs的上下文桩缺少workflowVersionLabel(sops.js 已有该函数),导致renderSwitcher抛出 TypeError,main 上 e2e unit 有 1 项失败。已按 sops.js 的实现补上这个桩。测试
新增测试
webtest/tests/projects-repos.test.mjs:「AI branch naming offers only CLIs configured for the user」,覆盖以下几点:internal/engine/core_cases_test.go:TestAgentLoopMessagesDescribeExecutorFailures。回归结果(修复分支)
go vet ./...:通过go test ./...:main 与修复分支的失败集合完全相同,都是 15 个依赖 Docker、Chromium 或 systemd 的环境用例,本 PR 没有引入新的失败。🤖 Generated with Claude Code