Human-in-the-Loop

Pattern
HIL Inquire Multiple Choice
Gather information through AI-driven multiple choice questions. Includes approval workflows and real-time rendering.
IntermediateOct 2025View the full pattern on desktop


Problems solved
- Pause the agent to ask structured multiple-choice questions
- Resume ToolLoopAgent after the user selects an answer
- Collect brand or preference context through guided choices
- Stop the loop on the inquire tool with hasToolCall
Use cases
- Brand intake questionnaires
- Onboarding surveys inside an agent
- Preference gathering for recommendations
- Customer research chats with constrained answers
AI SDK APIs
new Agenttool(stepCountIsvalidateUIMessagesuseChatInferAgentUIMessageToolLoopAgentconvertToModelMessagescreateUIMessageStreamcreateUIMessageStreamResponsegatewaygenerateObjectstreamText
Tags
aihuman-in-the-loopmultiple-choiceinteractive-questionsapproval-workflowsai-sdkbrand-contextstrategic-questioningtool-approvalstreaming
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 desktop






