Skip to content

chore(ai): add optional ChatRequestOptions to addToolApprovalResponse and addToolOutput#11048

Merged
felixarntz merged 10 commits intovercel:mainfrom
patrikdevlin:chore/add-body-to-add-tool-approval-response
Mar 5, 2026
Merged

chore(ai): add optional ChatRequestOptions to addToolApprovalResponse and addToolOutput#11048
felixarntz merged 10 commits intovercel:mainfrom
patrikdevlin:chore/add-body-to-add-tool-approval-response

Conversation

@patrikdevlin
Copy link
Contributor

@patrikdevlin patrikdevlin commented Dec 10, 2025

Background

Users should be able to customize the api request similar to sendMessage & regenerate

Fixes: #11423

Summary

Adding optional ChatRequestOptions parameter to addToolApprovalResponse. Add-on work to #8541.

Checklist

  • Tests have been added / updated (for bug fixes / features) - n/a
  • Documentation has been added / updated (for bug fixes / features) - n/a
  • 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)

Future Work

n/a

@vercel-ai-sdk vercel-ai-sdk bot added the ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. label Dec 10, 2025
@patrikdevlin patrikdevlin mentioned this pull request Dec 10, 2025
44 tasks
/**
* Optional request options to be used when sending the message
*/
options?: ChatRequestOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this approach because it makes it seem that options is relevant to the tool approval when in reality it's only needed to automatically re-submit if that's enabled. Curious what you think @lgrammel

My initial idea was what I shared in #11423 (comment) - overloading in that way may not be the most intuitive either, but it would be closer to the root of the problem and directly associated with re-submitting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My take is that it boils down to the concrete use cases, and what data is available when/where. I.e. are the ChatRequestOption values available only when sendApprovalResponse is invoked? then this is a good place (some of the concerns can be addressed by expanding the jsdoc). If not, then another place might be better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense. They're available when invoking addToolApprovalResponse, so I think it's a good place, but the same problem also applies when calling addToolOutput. So I think we'll need to add it to both methods.

Copy link
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@patrikdevlin upon further review, the approach looks good, but can you please expand it to also cover addToolOutput?

If you can, adding test cases for the two changes would be great as well.

reason?: string;

/**
* Optional request options to be used when sending the message
Copy link
Collaborator

Choose a reason for hiding this comment

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

worth clarifying that this is only relevant if a message is actually being sent as part of this.

Suggested change
* Optional request options to be used when sending the message
* Optional request options to be used if `sendAutomaticallyWhen` callback returns true

/**
* Optional request options to be used when sending the message
*/
options?: ChatRequestOptions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per https://github.com/vercel/ai/pull/11048/changes#r2760036163, can you please add this to addToolOutput as well?

Copy link
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@patrikdevlin I have pushed a few more changes to this branch:

  • support options in addToolOutput too - equally relevant there
  • add unit tests for the changes
  • add a UI example where this is testable end-to-end

Should be good to go shortly. Thanks for helping to get this fixed!

@felixarntz felixarntz added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 5, 2026
@felixarntz felixarntz changed the title chore(ai): add optional ChatRequestOptions to addToolApprovalResponse chore(ai): add optional ChatRequestOptions to addToolApprovalResponse and addToolOutput Mar 5, 2026
@felixarntz felixarntz added the ai/ui anything UI related label Mar 5, 2026
@felixarntz felixarntz merged commit 6a3793e into vercel:main Mar 5, 2026
22 of 23 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Mar 5, 2026
…e` and `addToolOutput` (#11048)

## Background

<!-- Why was this change necessary? -->

Users should be able to customize the api request similar to sendMessage
& regenerate

Fixes: #11423

## Summary

<!-- What did you change? -->

Adding optional ChatRequestOptions parameter to addToolApprovalResponse.
Add-on work to #8541.

## Checklist

<!--
Do not edit this list. Leave items unchecked that don't apply. If you
need to track subtasks, create a new "## Tasks" section

Please check if the PR fulfills the following requirements:
-->

- ~Tests have been added / updated (for bug fixes / features)~ - n/a
- ~Documentation has been added / updated (for bug fixes / features)~ -
n/a
- [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)

## Future Work

n/a

---------

Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
@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 5, 2026
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Mar 5, 2026

✅ Backport PR created: #13107

vercel-ai-sdk bot added a commit that referenced this pull request Mar 5, 2026
…valResponse` and `addToolOutput` (#13107)

This is an automated backport of #11048 to the release-v6.0 branch. FYI
@patrikdevlin

Co-authored-by: patrik <17474633+patrikdevlin@users.noreply.github.com>
Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Mar 5, 2026

🚀 Published in:

Package Version
ai 7.0.0-beta.1
@ai-sdk/angular 3.0.0-beta.1
@ai-sdk/langchain 3.0.0-beta.1
@ai-sdk/llamaindex 3.0.0-beta.1
@ai-sdk/react 4.0.0-beta.1
@ai-sdk/rsc 3.0.0-beta.1
@ai-sdk/svelte 5.0.0-beta.1
@ai-sdk/vue 4.0.0-beta.1

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/ui anything UI related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

addToolApprovalResponse on sendAutomaticallyWhen doesn't send body

3 participants