Skip to content

[Bug] 非 OpenAI 上游模型(muse/Meta API)使用 subagent 报 'custom tools are not supported on this endpoint' #445

Description

@CHENJIAMIAN

版本

  • Codex CLI 0.149.0(model_catalog_json 自建目录)
  • Codex-Manager 本地网关(portable 版,2026-08-18)
  • 上游:Meta 的 muse-spark-1.2-contributor(Meta Model API,经网关 "Console Go" 转发)

影响范围

Gateway / Request Rewriting(use_codex_compat_rewrite / normalize_dynamic_tools_to_tools

环境信息

  • Windows 11 + codex-cli
  • model_provider = custom -> http://localhost:48760(CodexManager)
  • my-custom-models.jsonmuse-spark-1.2-contributor 配置 multi_agent_version = "v2"

复现步骤

  1. muse-spark-1.2-contributor 发起需要派生子代理的请求(如 codex exec --model muse-spark-1.2-contributor,prompt 明确要求调用 spawn_agent)。
  2. 观察本地日志与上游返回。

实际结果

两个现象(取决于模型目录条目):

A. 使用 muse 原始条目时,本地 router 直接拒绝(请求未发出):

ERROR codex_core::tools::router: error=unsupported call: collaboration.spawn_agent
ERROR codex_core::tools::router: error=unsupported call: collaboration.list_agents

工具在 prompt 中声明可见,但执行层全部 unsupported call

B. 将 muse 条目临时克隆成 deepseek-v4-flash 的字段(仅改 slug/display_name)后,工具可在本地暴露,请求发出但被上游拒绝:

ERROR: unexpected status 502 Bad Gateway: type=invalid_request_error param=tools
Error from provider (Console Go): Upstream request failed: [invalid_request_error]
`custom` tools are not supported on this endpoint
url: http://localhost:48760/responses

对照:同一环境、同一 CLI、同一网关下,deepseek-v4-flash(同样 multi_agent_version=v2)可以正常派生子代理(子代理进程真实创建并可 wait/send_message)。

预期结果

  • 非 OpenAI 上游模型(如 Muse / Meta API)也能正常使用 Codex 多代理(subagent)。
  • 至少应给出明确的能力提示/降级,而不是 unsupported call 或 502。

根因分析(参考仓库源码 / DeepWiki)

v2 多代理的 collaboration.spawn_agent 等工具是以 custom/dynamic tools 形式随请求发送的。仓库中的 normalize_dynamic_tools_to_tools 会把 dynamicTools 转成标准 function 工具,但该转换只在 use_codex_compat_rewrite == true 时应用;而 should_apply_codex_responses_compat 要求目标上游 URL 包含 /backend-api/codex(即官方 Codex 后端)才返回 true。

  • deepseek 的上游端点支持 custom tools,因此无需转换即可工作;
  • muse 走 Meta API("Console Go"),URL 不含 /backend-api/codex,转换规则不生效,custom tools 原样转发给 Meta API,被其拒绝(custom tools are not supported on this endpoint)。

建议

  1. use_codex_compat_rewrite / normalize_dynamic_tools_to_tools 对非 Codex 上游(如 Meta / 其他 OpenAI 兼容端点)也按需启用,或提供按模型/上游配置的开关。
  2. 增加对上游是否支持 custom tools 的能力探测,不支持时给出明确提示或自动降级,避免 unsupported call / 502 的裸错误。
  3. 补充请求日志,区分"本地工具被禁用"与"上游拒绝工具格式"两类原因。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions