Repository navigation
fix(runtime): restore SOP gate tools when stdio MCP args are empty - #1292
Open
Robert0622 wants to merge 1 commit into
Open
Robert0622 wants to merge 1 commit into
Robert0622 wants to merge 1 commit into
Conversation
crispinhu27
approved these changes
Nov 24, 2026
crispinhu27
left a comment
Collaborator
There was a problem hiding this comment.
审查结论:Approve(head 43acea2a,base d2462fa5)
审查范围
internal/runtime/materialize.go中mcpConfigEntries的改动:stdio 条目在 args 为空时不再写出该字段。- 读了渲染结果的所有下游:共享 mcp.json(Claude Code、CodeBuddy)、Pi、Kimi、Cursor、Antigravity、DeepSeek Harness、opencode、zcode,以及 Codex 的
-c mcp_servers.*参数。 - 只有
agent_cli.go中 opencode 的适配逻辑会读entry["args"],字段缺失时它也能正确处理。
实际验证(隔离环境、合成数据)
- 新增的
TestWriteAgentCLIMCPConfigStdioArgs(pi/kimi/cursor/agy)和TestMaterializeInvocationInjectsGateMCP在 head 通过。只把materialize.go换回 base 版本后两项都失败:gate 条目写出"args":null。由此可以确认这个回归是本 PR 修掉的。 - 用临时探针按 head 和 base 分别生成各 CLI 的实际配置文件,结果如下:
- 所有 JSON 都能正常解析。
- 空 args 由 base 的
null/[]变成省略该字段。 - 有参数的条目(含空字符串参数)顺序和内容不变。
- opencode、zcode、Codex 和 HTTP 条目的输出与 base 完全一致。
- 在
internal/runtime、internal/httpapi、internal/engine、internal/domain跑了 go test:domain 通过;其余失败(bwrap、Docker、Chromium 不可用,以及缺少 gitignore 掉的 native-chat 资源)在 merge-base 上逐项对照,都能同样复现,属于环境问题,与本 PR 无关。 - CI 全部通过。
未做的验证
- 没有用真实 CLI 和模型跑 SOP 端到端,也没有确认 gate 工具在各 CLI 里重新可见:本环境没有供应商凭据。
- 用户显式配置空
args: []时,现在也会省略该字段。没有找到要求args必须存在的 CLI;zcode 和 Codex 路径原本就是这样处理的。
Contributor
|
结论:建议合入 GitHub 拒绝了 Pull Request Review 接口(HTTP 403:Tencent 组织启用了 OAuth App 访问限制)。当前账号无法提交正式 Approve / Request changes。以下改为普通评论。 核对了 stdio MCP 配置:参数为空时不再写出 args: null,有参数时仍按原顺序保留。这能避免内置 gate 被部分 CLI 拒绝,导致产物写完后 SOP 停住。测试检查了 Pi、Kimi、Cursor、Antigravity 以及真实 gate 配置。CI 已全部通过,与 main 没有冲突。 |
Collaborator
Author
CR + 用真实 CLI 跑 SOP 实测(head
|
| main | PR | |
|---|---|---|
生成的 .cursor/mcp.json |
"agentflow-gate": {"args": null, ...} |
不再写 args 字段 |
| Cursor 能不能看到 gate 工具 | GetMcpTools 报错:namespace "agentflow-gate" not found. Available namespaces: cursor |
直接调用了 agentflow-gate__submit_gate_result |
| 过程 | 30 次工具调用、100 秒、4.6 万 token。模型去读平台源码 internal/gatemcp/server.go,然后手写 JSON-RPC 调 gate 二进制,绕了一圈才交上结果 |
3 次工具调用、37 秒、2 万 token |
| 结果 | 这次碰巧绕过去了,换个弱一点的模型就会卡在「产物写完、交不了终态」 | pass,下游节点运行成功 |
git merge main 没有冲突。合并后复跑了 runtime 里 MCP/Gate/Materialize 相关的测试,结果见文末。
合并 main(3815373c)后复跑 runtime 的 MCP/Gate/Materialize 测试:只有
TestEnvironmentIdentityGitAndMCPHeaders失败,main 上同样失败(本机环境原因),没有新增失败。
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.
What changed
The shared stdio MCP renderer writes a nil Go argument slice as JSON
null. Several CLIs reject that entry. When the entry is the built-in gate server, an Agent can produce its artifact and then stop the SOP because the terminal decision tool is missing.Scope
Compatibility
The change applies to generated CLI configuration and requires no data migration. An Agent still submits a structured terminal decision. A required human gate waits for approval after a valid submission.
Validation
args: nulland passes with the shared fix. The runtime package and focused engine submission checks pass.pass, and ran a downstream node. The separate required-manual-gate run first recordedpass, waited for approval, and then ran downstream after approval.go vet ./..., the public content check, and the pinned Gitleaks scan passed.Safety