Conversation
…alNeeded and remove obsolete is-approval-needed.ts file.
…Needed and delete unused is-approval-needed.ts file.
…configuration into streamText and createExecuteToolsTransformation functions, and update related tests for improved clarity and functionality.
…n to ToolNeedsApprovalConfiguration across multiple files and remove obsolete tool-approval-configuration.ts and related test file.
…tency and clarity, updating related logic and tests accordingly.
…pe definitions, enhance tests for approval handling in generate and stream methods, and clarify approval logic in comments.
nicoalbanese
approved these changes
Apr 16, 2026
24 tasks
lgrammel
added a commit
that referenced
this pull request
Apr 20, 2026
## Background Specifying `needsApproval` does not make sense for provider-executed tools which run automatically on the provider side (see #14480 ). In order to filter out provider-executed tools, we need to first distinguish provider-defined from provider-executed tools. A provider tool can be: - provider-defined: the provider specifies input (and sometimes output) schemas, but the execution function is used defined. The tool is executed by the AI SDK. - provider-executed: the provider specifies input and output schemas. There is no user-defined execution function. The tool is executed by the provider as part of their response. ## Summary * introduce `isProviderExecuted` flag on provider tools * split `ProviderToolFactory` and related factory functions into `ProviderDefinedToolFactory` and `ProviderExecutedToolFactory`` * update provider tools ## Future Work * exclude provider-executed tools from `toolNeedsApproval` function ## Related Issues Separates provider-executed from provider-defined tools to enable fixing the limitation from #14480
lgrammel
added a commit
that referenced
this pull request
Apr 20, 2026
# Background We want to enhance the tool approval function to allow for automatic accept or reject without user interaction. The name `toolApproval` is shorter and much better aligned with that desired API. ## Summary * rename `toolNeedsApproval` to `toolApproval` * rename `ToolNeedsApprovalConfiguration` to `ToolApprovalConfiguration` ## Future Work * change tool approval function outputs to "not-applicable", "approved", "rejected", "user-approval" ## Related Issues Builds on #14480
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
You may want to enable or disable tool approvals for specific tools, irrespective of the tool approval setting on the tool itself. This is particularly relevant for 3rd party tools where you cannot control the
needsApprovalsetting without wrapping the tool.Summary
Introduce
toolNeedsApprovaloption ongenerateText,streamText, andToolLoopAgent. ThetoolNeedsApprovaloption takes precedence over theneedsApprovalproperty that might be defined on a specific tool.Example
Limitations
Provider-executed tools will get executed provider-side without considering the tool approval setting.
Manual Verification
examples/ai-functions/src/generate-text/openai/tool-approval-user-defined.tsexamples/ai-functions/src/stream-text/openai/tool-approval-user-defined.tsexamples/ai-functions/src/agent/openai/generate-tool-approval.tsFuture Work
isProviderExecutedflag on tools and exclude from approval listtoolNeedApproval