Skip to content

[v2] 补齐工作流失败注入、空目录/延迟模型水合与并发竞态修复 - #387

Open
wanglongan587 wants to merge 5 commits into
ora-space:mainfrom
wanglongan587:fix/1214-v2-workflow-minor-gaps
Open

wanglongan587 wants to merge 5 commits into
ora-space:mainfrom
wanglongan587:fix/1214-v2-workflow-minor-gaps

Conversation

@wanglongan587

@wanglongan587 wanglongan587 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

v2,不涉及 specs。

补齐 v2 工作流与运行时在重试注入、模型目录水合及并发竞态方面的第一批缺口:

  1. 创建工作流运行时配置并注入上次失败上下文 (injectLastFailure)
    • 在 v2-server/workflows.openapi.json 的 WorkflowRunCreate 与生成的 frontend-v2/src/lib/workflows/api/generated.ts 新增可选字段 injectLastFailure。
    • 对话框「运行工作流」增加「节点重跑时把上次失败原因告诉智能体」勾选框(默认勾选、重开重置),并将设置持久化至运行 payload,经 UpdateInput / Start 保留。
    • 重试或从失败处继续执行 Agent 节点时,依据失败类型(FailureKind.InjectsIntoPrompt())与 injectLastFailure 提取上次可注入失败原因,筛选范围、跨轮次续跑回放和触发语义和 desktop 一致(已在 store/workflow_last_failed_attempt_test.go 覆盖已恢复失败排除、Iteration 作用域隔离、未启动尝试排除三个作用域条件),按 locale 注入 prompt 并写入 payload.injected_failure_context,由前端运行节点详情展示。
  2. 修复空目录默认值、模型水合与 model.requested 记录
    • 撤销默认回填桌面端 official/ora-space.codeagentcli / gpt-5 的逻辑;目录为空时新 Agent 节点保持空执行器 { agentCli: "", modelId: "" },属性面板显示「加载中…」或「没有可用 Agent 模型」并隐藏「 · 」拼接与重复提示。
    • 当执行器目录迟到或在首次错误后重试加载完成时,对未触碰/空执行器节点自动补齐首项/修复可用模型,同时保持干净草稿的未保存状态与撤销栈不变。
    • 补充「新建 Agent 取目录首项模型」及「按模型名匹配时 payload.model.requested 记录匹配名」的测试。
  3. 修复 taskworkflow 拒收竞态与 nodeservices 超时测试抖动
    • 修复 taskworkflow 中 refuse 与 startFailure 在 RefuseTaskWorkflow 返回 store.ErrWorkflowRunState 时的竞态,确保取消已启动运行并在接管分支正确订阅观察直至进入 review。
    • 在 nodeservices 停止已结束流上的空闲/总时长定时器,清理 limits_test.go 真实时钟抖动并验证已取消流提前 EOF 仍上报中断原因。

注:theater-overlay-motion.ts 动画时钟修复由前置 PR 承接,已从本 PR 剔除;待前置 PR(#385 / #386)合入 main 后本分支会再行 rebase 并复跑全量门禁后送审。

Refs ora-space/circus#1214

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(12778dc)

@wanglongan587 我看了这个 PR,理解它是要补齐工作流重试和续跑的失败上下文注入,修复空模型目录、延迟水合及启动取消和流超时中的竞态。可以合并,建议补齐模型自动修复与撤销操作的交互。相关前端测试通过,数据库相关行为因缺少测试数据库未能验证。

  • 💬 其他建议:P2-1 撤销操作会恢复已修复的失效模型
  • 测试:cd frontend-v2 && npx vitest run src/features/workflows/editor/workflow-model-hydration.test.tsx src/features/workflows/editor/workflow-inspector.test.tsx src/features/chat/workflow-run/server-run-adapter.test.ts src/features/chat/workflow-run/run-flow.test.tsx --maxWorkers=4 通过;cd v2-server && go test -race -count=1 -timeout=5m ./internal/nodeservices ./internal/workflow ./internal/workflowhost ./internal/taskworkflow 没跑(非数据库用例通过;依赖 PostgreSQL 的失败注入和启动竞态用例因未设置 TEST_DATABASE_URL 被跳过,未完成验证。);没跑全量和 e2e。

涉及对外 API/协议、并发核心,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 12778dc · 第 1 轮(全量)

Comment on lines +825 to +827
if (historyHydrateEditGenerationRef.current === editGenerationRef.current) {
resetWorkflowHistory(workflowRef.current);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2-1(建议) 这里在已有编辑时保留了历史栈,但历史快照仍包含修复前的执行器。已复现:打开含失效模型的草稿,目录返回前新增一个 Agent,目录到达并自动修复后点击“撤销”,原节点就恢复为失效模型;由于 modelHydratedWorkflowId 已设置,后续不会再次修复,发布也会保存失效值。建议同步修复历史快照中的对应执行器,或在恢复快照时重新应用未触碰执行器的修复,并补充实际撤销后的断言。

@EricWvi EricWvi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Owner acceptance, round 1, on 12778dc4, run on a trial merge into main acc80ecd. The merge has no conflicts. All gates pass: full race, npm run check, full e2e (82 passed), and the real-Node workflow-retry/agents/runs/model-hydration specs (15 passed). The production behaviour matches desktop. One change is needed before merge:

M-1. The scoping predicates of FindLastFailedWorkflowNodeAttempt (v2-server/internal/store/workflow_runs.go:492-512) are untested. Each of these mutants survives the store and workflowhost suites:

  • dropping the NOT EXISTS (… succeeded …) clause;
  • neutralising iteration IS NOT DISTINCT FROM $4;
  • dropping started_at IS NOT NULL.

If any of them regressed, the suites would stay green while a Loop round 2 attempt is told round 1's already-recovered failure, or Iteration item 1 receives item 0's failure. Please add a PostgreSQL store test for three cases: a recovered failure followed by a later round, an Iteration item mismatch, and an unstarted failed attempt. Desktop's equivalents are repository_tests.rs:1249 and retry_review_tests.rs:104.

Please also reword "same round" in the description. After resume-from-failure of a Loop, the failure is injected into replayed round 1, not the round that failed. That is the same as desktop, so describe it as desktop-parity semantics.

The non-blocking Lows go to #1181 follow-ups:

  • undo after a late model repair restores and publishes the stale model;
  • the user-edit guard of late repair is untested;
  • prompt placement and output dropping for refusals are not pinned to desktop;
  • a blank executor is accepted at publish and fails only at run time;
  • the motion fix and the real injected-context render lack direct tests (the e2e seeds the DB text).

@wanglongan587
wanglongan587 force-pushed the fix/1214-v2-workflow-minor-gaps branch from 12778dc to fd54d93 Compare November 17, 2026 08:12

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(fd54d93)

@wanglongan587 我看了这个 PR,理解它是要补齐工作流重试和续跑的失败上下文注入,修复空模型目录、延迟水合及启动取消和流超时中的竞态。未发现新的合并阻塞问题,可以合并。上轮 P2-1 的撤销恢复失效模型问题仍未处理,本轮不重复列出;数据库相关行为因缺少测试数据库未能验证。

  • ⏳ 上轮还没处理的:P2-1(仍是建议,不影响合并)。
  • 测试:cd frontend-v2 && npx vitest run src/features/workflows/editor/workflow-model-hydration.test.tsx src/features/workflows/editor/workflow-inspector.test.tsx src/features/chat/workflow-run/server-run-adapter.test.ts src/features/chat/workflow-run/run-flow.test.tsx --maxWorkers=4 通过;cd v2-server && go test -race -count=1 -timeout=5m ./internal/nodeservices ./internal/workflow ./internal/workflowhost ./internal/taskworkflow ./internal/store ./internal/server 通过;cd v2-server && go test -v -count=1 -timeout=5m ./internal/store ./internal/taskworkflow ./internal/workflowhost ./internal/server -run 'TestLastFailedNodeAttempt|TestStartFailureRefuseStateRace|TestPrepareRefuseStateRace|TestRefuseRetryTransition|TestRetryInjectsPreviousFailure|TestResumeInjectsPreviousFailure|TestMatchingModelByName|TestWorkflowRunsOverHTTP' 没跑(目标数据库用例均因未配置 TEST_DATABASE_URL 而跳过。);没跑全量和 e2e。

涉及对外 API/协议、并发核心,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 fd54d93 · 第 2 轮(全量)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants