Handle OpenAI Responses tool_search input items#312
Handle OpenAI Responses tool_search input items#312Ken Jiang (knjiang) wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c27f502bf5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| let provider_executed = if matches!( | ||
| input.execution.as_ref(), | ||
| Some(openai::ToolSearchExecutionType::Server) | ||
| ) { | ||
| Some(true) | ||
| } else { | ||
| None |
There was a problem hiding this comment.
Preserve client tool_search items on re-export
When a Responses request contains a client-executed tool_search_call, this branch records it as a normal non-provider-executed tool call. The Responses exporter treats those as function_call items, so importing and then re-emitting the same history changes tool_search_call/tool_search_output into ordinary function-call items and loses the typed execution/tools wire shape that OpenAI expects for tool-search history. Preserve enough typed state here, or teach the Responses exporter to emit tool_search_* for tool_name == "tool_search".
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 964b4b0d87
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| })); | ||
| } | ||
|
|
||
| let anthropic_tool = Tool::try_from(tool)?; |
There was a problem hiding this comment.
Normalize Responses discovery tools before Anthropic serialization
When a Responses request uses the normal dynamic-discovery tool config (tools entries like {"type":"tool_search"} or {"type":"namespace"}), parse_openai_responses_tools_array stores those as BuiltinToolProvider::Responses. This new Anthropic serialization path only special-cases Anthropic builtins before calling Tool::try_from, which rejects Responses builtins, so Responses→Anthropic fails instead of emitting the equivalent tool_search_tool_regex and deferred tools. Normalize or filter Responses discovery tools before this conversion.
Useful? React with 👍 / 👎.
| ToolContentPart::ToolResult(result) => Some(result), | ||
| ToolContentPart::ToolDiscoveryResult(_) => None, |
There was a problem hiding this comment.
Avoid emitting empty Bedrock messages for discovery results
For a Responses history containing a tool_search_output, the universal Tool message contains only ToolDiscoveryResult; this filter drops every part, and universal_to_bedrock_messages still pushes a Bedrock user message with content: []. That produces an invalid/meaningless Converse request instead of either dropping discovery-only messages at the message level or returning an explicit unsupported-mapping error.
Useful? React with 👍 / 👎.
| for item in &result.tools { | ||
| item.tool_name.hash(hasher); |
There was a problem hiding this comment.
Include discovered tool definitions in the dedup key
If two imported tool_search_output messages have the same call id and tool names but different returned tool definitions (for example a schema/strictness change), deduplication treats them as identical because only tool_name is hashed. Since ToolDiscoveryResultItem.tool carries the actual definition that is later re-exported to Responses/Anthropic, the second result can be dropped and leave stale tool metadata in the conversation.
Useful? React with 👍 / 👎.

Summary
Handle OpenAI Responses
tool_search_callandtool_search_outputinput items in Lingua instead of falling through tothe generic message converter and failing on missing
role.Changes
ToolSearchCall/ToolSearchOutputitems.responsesToolSearchInputParampayload case usinggpt-5.5.