feat: add tool approval feature for human-in-the-loop workflows#79
Draft
iwasrobbed wants to merge 1 commit into
Draft
feat: add tool approval feature for human-in-the-loop workflows#79iwasrobbed wants to merge 1 commit into
iwasrobbed wants to merge 1 commit into
Conversation
Port Vercel AI SDK's tool approval feature to Rust, allowing tools to require user confirmation before execution. - Add NeedsApproval enum (Always, Never, Dynamic) matching Vercel's boolean | function pattern - Add ToolApprovalRequest/Response types with approval_id flow - Add needs_approval field to Tool struct with builder support - Implement non-blocking approval flow in generate_text and stream_text - Add pending_tool_approvals() and has_pending_approvals() helpers - Add Message::ToolApproval variant for approval responses - Update all provider conversions to handle new message types - Add comprehensive unit tests (29 new tests) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
🤖 Generated with Claude Code | Opus 4.5 by directly reading Vercel's AI SDK's latest main branch
TODO
Summary
Adds tool approval functionality allowing tools to require user confirmation before execution, matching the Vercel AI SDK's
needsApprovalpattern.NeedsApprovalenum withAlways,Never, andDynamicvariantsToolApprovalRequestandToolApprovalResponsetypes for the approval flowneeds_approvalfield onToolstruct and builderpending_tool_approvals()andhas_pending_approvals()methods on response typesMessage::ToolApprovalvariant for sending approval responsesUsage
Test plan
NeedsApprovalenum variantsToolApprovalRequest/ToolApprovalResponseserializationcollect_tool_approvals()andhas_pending_approval_requests()Related Issue
Closes #77
Type of Change
Checklist