Loading preview…
Loading preview…
Chat assistant with human approval workflows for safe tool execution.
Loading preview…
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in — then wire env vars and routes the same way.
Install from the preview toolbar
Copy the install command above and run it in your project — Pro patterns include a short-lived token.
Add environment variables to .env.local
OPENAI_API_KEY, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN
Point client fetches at your API routes
Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions for your product — Copy for AI in the toolbar helps seed that work.
Run your dev server and open the pattern route
Install dependencies if needed, then start the app and verify responses.
AI SDK APIs
streamTextgatewaystepCountIsconvertToModelMessagestoolProviders
External services
app/page.tsxapp/layout.tsxapp/api/human-in-loop/route.tslib/tools.tslib/utils.tsREADME.mdnpm packages
6
Registry components
human-in-loop/route.tsAPI route implementing the human-in-the-loop pattern. Uses processToolCalls() to intercept tool calls that require human confirmation before execution. Passes executor functions for tools without execute. Uses stepCountIs(5) to limit agent loops.
lib/tools.tsDefines 7 AI tools demonstrating the human-in-the-loop pattern. 5 tools lack execute functions (requiring human approval): getWeatherInformation, moderateContent, addToCart, approveUser, processPayment. 2 tools have execute functions (auto-execute): webSearch, getLocalTime.
lib/utils.tsCore utility implementing the processToolCalls pattern for human-in-the-loop flows. Processes tool parts from the last message, checks for APPROVAL.YES/NO strings, executes approved tools via provided executor functions, and streams results back via UIMessageStreamWriter.
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Chat assistant with human approval workflows for safe tool execution.

All patterns include interactive previews and complete source files.
What you unlock: