Codex harness 走 Chat Completions 上游时 web_search 工具导致请求失败
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: Alexdwbh
**客户端版本**: 0.1.45
---
## 现象
在 Cindy 中用 Codex harness,上游协议为 Chat Completions(如官方 DeepSeek 提供商预设,`codex.wireProtocol = "openai-chat"`),选用 `deepseek-v4-pro` 等模型后,任何会触发 Codex 内置 `web_search` 工具的会话都直接报错:
```json
{"error":{"type":"invalid_request_error","code":"unsupported_feature","message":"Responses feature is not supported by the Chat Completions bridge: tools[3].web_search"}}
```
同样的上游模型,用 claude-code harness 和 pi harness 均正常,问题只出现在 Codex harness 上。
## 复现步骤
1. Cindy 中添加/选择走 Chat Completions 协议的提供商(如内置 DeepSeek 提供商,`codex.wireProtocol = "openai-chat"`)。
2. 新建对话,选择 Codex harness + `deepseek-v4-pro`(或 `gpt-5.6-sol` 等任意模型)。
3. 发送一个会触发联网搜索的任务(例如“查一下今天 DeepSeek 有什么新闻”)。
4. 观察:请求立即失败,返回上述错误;`tools[3].web_search` 即 Codex 工具表中的第 4 个工具。
## 期望行为
桥接层应将 `web_search` 工具降级/跳过(上游不支持时从工具表移除该工具,并在 UI 提示“联网搜索不可用”),而不是让整个请求失败。
## 实际行为
整个请求被拒绝,会话无法继续,触发 `web_search` 的任务 100% 失败。
## 复现频率
100% 可复现。
## 已尝试
- 换用 claude-code / pi harness 接同一 DeepSeek 上游 → 正常,确认问题仅出在 Codex harness 的桥接层。
- 直接请求 DeepSeek 官方 Responses API 并携带 `web_search` 工具 → 正常响应,说明上游本身支持该工具。
## 技术分析(结论,已本地验证)
- 该错误字符串来自 Cindy 应用自身桥接层(`app.asar` 中可见),既不是 Codex CLI 本身、也不是 DeepSeek 上游服务报的。
- 背景:Codex CLI 使用 OpenAI Responses API,`web_search` 是 Responses 协议独有的内建工具;Chat Completions 协议里工具只有 `function` 一种类型,无法表达 `web_search`。Cindy 把 Codex 的 Responses 请求翻译成 Chat Completions 时,遇到 `tools[i].web_search` 即抛错。
- Cindy 代码中其实已存在 web_search 的替代处理路径(映射到 `tool_search` 聊天工具),但当前似乎只对自家网关/特定条件生效,对第三方 Chat Completions 上游直接抛错。
## 建议修复方向(任选其一)
1. 桥接层遇到 `web_search` 时映射为已有的 `tool_search` 聊天工具,或降级为普通 function 工具;上游不支持时跳过该工具并在 UI 提示“联网搜索不可用”。
2. 若上游原生支持 Responses API(如 api.deepseek.com),允许 Codex harness 以 `wireProtocol = "responses"` 直通,不做 Chat Completions 桥接。
3. 提供 per-model / per-provider 的“联网搜索”开关,关闭后从工具表中剔除 `web_search`,避免请求失败。
---
**版本区域**: CN
**OS**: darwin arm64 (25.6.0)
**界面语言**: zh-CN
Contributor guide
Research direction
Start at the Codex harness bridge path that translates Responses requests to Chat Completions, using the reported `tools[i].web_search` failure as the entry point. Inspect the existing `web_search` to `tool_search` handling mentioned in the issue and compare its provider conditions. Done means unsupported Chat Completions upstreams no longer reject the whole request, and the UI communicates when web search is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100