fix(pi): 按端点适配 SuperGrok 搜索工具 - #2943
Conversation
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/maker-host/anthropic-responses-bridge-host.ts | 根据上游端点选择 wire protocol,并分别清理 Chat Completions 搜索工具或规范化 Responses 搜索工具。 |
| apps/desktop/src/main/maker-host/tests/piNativeSubscriptionForwarding.test.ts | 增加 Pi 原生 xAI 请求最终载荷的回归覆盖,包括过滤、去重、选择协调及原始请求保留。 |
Reviews (6): Last reviewed commit: "fix(pi): normalize xAI search tool choic..." | Re-trigger Greptile
|
这里需要调整一下修复方向:当前把 Chat Completions 下的 我在 2026-08-18 对
官方当前工具文档也已经转向 Agent Tools / Responses: 建议把本 PR 收敛为以下方案:
建议补三组回归:
这样可以把两个问题分开:模型目录决定 Grok 4.6 正常走 Responses;endpoint 门控负责阻止 Responses 工具再次污染 Chat Completions。 |
MagicLizi
left a comment
There was a problem hiding this comment.
审查通过。wireProtocol 透传正确,x_search/live_search 按端点归一化且不留重复声明,tool_choice 窄化正确适配了 Chat Completions 的嵌套 function 形态。
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
|
@zqchris 👋 这个 PR 目前与 请在本地 merge 最新的 |
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a3b26015a
ℹ️ 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".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
MagicLizi
left a comment
There was a problem hiding this comment.
Code Review — P1 ×1
P1: apps/desktop/src/main/maker-host/anthropic-responses-bridge-host.ts:556-575 — 搜索工具去重逻辑依赖数组顺序,可能静默丢弃真实配置
withNativeXaiServerSideTools 里的去重逻辑是 first-seen-wins:当 live_search(无选项的旧拼写)排在带 from_date 的真实 x_search 之前时,旧条目先占位被转为裸 { type: 'x_search' },后续带选项的真实条目被作为 duplicate 丢弃。结果是日期限定等搜索参数静默丢失,用户无任何报错提示。
测试本身断言了这个行为(expect([{ type: 'x_search' }]),选项消失),但从函数注释意图来看("preserving real declarations, normalizing stale spellings"),应该优先保留带选项的真实 x_search 条目,仅在没有真实条目时才 fallback 到转换 live_search。
建议修复方向:先扫描是否存在带选项的 x_search,有则保留;只在无真实 x_search 时才把 live_search 转换为裸 x_search。
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2332a848fc
ℹ️ 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".
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
MagicLizi
left a comment
There was a problem hiding this comment.
代码审查通过。
修复 Pi + SuperGrok 搜索工具在 xAI 不同端点之间的协议兼容问题:Chat Completions 清除不支持的搜索工具声明,Responses 规范化并去重。测试覆盖完整,逻辑清晰。
|
干得漂亮 🎯 xAI 搜索工具在两种端点之间的兼容问题解决得很彻底,参数化测试把所有排列组合覆盖到了。 |
这次改了什么
摘要
修复 Pi + SuperGrok 请求在 xAI endpoint 之间混用服务端搜索工具协议导致 422。真实上游探测确认 Chat Completions 的旧
live_search已不可用,官方工具文档也已转向 Agent Tools / Responses:Pi 原生订阅转发现在对/v1/chat/completions清除误入的x_search/live_search,保留普通 function tools 与合法tool_choice;/v1/responses继续规范化并只保留一个x_search。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
x_search注入、归一化与去重;Responses 单一 function tool 的tool_choice合法化;最终请求体回归测试。input[]清洗。x_search/live_search被工具 schema 拒绝;普通 function tools 不受影响。Grok 4.6 正常使用 Responses +x_search依赖 fix(pi): SuperGrok Grok 4.6 可热切,并收紧 live catalog 刷新 #2818 将其 catalog 协议设为openai-responses。UI 变化
怎么验证的
自动验证
手工验证
不涉及 UI。通过测试中的 fetch recorder 检查最终发往上游的完整 JSON 请求体:
x_search/live_search时只保留原 function tool,并保留对应tool_choice;live_search/ 重复搜索声明归一化为单一x_search,function tool 与单函数收窄保持。未执行的验证
未做真实 SuperGrok 账号 E2E:没有启动 Desktop dev 或向真实 xAI 账号发起计费请求。完整用户路径还依赖 #2818 合入后让 Grok 4.6 正常走
openai-responses;具备 SuperGrok 账号时应在两项改动同时存在的构建中选择 Pi + Grok 4.6,验证请求走/v1/responses、不再返回 422,且 X 搜索可用。风险
风险分类
影响与回滚
/v1/responses或/v1/chat/completionsendpoint 决定。Claude Code、Codex、BYOM 与共享 Responses 工具定义不变。缓存率、system prompt、事件流、模型路由和 usage 计量不受影响。x_search/live_search返回 422/410。提交前检查
git commit -s,见 DCO)