Skip to content

feat(openai): add new tool search tool#13157

Merged
aayush-kapoor merged 19 commits intomainfrom
aayush/openai-tool-search
Mar 17, 2026
Merged

feat(openai): add new tool search tool#13157
aayush-kapoor merged 19 commits intomainfrom
aayush/openai-tool-search

Conversation

@aayush-kapoor
Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor commented Mar 6, 2026

Background

OpenAI introduced a new tool along with the release of GPT 5.4

https://developers.openai.com/api/docs/guides/tools-tool-search

API spec here: https://developers.openai.com/api/reference/resources/responses/methods/retrieve

Summary

  • added the new tool spec
  • ensure tool conversion takes place properly

Manual Verification

verified by running the examples:

  • examples/ai-functions/src/generate-text/openai/responses-tool-search.ts
  • examples/ai-functions/src/stream-text/openai/responses-tool-search.ts
  • ‎examples/ai-functions/src/generate-text/openai/responses-client-tool-search.ts‎
  • ‎examples/ai-functions/src/stream-text/openai/responses-client-tool-search.ts‎
  • UI examples
    • ran http://localhost:3000/chat/openai-tool-search with store:false and store:true
    • http://localhost:3000/chat/openai-tool-search-client with store:false and store:true

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

@tigent tigent bot added ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label feature New feature or request provider/openai Issues related to the @ai-sdk/openai provider labels Mar 6, 2026
aayush-kapoor added a commit that referenced this pull request Mar 6, 2026
## Background

faced the issue while implementing #13157 - for multiturn conversation,
the item Ids weren't properly being mapped within aisdk and there was a
mismatch between what we were sending to the openai api and what was
expected.

we were attching the same tool call id as the `tool-call` object to the
`tool-result` which caused duplicate ID found errors + incorrect ids
sent for certain parts

## Summary

- since the item_id for tool_search_output is propagated via
providerMetadata - we ensure the providerMetadata is preserved through
the UI stream.
- similar change needed for generate text as well

## Manual Verification

will be done in #13157 

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
vercel-ai-sdk bot pushed a commit that referenced this pull request Mar 6, 2026
## Background

faced the issue while implementing #13157 - for multiturn conversation,
the item Ids weren't properly being mapped within aisdk and there was a
mismatch between what we were sending to the openai api and what was
expected.

we were attching the same tool call id as the `tool-call` object to the
`tool-result` which caused duplicate ID found errors + incorrect ids
sent for certain parts

## Summary

- since the item_id for tool_search_output is propagated via
providerMetadata - we ensure the providerMetadata is preserved through
the UI stream.
- similar change needed for generate text as well

## Manual Verification

will be done in #13157 

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

Unresolved merge conflict markers in two files cause build failure with "Unexpected <<" and "Merge conflict marker encountered" errors.

Fix on Vercel

@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 9, 2026
@viktorlarsson
Copy link
Copy Markdown
Contributor

@aayush-kapoor is this still in progress?

@aayush-kapoor aayush-kapoor merged commit 156cdf0 into main Mar 17, 2026
19 checks passed
@aayush-kapoor aayush-kapoor deleted the aayush/openai-tool-search branch March 17, 2026 17:12
@aayush-kapoor
Copy link
Copy Markdown
Collaborator Author

@viktorlarsson sorry, just needed to be reviewed. should be out soon

vercel-ai-sdk bot pushed a commit that referenced this pull request Mar 17, 2026
@vercel-ai-sdk vercel-ai-sdk bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 17, 2026
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Mar 17, 2026

⚠️ Backport to release-v6.0 created but has conflicts: #13534

@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Mar 17, 2026

🚀 Published in:

Package Version
@ai-sdk/azure 4.0.0-beta.9
@ai-sdk/openai 4.0.0-beta.9

aayush-kapoor added a commit that referenced this pull request Mar 17, 2026
This is an automated backport of #13157 to the release-v6.0 branch. FYI
@aayush-kapoor
This backport has conflicts that need to be resolved manually.

### `git cherry-pick` output

```
Auto-merging packages/openai/src/responses/convert-to-openai-responses-input.ts
Auto-merging packages/openai/src/responses/openai-responses-language-model.test.ts
CONFLICT (content): Merge conflict in packages/openai/src/responses/openai-responses-language-model.test.ts
Auto-merging packages/openai/src/responses/openai-responses-language-model.ts
Auto-merging packages/openai/src/responses/openai-responses-prepare-tools.ts
error: could not apply 156cdf0... feat(openai): add new tool search tool (#13157)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
```

---------

Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com>
Co-authored-by: Aayush Kapoor <aayushkapoor34@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label feature New feature or request provider/openai Issues related to the @ai-sdk/openai provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants