Confirmations & Plans

Pattern

Tool Approval

Demonstrate tool execution with user confirmation. Includes approval workflows, confirmation UI, and state management for safe AI operations.

BeginnerOct 2025View the full pattern on desktop
Tool Approval preview

Problems solved

  • Require user confirmation before a needsApproval tool runs
  • Demonstrate the AI SDK built-in approval mechanism for delete_file
  • Keep pending approval state visible in the chat UI

Use cases

  • File-deletion confirmations in assistants
  • Destructive admin actions gated by the user
  • Teaching needsApproval tool flows
  • Safe tool execution demos

AI SDK APIs

streamTextconvertToModelMessagesuseChataddToolApprovalResponse

Tags

aitool-approvalconfirmationai-sdkopenaihuman-in-the-loopsafe-aiworkflow

Requirements

Node.js
24+
Memory
512MB
Other
  • OpenAI API key

Environment variables

External services

openai

Ready to use?

View the full interactive pattern with live preview and copy the source code.

View the pattern on desktop

Related patterns