Skip to content

fix(desktop): route XD Grok through Chat bridge - #2487

Open
tiammomo wants to merge 3 commits into
makecindy:mainfrom
tiammomo:tiammomo/fix/xd-grok-tool-compat
Open

fix(desktop): route XD Grok through Chat bridge#2487
tiammomo wants to merge 3 commits into
makecindy:mainfrom
tiammomo:tiammomo/fix/xd-grok-tool-compat

Conversation

@tiammomo

@tiammomo tiammomo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

Route XD Gateway Grok models through Cindy's Responses-to-Chat bridge so Codex plugin tools remain available.

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • Related issue: Fixes Codex + 网关版 Grok 4.5 因工具格式不兼容请求失败 #2348
  • Included: Mark XD Gateway x-ai/grok-* models for the existing Chat bridge, preserve namespace/custom/tool-search adapters, inject Gateway credentials, and cover explicit and implicit routes.
  • Not included: Direct xAI routing, retry behavior, other Gateway models, or server-side search adaptation.
  • User-visible change: Codex sessions using XD Gateway Grok retain plugin tools instead of failing with the Responses namespace schema.
  • Breaking change: No.

Remote and mobile adaptation

  • SSH remote workspaces: Not affected.
  • Device link: No channel or protocol change.
  • Mobile: Not affected.

UI 变化

Not applicable. No visual, layout, copy, or interaction change.

  • 引用的设计规范:不涉及:request JSON is transformed in the Desktop main process; no UI path changes.

怎么验证的

自动验证

pnpm --filter desktop exec vitest run src/main/maker-host/__tests__/activeCatalogXdAvailability.test.ts src/main/maker-host/__tests__/providerRoute.test.ts src/main/maker-host/__tests__/codexProxyHost.test.ts
Result: passed (214 tests).

pnpm --filter @cindy/responses-chat-bridge exec vitest run src/__tests__/translate-request.test.ts src/__tests__/chat-sse-translator.test.ts
Result: passed (90 tests).

pnpm test:unit
Result: passed.

NODE_OPTIONS=--max-old-space-size=6144 pnpm --filter desktop run --if-present typecheck
Result: passed.

pnpm check:dco
Result: passed.

手工验证

Not run.

未执行的验证

Real XD Gateway and Windows smoke tests were not run.

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • Impact: Only XD Gateway x-ai/grok-* Codex requests switch from native Responses forwarding to the existing Chat bridge.
  • Risk: Chat Completions does not provide Responses server-side search tools. Disabled search is removed; enabled unsupported search fails closed.
  • Rollback: Revert the three commits. No data migration or cleanup is required.

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

Signed-off-by: tiammomo <pearfl@qq.com>
@tiammomo
tiammomo marked this pull request as ready for review August 12, 2026 03:12
@tiammomo
tiammomo requested a review from a team as a code owner August 12, 2026 03:12
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 将 XD Gateway 中的 x-ai/grok-* Codex 模型切换到现有 Chat 桥接路径,并在转发前清理不受支持的禁用搜索工具元数据。

  • 在动态 XD 模型目录中为 Grok 模型标记 openai-chat 兼容协议
  • 使用 XD Gateway 地址和凭证创建 Grok Chat 桥接请求
  • 移除禁用的 web_search,并同步清理悬空的 tool_choice 与并行工具元数据
  • 补充显式路由、隐式路由、凭证缺失回退及非 Grok 模型行为测试

Confidence Score: 5/5

当前没有已确认的阻塞性故障,PR 看起来可以安全合并。

没有仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/main/maker-host/active-catalog.ts 为动态发现的 XD Grok Codex 模型增加 openai-chat 兼容协议标记。
apps/desktop/src/main/maker-host/provider-route.ts 根据目录模型的兼容协议选择具体路由,同时保留既有 XD Claude Anthropic 桥接逻辑。
apps/desktop/src/main/maker-host/codex-proxy-host.ts 为 XD Gateway Chat 桥接注入正确上游与凭证,并清理 Grok 不支持的禁用搜索声明。
apps/desktop/src/main/maker-host/tests/codexProxyHost.test.ts 覆盖 XD Grok 显式和隐式路由、工具保留、凭证缺失回退以及非 Grok 原生 Responses 路径。
apps/desktop/src/main/maker-host/tests/activeCatalogXdAvailability.test.ts 验证 XD Grok Codex 模型被标记为 openai-chat 兼容协议。

Sequence Diagram

sequenceDiagram
  participant Codex
  participant Proxy as Desktop Codex Proxy
  participant Router as Provider Router
  participant Bridge as Responses-to-Chat Bridge
  participant XD as XD Gateway
  Codex->>Proxy: "Responses 请求(x-ai/grok-*)"
  Proxy->>Router: 解析会话提供商与兼容协议
  Router-->>Proxy: XD + openai-chat + gateway-key
  Proxy->>Proxy: 移除禁用的 web_search 并清理工具元数据
  Proxy->>Bridge: 转换 Responses 请求
  Bridge->>XD: Chat Completions 请求 + Gateway 凭证
  XD-->>Bridge: 模型响应
  Bridge-->>Codex: Responses 兼容响应
Loading

Reviews (3): Last reviewed commit: "fix(desktop): route XD Grok through Chat..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76829970f2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/codex-proxy-host.ts Outdated
Comment thread apps/desktop/src/main/maker-host/codex-proxy-host.ts Outdated
@MagicLizi MagicLizi added the touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) label Aug 12, 2026
Signed-off-by: tiammomo <pearfl@qq.com>
@MagicLizi

Copy link
Copy Markdown
Contributor

@tiammomo 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/main/maker-host/codex-proxy-host.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@klboke

klboke commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@tiammomo 嗨咯,当前的处理方式会把所有插件能力都丢了,没法用插件了,是否考虑走 Chat bridge 的方式解决?

@MagicLizi

Copy link
Copy Markdown
Contributor

👋 此 PR 命中 Arch 维护者确认门(核心路径改动 247 行 ≥ 150)。

请维护者(@makecindy/maintainers)确认后直接在 PR 上 Approve 即可放行;如需修改请 Request Changes,作者改完后重新 Approve。

讨论 issue:#2490

@MagicLizi MagicLizi added the awaiting-discussion 等待维护者讨论(review-pr) label Aug 12, 2026
Signed-off-by: tiammomo <pearfl@qq.com>
@tiammomo
tiammomo requested a review from zqchris as a code owner August 12, 2026 04:23
@tiammomo tiammomo changed the title fix(desktop): sanitize XD Gateway Grok tools fix(desktop): route XD Grok through Chat bridge Aug 12, 2026
@tiammomo

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I replaced the tool-filtering approach with the existing Responses-to-Chat bridge. Namespace, custom, and tool-search adapters are now preserved for both explicit and implicit XD Gateway Grok routes. The focused 214-test route suite, 90 Chat bridge tests, full unit suite, Desktop typecheck, and DCO pass.

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

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex + 网关版 Grok 4.5 因工具格式不兼容请求失败

3 participants