Skip to content

Fix role binding and settings in the SOP orchestrator - #1154

Open
Robert0622 wants to merge 4 commits into
mainfrom
codex/fix-sop-orchestrator-role-settings
Open

Robert0622 wants to merge 4 commits into
mainfrom
codex/fix-sop-orchestrator-role-settings

Conversation

@Robert0622

Copy link
Copy Markdown
Collaborator

Changes

  • Refresh the role catalog for the SOP's project before orchestration. When a new role is needed, let the user review and save it in the existing role wizard before binding it to a node.
  • Resume orchestration with the saved conversation transcript so the follow-up turn uses the newly saved role. If a generated graph still references an unavailable role, restore the canvas and identify the affected nodes.
  • Reveal the node inspector when a node is selected while AI chat is open. Preserve the conversation and link the inspector to the bound role and its verification settings.
  • Keep the feedback control clear of the assistant's send button.

Verification

  • Passed the Go web package and the targeted browser-logic regression tests.
  • Verified two live CodeBuddy DeepSeek V4.1 Flash turns in Chromium. Created a project role, bound it to a generated SOP, saved the workflow, and checked inspector switching, the role deep link, reload, browser back, and the verification tab.
  • Ran the saved role with DeepSeek V4.1 Flash in an isolated instance. The role succeeded, the run reached the manual gate, and the SOP succeeded after approval.

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

初审 #1154(head 2b99578,merge-base d58a85a)。

审查范围:本 PR 全部 10 个文件的改动,重点是 web/orchestrate.js 中按存档会话续接编排、编排前刷新项目角色、agents_save 角色草稿交由角色向导确认、角色不可用时恢复画布,以及 app.js/agents.js/flows.js 中角色深链、向导关闭/路由同步、选中节点时收起 AI 面板等。

验证:在隔离环境构建 chatbot 后 go test ./web/ 通过;orchestrate-ai/orchestrate-build/flow-designer/flows-editor/assets-agents/views/app-shell 等 8 个 webtest 文件 34 个用例在 head 全部通过;CI 16 项全部成功。另编写 jsdom 临时用例在 head 与合并基线上对比复现。

发现 1 个 P3 问题(详见行内评论):存档会话被删除后,GET /api/assistant/sessions/:id 404 使后续每一轮都报「对话不存在」,且缓存的 sessionId 不会被清除;基线在同一场景下可继续编排。

未验证范围:未能用真实模型后端跑多轮编排(无凭据);未跑完整 webtest 全量与真实浏览器交互检查(依赖 CI browser 任务结果)。以上不代表代码没有其他缺陷。

Comment thread web/orchestrate.js
Comment on lines +1041 to +1044
const [session] = await Promise.all([
sessionId ? api('/api/assistant/sessions/'+encodeURIComponent(sessionId),{silent:true}) : null,
refreshWorkflowAgents()
]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P3] 存档会话不存在时,编排助手后续每一轮都失败

  • 触发条件:项目内已完成至少一轮 AI 编排(aiHistory[project].sessionId 已记录),之后该会话被删除(如在对话侧栏删除,DELETE /api/assistant/sessions/:id),再次发送编排请求。
  • 预期 vs 实际:合并基线不读取会话,直接带旧 sessionId 调 /api/assistant/chat,服务端找不到会话会新建,编排可继续;本 PR 先 await api('/api/assistant/sessions/'+id),404 使 Promise.all 整体 reject,本轮报「对话不存在」,且 aiHistory[project] 未清除,之后每一轮都同样失败,直到手动点「新对话」或刷新。
  • 复现:webtest jsdom 用例,第一轮 chat 返回 sessionId: 'ai-1',随后将 GET /api/assistant/sessions/ai-1 置为 404,再连续调用两次 runAIOrchestrator()。
  • 证据:head 第 2/3 轮 chat 调用次数始终为 1,日志为「对话不存在」;基线第 2/3 轮正常发出请求并放置草稿。
  • 修复方向:会话读取失败(尤其 404)时删除 aiHistory[project] 并以空 sessionId/空历史继续本轮,或至少在失败时清除缓存的 sessionId,并给出可操作提示。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

在当前 head 8d2ed0b 复测:仍可复现(STILL_PRESENT)。

  • 用例:webtest jsdom,第一轮 /api/assistant/chat 返回 sessionId: 'ai-1',之后把 GET /api/assistant/sessions/ai-1 设为 404,再连续两次 runAIOrchestrator()(node --test tests/zz-1154-repro.test.mjs)。
  • head 8d2ed0b:三轮后 chat 调用次数为 1/1/1,日志出现「对话不存在」,aiHistory[project] 仍为 {sessionId:'ai-1'}。
  • 基线 d58a85a:同一用例 chat 调用次数 1/2/3,测试通过。

新增的 c9580a8、8d2ed0b 没有改动这段会话读取逻辑(web/orchestrate.js 1047-1054 行与上次一致)。修复方向同上:会话读取 404 时清除 aiHistory[project] 并以空 sessionId 继续本轮。

@Robert0622

Copy link
Copy Markdown
Collaborator Author

用 Chromium 和 CodeBuddy iOA 的 DeepSeek V4.1 Flash 复测了编排后在原会话追加角色和审批的场景。

  • 基线 d58a85a 首轮生成草稿成功,原会话第二轮返回 HTTP 409「共享会话已更新,请重新打开后发送」。
  • Fix role binding and settings in the SOP orchestrator #1154 的合并预览 e34ab530 第二轮返回 200,并给出了可确认的角色草稿。确认角色后的第三轮返回了正确的 SOP 草稿,画布应用时出现 Cannot read properties of undefined (reading 'x')。
  • 后续修复 fix(sop): keep streamed node positions when applying edits #1162 保留了流式放置的节点坐标。同一场景三轮都返回 200。原 SOP 保存为草稿修订 2,重新打开后核对了四个节点和三条成功连线。

@Robert0622

Copy link
Copy Markdown
Collaborator Author

画布修复已直接追加到本 PR,提交为 c9580a8,与此前 CodeBuddy iOA + DeepSeek V4.1 Flash 浏览器实测的提交一致。同一会话三轮均返回 HTTP 200,创建并绑定新角色、追加最终人工审核后,重新打开已保存的 SOP,确认四个节点和三条连线完整。

GitHub 已将 #1162 标记为合并到本 PR 的分支。后续评审集中在 #1154。

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

复审 #1154(head 8d2ed0b,merge-base d58a85a)。

复审范围:上次 Review(2b99578)之后新增的 2 个提交 c9580a8(AI 编辑完成时保留流式放置的节点坐标、清空待放置队列)和 8d2ed0b(会话进程已退出后发送 EOF 不再报 file already closed),以及历史 P3 问题。

历史问题:

  • [P3] 存档会话不存在时编排助手后续每一轮都失败:STILL_PRESENT。head 上同一 jsdom 用例三轮 chat 调用次数仍为 1/1/1、日志「对话不存在」、缓存 sessionId 未清除;基线为 1/2/3。详见原线程。

新提交审查与验证:

  • c9580a8:用 node --test 补跑边界用例(流式节点被最终草稿删掉、队列中尚未放置的节点、最终草稿新增节点),结果节点全部有坐标、无重复 id、被删节点及其连线未残留,未发现新问题。
  • 8d2ed0b:只在 EOF 分支把 os.ErrClosed 视为成功,写数据分支和其他错误不受影响;新测试 TestConversationProcessEOFAfterExit 在 head 通过(-count=3),把同一测试放到基线上失败(close |1: file already closed),说明修复有效。
  • 构建与测试(head):build-chatbot、go build ./...、go vet ./internal/runtime/、go test ./web/ 通过;webtest 全量 218/218 通过。go test ./internal/runtime/ 在本环境有 10 个 Docker/Chromium/bwrap 相关用例失败,基线 d58a85a 上失败的是同样 10 个,属于环境差异,与本 PR 无关。

未验证范围:未用真实模型后端和真实浏览器跑多轮编排(无凭据);发布前复查 CI,当前 head 的检查全部成功。以上不代表代码没有其他缺陷。

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.

2 participants