tool( )





Pattern
HIL Tool Approval Basic
Chat assistant with human approval workflows for safe tool execution.
IntermediateOct 2025View the full pattern on desktop


Problems solved
- Intercept tool calls that require human confirmation before execution
- Resume the agent after approve or deny decisions
- Limit agent loops with stepCountIs during approval flows
- Surface pending tool approvals in a streaming chat UI
Use cases
- Content moderation queues with human sign-off
- E-commerce actions that need cart confirmation
- Admin tools that gate destructive operations
- Customer-support agents requiring human approval
AI SDK APIs
streamTextgatewaystepCountIsconvertToModelMessagestool(tools:
Tags
aihuman-in-the-loopai-sdktool-approvalchat-interfacerate-limitingsafe-aiworkflow-management
Requirements
- Node.js
- 24+
- Memory
- 512MB
- Other
- OpenAI API key
Environment variables
OPENAI_API_KEYGet key
External services
openaiupstash
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktopRelated patterns


HIL Needs Approval
Demonstrate tool approval with async generators. Includes real-time feedback, approval workflows, and interactive management.
aiagents+8
View pattern β


Tool Input Lifecycle Hooks
Explore tool input lifecycle hooks: onInputStart, onInputDelta, and onInputAvailable. See how to track tool input generation in real-time during streaming.
aitools+7
View pattern β



