PatternsAgent Patterns

HIL Inquire Text Input

Loading pattern preview

Loading preview…

Problems solved

Technical challenges this implementation handles out of the box.
  • Pause the agent to collect free-text answers mid-loop
  • Resume ToolLoopAgent after open-ended user input
  • Gather detailed brand or requirements context through questions
  • Stop on askTextInput with hasToolCall and process responses

Use cases

Products and workflows this pattern is designed to support.
  • Discovery interviews in chat
  • Requirements gathering agents
  • Customer onboarding with open-ended prompts
  • User research intake workflows

Setup

Requirements, wiring steps, and what this pattern adds to your project.

Getting started

Pick how you want to pull this pattern in — then wire env vars and routes the same way.

  1. 1

    Install from the preview toolbar

    Shadcn Icon

    Copy the install command above and run it in your project — Pro patterns include a short-lived token.

  2. 2

    Add environment variables to .env.local

    OPENAI_API_KEY

  3. 3

    Point client fetches at your API routes

    Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.

  4. 4

    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.

  5. 5

    Run your dev server and open the pattern route

    Install dependencies if needed, then start the app and verify responses.

Environment variables

Capabilities

AI SDK APIs

AgenttoolstepCountIsvalidateUIMessagesuseChatInferAgentUIMessagegenerateObject

Providers

OpenAI

External services

Upstash

Files added

7 files
  • app/page.tsx
  • app/layout.tsx
  • app/api/inquire-text/route.ts
  • lib/ai/multiple-choice-inquire-agent.ts
  • lib/ai/tools/ask-multiple-choice-tool.ts
  • lib/tool-approval-types.ts
  • README.md

Dependencies

11 total

npm packages

6
AISDKlucide-reactNext.jsReactsonnerZod

Shadcn IconRegistry components

5
buttonemptylabeltextareatooltip

Critical files

  • ai/multiple-choice-inquire-agent.ts

    Agent implementation using ToolLoopAgent with hasToolCall('askTextInput') stop condition. Contains processTextInputToolCalls for handling free-text user answers.

  • tools/ask-multiple-choice-tool.ts

    Tool (askTextInputTool) that dynamically generates text input questions with placeholders using generateObject.

Requirements

Complexity
Intermediate
Setup time
~15 minutes
Node
24+
Memory
512MB
Upstash Redis