Input Request
Pause an agent mid-run to ask for structured input, say why it needs it and what it does next, and send nothing until the person chooses to.
Overview
Input Request is the form an agent shows when it stops mid-run and needs values it cannot decide on its own. It says what the agent is asking for, why, and what it will do next, then collects typed fields: text, longer text, numbers, a choice, several choices, a date, and yes or no.
Take a migration agent with a finished plan. It cannot choose between staging and production, or pick a maintenance date. It pauses and shows a request. The person fills it in and presses Send, and your onSubmit receives the values and resumes the run.
It extends Approval Card and shares its look. Use Approval Card for one or more multiple-choice questions asked in turn. Use Input Request when the agent needs typed values in one form.
Input Request does not talk to your agent. It collects the values and passes them to onSubmit.
Anatomy
- HeaderWho is asking, the request, and why the agent needs it
- FieldsEach field with its label, Required or Optional, help, and error
- Next stepWhat the agent does with the answers
- FooterThe deadline, then Cancel run, Skip, and Send
- SummaryWhat was sent, once the request is answered
Installing input-request brings Approval Card, Button, Checkbox, Input, Select, Switch, and Textarea along as registry dependencies.
Behavior
Fields
Each field comes from a plain object with an id, a type, and a label. required marks it as Required; others read Optional. help adds a line under the label, and defaultValue fills it in. Text fields take minLength, maxLength, and a pattern with its own message. Numbers take min, max, step, and a unit. Dates take min and max as YYYY-MM-DD.
Sending
Send checks every field with validateInputRequest. If any fail, each shows its message, a line above the fields counts them, and focus moves to the first one. Fixing a field clears its message.
onSubmit receives a value for every field, keyed by id. Text is trimmed, and empty text, numbers, dates, and choices are null. Several choices are an array, and yes or no is a boolean.
If onSubmit returns a promise, the form shows "Sending…" and locks its controls until it settles. When it resolves, the form becomes a summary of what was sent. When it rejects, the form keeps every value and offers Send again.
Skip and cancel
Pass onSkip to let the run continue without the input, and onCancelRun to stop the run. Each button appears only when you handle it, and each replaces the form with a line saying what happened.
Finished requests
Pass status to show a request that has already finished, such as when a conversation is reloaded: "submitted" with submittedValues shows the summary, and "skipped", "cancelled", and "expired" show their line. deadline adds a line to the footer, such as when the run stops waiting.
Accessibility
The form is a group named by the request and described by the reason. Every field has a visible label tied to its control. Help and error lines are attached with aria-describedby, and an invalid field is marked with aria-invalid. Several choices are a group of checkboxes named by the field's label, and yes or no is a switch.
The count of fields that need attention is an alert. The line that replaces a finished form is a status, and focus moves to the card so it is not lost.
The pulsing dot beside "needs your input" stops with reduced motion.
Installation
Usage
import { InputRequest } from "@/components/ai/input-request"
<InputRequest
agent="Migration agent"
title="Where and when should I run the orders migration?"
reason="I can't pick the environment or a maintenance date on my own."
nextStep="Back up the orders table, then migrate in batches."
fields={[
{
id: "environment",
type: "select",
label: "Target environment",
required: true,
options: [
{ value: "staging", label: "Staging" },
{ value: "production", label: "Production" },
],
},
{ id: "window", type: "date", label: "Maintenance date", required: true },
]}
onSubmit={(values) => resumeRun(run.id, values)}
onSkip={() => resumeRun(run.id, null)}
onCancelRun={() => cancelRun(run.id)}
/>Examples
Finished requests
A request that was answered, as shown after a reload, and one that expired.
API reference
InputRequest
Accepts native div props beyond those listed.