Skip to content

fix: prevent regular tool_search functions from being replayed as native tool search#17446

Open
lgrammel wants to merge 2 commits into
mainfrom
bugfix/17402-2
Open

fix: prevent regular tool_search functions from being replayed as native tool search#17446
lgrammel wants to merge 2 commits into
mainfrom
bugfix/17402-2

Conversation

@lgrammel

Copy link
Copy Markdown
Collaborator

Background

Regular OpenAI Responses function tools named tool_search were 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_search was configured; the reproduction confirmed this produced a tool_search_call without 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_search function as function_call and function_call_output; existing native tool-search coverage remains passing.

End-to-end Validation

  • pnpm -C packages/openai build followed by pnpm -C examples/ai-functions exec tsx src/reproduction/issue-17402-tool-search-name-collision.ts — the live OpenAI request completed successfully with function_call and function_call_output history.

Related Issues

Fixes #17402

Closes #17430

Co-authored-by: guitard0g 11187231+guitard0g@users.noreply.github.com

@lgrammel

Copy link
Copy Markdown
Collaborator Author

Bugfix review

Outcome: changes-required

Reproduction replay

Status: inconclusive

The original bug signal did not appear, but the replay failed for a different reason.

Concerns:

  • The original reproduction could not produce conclusive verification.

Fixes issue

Status: 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:

  • The exact original reproduction could not provide valid pass/fail evidence.

Side effects

Risk: 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.

Performance

Risk: none

The change adds only a boolean condition to existing branches and does not introduce allocations, retained state, or additional traversal.

Backwards compatibility

Risk: 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.

Security

Risk: none

The change only controls request-item serialization and introduces no new parsing, credential handling, network destinations, or executable input paths.

Testing

Status: 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.

Verification

Reviewed 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/openai: function named tool_search is replayed as native tool search

1 participant