Skip to content

Handle OpenAI Responses tool_search input items#312

Open
Ken Jiang (knjiang) wants to merge 3 commits into
mainfrom
06-19-handle_openai_responses_tool_search_input_items
Open

Handle OpenAI Responses tool_search input items#312
Ken Jiang (knjiang) wants to merge 3 commits into
mainfrom
06-19-handle_openai_responses_tool_search_input_items

Conversation

@knjiang

@knjiang Ken Jiang (knjiang) commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Handle OpenAI Responses tool_search_call and tool_search_output input items in Lingua instead of falling through to
the generic message converter and failing on missing role.

Changes

  • Add typed conversion for Responses ToolSearchCall / ToolSearchOutput items.
  • Add a responsesToolSearchInputParam payload case using gpt-5.5.
  • Capture live Responses snapshots and cross-provider transforms for the new case.
  • Document narrow expected cross-provider differences where target formats cannot preserve tool result names.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@knjiang Ken Jiang (knjiang) marked this pull request as ready for review June 19, 2026 05:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +987 to +993
let provider_executed = if matches!(
input.execution.as_ref(),
Some(openai::ToolSearchExecutionType::Server)
) {
Some(true)
} else {
None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +275 to +276
ToolContentPart::ToolResult(result) => Some(result),
ToolContentPart::ToolDiscoveryResult(_) => None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +249 to +250
for item in &result.tools {
item.tool_name.hash(hasher);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant