Repository navigation
fix(apicompat): map ToolSearch to native tool_search for Codex OAuth - #8804
Conversation
The Messages to Responses bridge turned every ToolSearch tool_result made of tool_reference blocks into "(empty)" and sent every defer_loading tool as a top-level function. On ChatGPT/Codex accounts whose model reports supports_search_tool (Grok excluded, xAI has no tool_search) ToolSearch now maps to the native client-executed tool_search, history becomes tool_search_call and tool_search_output carrying the revealed definitions, and an upstream tool_search_call comes back as a ToolSearch tool_use on both the streaming and buffered paths. Deferred tools stay out of the top-level tools so the prompt cache prefix is the same before and after a reveal. Requests that do not declare ToolSearch are left untouched.
|
AI-assisted local review of
Validation on Go 1.27.4/macOS arm64: 3 failing leaf scenarios and 8 passing controls through |
A revealed tool was declared in tool_search_output under its own name while its replayed function_call used the Codex reserved-name alias, so the two disagreed for python. Reserved-name collection now walks tool_search_output tools like additional_tools. The collector is shared with the /v1/responses passthrough entries, so they now alias tool_search_output definitions too. The Responses API has no tool_choice value that forces tool_search or a tool that only tool_search_output declares, so a request forcing ToolSearch or a deferred tool keeps the plain function mapping and its body is unchanged. tool_search_output has no field for the result text, so text and errors from a ToolSearch result ride in a separate input_text part of the user message after the tool outputs, ahead of the user's own parts.
|
3f1a7c6 collects reserved names from |
|
Thanks — I rechecked I additionally checked six streamed/buffered cases where the revealed definition is the only occurrence of the function name, with no previous function call to seed the reverse map. The full |
Refs #8802
On Codex OAuth accounts whose model reports
supports_search_tool, ToolSearch maps to the native Responsestool_searchwithexecution: clientand deferred tools stay out oftools.toolsis identical before and after a reveal, so the cached prefix survives.(empty)for a tool_reference resulttool_search_callandtool_search_outputwith the referenced definitionsinput_textpart in the next user message,tool_search_outputhas no field for ittool_searchpythontoolsandfunction_calltool_search_outputdefinitions, on the/v1/responsesHTTP and WebSocket passthrough tooOther bridge accounts and requests that don't declare ToolSearch are unchanged. So is Grok, since sub2api already lowers
tool_searchto a function for xAI.Shapes follow openai/codex
ToolSpec::ToolSearch,ResponseItem::ToolSearchCallandResponseItem::ToolSearchOutput. Loaded tools are plain functions withdefer_loading, as Codex sent them before it wrapped them in thefunctionsnamespace.On a Codex OAuth account with gpt-6-astra at this head, streamed and not: a ToolSearch
tool_use, then after a tool_result holding only a tool_reference atool_usefor the revealed tool. An is_error result with text returns 200. A revealed tool namedpythoncomes back aspython, also on/v1/responsesover HTTP and WebSocket.