Skip to content

fix(proxy): promote additional_tools input items for openai-response upstreams - #308

Open
jlu-lujing wants to merge 1 commit into
mxyhi:mainfrom
jlu-lujing:fix/additional-tools-openai-response
Open

fix(proxy): promote additional_tools input items for openai-response upstreams#308
jlu-lujing wants to merge 1 commit into
mxyhi:mainfrom
jlu-lujing:fix/additional-tools-openai-response

Conversation

@jlu-lujing

Copy link
Copy Markdown

问题

Closes #307

Codex CLI 0.150.x 将内置 code-mode exec 工具以 Responses API 的 additional_tools input item 混在 input 中发送(首次请求即包含,且无配置可关闭)。sglang / vLLM 等第三方 Responses 上游对 input 类型做严格白名单校验,直接返回:

{"error":{"code":"invalid_request_error","message":"Unsupported Responses API input item type: 'additional_tools' None"}}

导致 Codex 完全无法经由 openai-response 上游使用。

方案

xAI 上游已有相同的处理(promote_xai_additional_tools):把 additional_tools 里的工具声明提升到根 tools 数组,再删除该 input item。本 PR 将其泛化为 promote_additional_tools 并同样应用到 openai-response provider 的 /v1/responses

  • 提升时按工具名去重,避免多轮历史重复注入同名工具
  • 原生 openai provider 保持透传不变(官方 Responses API 接受该 item,且 Responses Lite 依赖 input 内声明)
  • 复用现有 filter_limit_bytes 体量上限,与其余改写一致

测试

cargo test -p token_proxy_runtime 640 passed,新增 3 个用例:

  • openai_response_promotes_additional_tools_into_root_tools
  • openai_response_promotion_skips_duplicate_tool_names
  • native_openai_keeps_additional_tools_input_items(守护原生透传)

本地实测 Codex CLI 0.150.1 → token_proxy → sglang 上游,修复后请求正常返回。

…upstreams

Codex CLI 0.150 sends its code-mode exec tools as a Responses API
`additional_tools` input item. Third-party Responses upstreams (sglang,
vLLM, ...) validate input types against a strict allowlist and reject
the item with 400 "Unsupported Responses API input item type:
'additional_tools'".

Reuse the xAI promotion path for the openai-response provider: move
declared tools into the root tools array (skipping duplicates by name)
and drop the input item. Native OpenAI keeps pass-through since its
Responses API accepts the item.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

支持 Codex CLI 0.150 的 additional_tools input item(当前 400: Unsupported Responses API input item type)

1 participant