Repository navigation
fix(engine): 重试事件不再重复「从中断处继续:从中断处继续」 - #1559
Open
Robert0622 wants to merge 2 commits into
Open
Robert0622 wants to merge 2 commits into
Robert0622 wants to merge 2 commits into
Conversation
网页和对话发起重试时把「从中断处继续」「从指定节点重跑」本身作为 reason 发来, reason 为空时引擎也回落到同一句话,Retry 再无条件拼上 retryLabel+":", 运行时间线和遥测里于是出现「从中断处继续:从中断处继续」。 新增 labelRetryMessage:说明已经以标签开头时原样保留,否则仍加前缀, 用户自己写的原因和人工补充上下文不受影响。 Co-Authored-By: Claude Code <noreply@anthropic.com>
crispinhu27
previously approved these changes
Nov 29, 2026
crispinhu27
left a comment
Collaborator
There was a problem hiding this comment.
审查结论:APPROVE
审查版本 head d6eab47f(base main 611e752b),初审(此前无本账号 Review)。
审查范围
internal/engine/run_ops.go:retryContext中事件与遥测改用labelRetryMessage,新增该辅助函数。internal/engine/retry_event_label_test.go:新增 6 个子用例。- 影响面核对:
web/app/issues.js:753与:938把「从中断处继续」「从指定节点重跑」本身作为reason发送;chatbot/src/RunAlerts.jsx:190的 retry 不带reason,由Retry回落成同一标签;全仓库只有run_ops.go这两处写node.retry_requested文本,internal/repo/analytics.go只按事件类型统计、不解析文案;web/i18n-en.js中从中断处继续 → Resume from failure、从指定节点重跑 → Rerun from step,所以标签去重后英文界面也随之正常。未改接口与前端,兼容旧调用方。
实际执行的验证
在隔离目录分别取 head d6eab47f 与 base 611e752b 的源码(Go 1.26.11):
- head 上
go test ./internal/engine -run TestRetryEventDoesNotRepeatRetryLabel -count=1:6/6 子用例通过。 - 把同一测试文件原样放到 base
611e752b上运行:4 个子用例失败,报出retry event = "从中断处继续:从中断处继续", want "从中断处继续",其余自定义 reason 用例通过——证明该测试确实覆盖此缺陷、且缺陷由本 PR 修复。 - 另写边界探针(未包含在 PR 内):
labelRetryMessage的 8 组输入(标签本身、前后空白、标签+人工上下文、仅人工上下文、自定义原因、两个标签交叉、空 note、以标签开头的长原因)结果均符合预期;并验证NodeRun.Feedback仍保留原始 note(从中断处继续\n\n人工补充上下文:\n补充),未被本 PR 改动。 go vet ./internal/engine、gofmt -l均无问题;go build ./...仅报web/embed.go缺native-chat构建产物(先构建 chatbot 才能通过,属环境因素,与改动无关)。go test ./internal/engine全量:head 与本容器 base 上的失败用例集合经比对一致,全部是沙箱/30s 超时类环境失败(同一用例在未修改的 base 上同样失败),本 PR 未引入新失败。- CI:head
d6eab47f上 17 项检查全部 success(含 core、platform-required、webtest、browser、e2e-required)。
说明
- 仅改展示文案,不改变
Feedback、HumanContext、prompt 或重试语义;遥测与事件文本一致去重。 note为空时函数会产出「从中断处继续:」(带尾冒号),但retryContext在此之前已把空 reason 回落成标签,该分支实际不可达,不构成问题。- 无法在隔离环境复现真实运行页的端到端重试(本机无 Go 后端运行所需的沙箱依赖),但缺陷位于纯文本拼接、已由 head/base 对照的单测和探针直接证明;PR 描述中的浏览器截图与上述代码路径一致。
未发现需要阻塞的问题。
- composeHumanFeedback: 网页 withHumanContext 会把上下文同时拼进 reason 并单独发 context, reason 已以同一段「人工补充上下文」结尾时不再追加,事件、节点 Feedback(prompt 的上一轮反馈) 和打回原因都只保留一份。 - retryContext: 指定了节点但没给原因(chatbot RunAlerts 只发 nodeId)时,回落原因改为 「从指定节点重跑」,与事件标签一致。 Co-Authored-By: Claude Code <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.
问题
运行详情「实时轨迹」和运行事件里,人工重试会显示成重复的标签:
从中断处继续:从中断处继续(英文界面Resume from failure: Resume from failure)从指定节点重跑:从指定节点重跑从中断处继续:从中断处继续\n\n人工补充上下文:…原因
web/app/issues.js的resumeRun/openRerunFromNode把「从中断处继续」「从指定节点重跑」本身作为reason发给POST /api/runs/:id/retry。chatbot 也是这样发的。reason为空时,Engine.Retry也会回落成同一句话。internal/engine/run_ops.go写事件和遥测时又无条件拼接了retryLabel+":"+note,于是同一个标签出现两次。在 main611e752b上用真实 LOOP 复现,数据库run_events里所有网页发起的重试都是这个样子。修复
新增
labelRetryMessage(label, note):说明已经以标签开头(等于标签,或标签后跟换行和人工补充上下文)时原样保留,否则仍然加上标签:前缀。事件node.retry_requested和控制遥测都改用它。从中断处继续:<原因>。Feedback、HumanContext、prompt 都不受影响,只改展示用的事件和遥测文本。已检查所有 open PR,没有其他 PR 改到这段逻辑。#1490 处理的是上下文重复注入,与本 PR 互不重叠。
复现与验证(真实部署 + 真实浏览器)
环境:MariaDB + native 沙箱,私有库
Robert0622/loopforge-sweep-20261129-2200。LOOP「准备 → 检查」中的「检查」节点第一次故意失败。在运行页点「↻ 重试运行」,再看「检查」节点的实时轨迹。修复后,在同一运行上再点「从这里重跑」,轨迹依次是「从中断处继续」「从指定节点重跑」,不再重复:
Playwright 读到的文本:
从中断处继续:从中断处继续/Resume from failure: Resume from failure从中断处继续/Resume from failure;从这里重跑后为从指定节点重跑、从中断处继续测试
internal/engine/retry_event_label_test.go,覆盖 6 种情况:标签作 reason、reason 为空、标签加人工上下文、从指定节点重跑,以及两种自定义 reason。同时断言事件和遥测两处文本。retry event = "从中断处继续:从中断处继续", want "从中断处继续")。go vet ./internal/engine通过。go test ./internal/engine ./internal/httpapi ./internal/repo ./internal/domain:repo、domain 通过。engine 和 httpapi 各有 2 个失败(浏览器容器、git 身份相关,这个容器里无法运行),未修改的 main 上同样失败,本 PR 没有引入新的失败。🤖 Generated with Claude Code