fix: prevent regular tool_search functions from being replayed as native tool search#17446
fix: prevent regular tool_search functions from being replayed as native tool search#17446lgrammel wants to merge 2 commits into
Conversation
Bugfix reviewOutcome: changes-required Reproduction replayStatus: inconclusive The original bug signal did not appear, but the replay failed for a different reason. Concerns:
Fixes issueStatus: unclear The converter now selects all three native tool-search call/output branches only when an openai.tool_search provider tool is configured; otherwise tool_search history becomes function_call and function_call_output. Concerns:
Side effectsRisk: low The change is narrowly limited to tool-search history classification, and native serialization remains enabled when the configured provider tool ID is openai.tool_search. PerformanceRisk: none The change adds only a boolean condition to existing branches and does not introduce allocations, retained state, or additional traversal. Backwards compatibilityRisk: none No stored-data format or public API changes are introduced; existing ordinary function history is serialized correctly while configured native tool-search history retains its prior representation. SecurityRisk: none The change only controls request-item serialization and introduces no new parsing, credential handling, network destinations, or executable input paths. TestingStatus: appropriate The regression test covers both the ordinary tool_search call and result, existing native tool-search coverage remains passing, and focused mock request checks confirmed both production paths. VerificationReviewed the complete base-branch diff and relevant converter, mapping, preparation, and model code. The OpenAI package build, type check, formatting check, and complete Node and Edge test suites passed with 790 tests in each environment. A mocked public-model request check confirmed ordinary tool_search history produces function items while configured native tool search still produces native items. Approval remains blocked solely by the authoritative inconclusive exact replay. |
Background
Regular OpenAI Responses function tools named
tool_searchwere replayed as native tool-search items, causing follow-up requests to fail with HTTP 400.Root Cause
The Responses history converter selected native tool-search call and output serialization solely from the resolved tool name, without confirming that
openai.tool_searchwas configured; the reproduction confirmed this produced atool_search_callwithout required arguments.Summary
Passed the configured native tool-search state into the history converter and gated native tool-search call and output serialization on that state.
Testing
Added inline-snapshot regression coverage for replaying a regular
tool_searchfunction asfunction_callandfunction_call_output; existing native tool-search coverage remains passing.End-to-end Validation
pnpm -C packages/openai buildfollowed bypnpm -C examples/ai-functions exec tsx src/reproduction/issue-17402-tool-search-name-collision.ts— the live OpenAI request completed successfully withfunction_callandfunction_call_outputhistory.Related Issues
Fixes #17402
Closes #17430
Co-authored-by: guitard0g 11187231+guitard0g@users.noreply.github.com