Skip to content

fix(sop): save designer role edits and node instructions - #1535

Open
Robert0622 wants to merge 1 commit into
mainfrom
codex/sop-designer-role-edits
Open

Robert0622 wants to merge 1 commit into
mainfrom
codex/sop-designer-role-edits

Conversation

@Robert0622

@Robert0622 Robert0622 commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Changes

  • Let the LOOP Designer propose edits to an existing project role’s name, description, or task prompt. The review shows the proposed values, and saving applies just those fields against the reviewed role revision.
  • Save Agent node instructions with the workflow, show them in the node inspector, and include them with the role instructions when the node runs. Clearing a node prompt from an AI draft also survives saving.

Compatibility

Both changes use the existing JSON definitions and require no database migration.

Validation

  • Targeted Go tests in internal/httpapi, internal/engine, internal/mcpserver and internal/repo passed. The regression test saves an assistant-generated node prompt, publishes the LOOP and checks the instructions received by a mock Agent.
  • The 7 orchestrator browser-logic tests, 15 chatbot SOP Designer tests on Node 22, chatbot build and public content check passed.
  • The isolated MySQL smoke test passed for partial role edits, revision history, and stale-update rejection. Gitleaks passed on the PR commit.
  • All 28 non-model public Playwright cases passed across the initial run and the retried script cases. The latter used a cached release sandbox image and its packaged Linux helpers.
  • The chatbot rich-content case that exceeded the full-suite timeout passed on an isolated rerun. TestBrowserStreamPushesFramesAndRunsCommands still timed out locally on an isolated rerun.

@Robert0622

Copy link
Copy Markdown
Collaborator Author

CR @ e9f2a22

结论:可以合入,没有发现阻塞问题。CI 16/16 全绿,mergeable=MERGEABLE。下面是审查要点、本机部署实测(main f3c1fcde vs 本 PR)和几条 P3 备注。

审查要点

  • 按审阅版本保存:设计器先 GET /api/agents/{id} 拿到 updatedAt,确认后 PUT /api/agents 只带 {id, projectId, updatedAt, changes}。服务端先比一次 updatedAt,仓库层在事务里 SELECT … FOR UPDATE 再比一次,冲突返回 409「角色已更新,请重新审阅修改」。changes 用 DisallowUnknownFields,只接受 name/description/prompt,名称去空格后不能为空。
  • 只改这三个字段:AgentContentChanges.Apply 只覆写 name/description/prompt,executor、model、rules、skills、hooks、loop、verification 等原样保留(新增 TestAgentContentEditPreservesConfiguration 覆盖,并校验旧版本快照);Version 加一,UpdatedAt 更新;无实际变化时不加版本。
  • 权限:内容修改只允许当前项目角色(projectId 必须与库里一致),走 requireProjectWriter;平台级角色不走这条路径。project_write_access_test 新增非成员/只读成员 403、成员 200。
  • 节点指令:WorkflowNode.prompt 只对 type=agent 生效,compileTaskPrompt 把角色任务说明和节点任务说明一起写入「节点任务书」;审批节点的 taskPrompt 仍只给审批人。角色与节点都为空时不再生成任务书,运行输入仍会补一次(TestRunContextReachesRolesAndNodeTaskPromptDoesNot 保持)。
  • 清空后不复活:AI 编辑会由服务端按画布展开成完整 workflows_save,mergeAIEdit 现在对展开结果里没有 prompt 的节点显式删除字段;omitempty 让保存后不再写回。
  • 文档同步了 openapi(AgentContentEdit、节点 prompt)、registry.md 和 orchestration.md。

P3(不阻塞):

  1. openapi 的 PUT /api/agents 仍只列 200/400/401,没写 403(非项目成员)和 409(updatedAt 过期 / 角色属于其他项目),和实现不一致,建议补上。
  2. 内容修改路径先判断项目归属再判断权限,访问别的项目角色返回 409 而不是 403(信息量很小)。
  3. 审阅卡片只显示「要改成什么」,不并排显示当前值;改名时看不到原名,可以再加一行。

部署实测

本机两套实例,各用独立 MariaDB 库:main f3c1fcde 与 PR e9f2a226,原生沙箱,Chromium 真实操作设计器,模型 CodeBuddy deepseek-v4.1-flash,测试仓库为私有库 Robert0622/loopforge-cr1535-1128。

场景 main 本 PR
设计器让 AI 修改现有角色的名称/职责/任务说明 → 审阅 → 保存 无 changes 协议;同样的内容修改请求返回 400「agent id and name are required」 草稿卡列出「名称 / 任务说明」改动,点「审阅并保存修改」弹确认;保存后 name、prompt 更新,未提出的 description / executorId / model 原样保留,version 2→3
审阅确认框打开期间另一个人保存了角色,再点确认 — PUT /api/agents 返回 409,界面提示「角色已更新,请重新审阅修改」,角色保持对方保存的值,version 不变
节点检查器里给 Agent 节点写「本节点任务」,保存 → 刷新 没有该输入框 刷新后仍在,GET /api/workflows 也返回该字段
让 AI 清空节点任务后再保存、刷新 无该字段 画布上 prompt 变为空,保存 + 刷新后仍为空,库里字段消失,没有被画布旧值复活
发布 LOOP 后真实跑一次(同一输入) 只按角色提示词输出 207 字周报,节点指令未生效 节点输出明确写「任务说明要求 200 字,而本节点任务要求一句话,按本节点任务执行」,节点指令进入 Agent 提示词

截图:

审阅草稿 保存确认 并发 409
本 PR:节点任务可编辑 刷新后仍在 main:没有该输入框
AI 清空节点任务后 保存 + 刷新后为空

测试

  • chatbot:63 个文件 572/572 通过。
  • webtest orchestrate-ai:7/7 通过(含新增「已有角色草稿需要确认、只保存提出的字段」)。
  • go test ./internal/repo ./internal/mcpserver:通过。
  • go test ./internal/engine(PATH 里放 bwrap 桩):2 个失败是环境问题——TestEnsureRunBrowserRestoresReclaimedWorkspaceWithStaleRun(本机 Chromium 被沙箱挡掉)和 TestPrepareRepositoryAppliesResponsibleUserGitIdentityOnCloneAndResume(本机 git 身份),同样两个用例在 main 上单独跑也失败。
  • go test ./internal/httpapi:2 个失败(TestMainBotBrowserStartsAndDrivesRunBrowser 报「Agent 浏览器启动失败:当前运行环境不支持,或 Chromium 不可用」、TestBrowserStreamPushesFramesAndRunsCommands 20s 超时),同样两个用例在 main 上单独跑也失败,属本机 Chromium/沙箱环境限制;其余 httpapi 用例通过。
  • CI @ e9f2a22:16/16 pass。

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.

1 participant