fix(desktop): sanitize XD Gateway Grok tools - #2444
Conversation
Signed-off-by: yuaiccc <yuaiccc@aliyun.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/maker-host/codex-proxy-host.ts | 新增范围受限的 XD Gateway Grok 工具兼容 transform,并接入现有 Codex 请求转换链。 |
| apps/desktop/src/main/maker-host/tests/codexProxyHost.test.ts | 新增端到端转换链测试,并同步更新 transform 数量和顺序断言。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Codex Responses 请求] --> B{provider 为 xd?}
B -- 否 --> P[原样传递]
B -- 是 --> C{模型以 x-ai/grok 开头?}
C -- 否 --> P
C -- 是 --> D{XD Codex 路由可服务该模型?}
D -- 否 --> P
D -- 是 --> E[sanitizeXaiTools]
E --> F[删除 namespace 工具]
E --> G[清理 web_search 不兼容字段]
E --> H[保留受支持工具]
F --> I[继续后续 transform 链]
G --> I
H --> I
Reviews (2): Last reviewed commit: "chore: complete PR description per forma..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47bd4366d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) { | ||
| return null; | ||
| } | ||
| return sanitizeXaiTools(body); |
There was a problem hiding this comment.
MagicLizi
left a comment
There was a problem hiding this comment.
格式检查未通过
请补充 PR Description 的必要段落:
- 这次改了什么:说明 sanitize XD Gateway Grok tools 的具体改动
- 怎么验证的:说明测试覆盖和验证方式
- 风险:评估此改动对 Codex proxy 链的影响
修完描述后 push 即可触发重新审查。
|
@yuaiccc 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/maker-host/codex-proxy-host.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
Signed-off-by: yuaiccc <yuaiccc@aliyun.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 039433e29a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) { | ||
| return null; | ||
| } | ||
| return sanitizeXaiTools(body); |
There was a problem hiding this comment.
当 Grok 请求只声明 namespace 等不支持的工具,或 tool_choice 强制选择其中一个时,sanitizeXaiTools 会删除该工具,却保留 tool_choice 和 parallel_tool_calls;最终请求会出现“没有 tools 仍指定 tool_choice”或 choice 引用不存在工具的形态,Gateway 仍会返回 schema 400。相邻的 Seed 兼容层已经通过重置失效 choice、在工具清空时删除这些控制字段处理了同一情况;这里复用 sanitizer 时也需要保持这些字段一致。
Useful? React with 👍 / 👎.
|
@yuaiccc 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/maker-host/codex-proxy-host.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
这次改了什么
摘要
新增
createGatewayGrokResponsesCompatTransform,加入 Codex 代理的请求 transform 链。当 session provider 为xd(XD Gateway)、model 以x-ai/grok开头、且providerRoutingServesWireModel('xd', 'codex', model)为真时,复用既有sanitizeXaiTools清理 Codex namespace tools(如multi_agent_v1)与web_search的external_web_access标记,避免 Grok Responses 上游因不支持的 tool 形状返回 400。区别于已有的 first-partyxai/OAuth provider 变换,本变换只作用于网关路由下的x-ai/grok模型。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
createGatewayGrokResponsesCompatTransform加入createTransformRequestChain(计数 13 → 14);新增单测drops Codex namespace tools for XD Gateway Grok models;同步 transform 链计数与注释清单。xai/OAuth provider 变换、其它 provider 路由。x-ai/grok*模型时不再因 tool 形状被上游 400。UI 变化
不涉及:仅改主进程请求 transform 链,无 renderer / 视觉 / 交互 / 文案变化。
怎么验证的
自动验证
手工验证
不涉及:transform 行为由单测覆盖。
未执行的验证
本次未本地复跑单测,依赖 CI 重跑确认。
风险
风险分类
影响与回滚
xd+ modelx-ai/grok前缀 + 路由服务校验三重条件),只影响 XD Gateway Grok 路径,不影响 first-partyxaiOAuth 或其它 provider。复用既有sanitizeXaiTools,无新逻辑分支;未匹配时返回null透传,不改写请求。createGatewayGrokResponsesCompatTransform(计数回 13)。提交前检查