Codex agent fails with third-party providers: "Unsupported custom tool: 'exec'. Only 'apply_patch' is supported."
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: 匿名
**客户端版本**: 0.1.46
---
## 现象
Maker 会话选择 agent = Codex + 第三方兼容端点(DeepSeek / OpenCode Go / Z.ai GLM)时,每次提问都在模型响应前被 400 拒绝,报错:
```json
{"error":{"message":"Unsupported custom tool: 'exec'. Only 'apply_patch' is supported.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}
```
## 复现步骤
1. 打开 Maker 会话,agent 选 Codex。
2. 选一个第三方 provider/模型(如 DeepSeek `deepseek-v4-flash`,或 OpenCode Go)。
3. 发送任意消息(如“你好”)。
## 期望行为
Codex agent 能像 0.1.46 之前一样正常使用已配置的第三方 provider(最近一次正常会话为 2026-08-11)。
## 实际行为
每次都会抛出上面的 400 错误,turn 以 error 结束。
## 复现频率
100%。升级到 0.1.46(2026-08-13)后稳定复现;升级前正常。
## 已尝试
- 本地检查发现 `buildCodexProxySpawnArgs` 无条件传入 `-c features.code_mode_only=true`,强制 codex 进入 Code Mode,此时 codex 0.145.0 发给模型的是 custom tool `exec`(+ `wait`),而非经典 `exec_command` / `apply_patch` 工具集。第三方端点只把 `apply_patch` 当 custom tool 白名单,拒绝 `exec`。
- `config.toml` 无法覆盖:app 每次启动都用命令行 `-c` 覆盖(优先级高于配置文件),且无用户可见开关。
## 脱敏证据
- 失败会话(Code Mode):发送工具 = `custom exec`、`function wait`、`function request_user_input`、`web_search`;启用特性含 `CodeMode`、`CodeModeOnly`。
- 升级前正常会话:发送工具 = `function exec_command`、`write_stdin`、`update_plan`、`request_user_input`、`view_image`、`web_search`;启用特性仅含 `CodeModeHost`(无 `CodeMode`/`CodeModeOnly`)。
- 错误链路:codex POST 到本地网关 `/responses` → 网关转发到上游第三方端点 → 上游 400 返回上述错误。
## 建议修复
仅在支持 `exec` 工具集的端点(如官方 OpenAI)上强制 `code_mode_only`;或改为可配置;或对非 OpenAI 端点回退到经典工具集(`exec_command`/`apply_patch`)。
## 临时绕过
- Codex agent 改用官方 OpenAI;或
- 第三方 provider 改用 claude-code / pi agent(不受影响)。
---
**OS**: darwin arm64 (25.2.0)
**界面语言**: zh-CN
Contributor guide
Research direction
Start at the named buildCodexProxySpawnArgs entry point and inspect how the Codex command-line features are selected for third-party providers. Reproduce the Maker Codex flow with a listed provider and compare the request tools before and after the change. Done means third-party providers no longer receive an unsupported exec tool, while the supported Codex flow continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100