Skip to content
Talk to an engineer

Canvas

Form

A long form beside the chat. The agent fills in what it knows and answers questions about the rest; its fields stay marked until the user checks them. Only the user sends it.

KindCanvas · FORM · EDIT_MODEAgent waitsNoMobileNo canvas: a progress card

Use it when: A long form (3–4 sections, 10–16 fields) the user fills in over a few turns, with the agent filling what it can find and answering questions about the rest. The user sends it from the canvas.

Use something else when: Up to ~8 fields the agent can draft in one go (form with approval card). Steps that depend on earlier answers (wizard). Mobile: the canvas isn’t available; use the progress card (mountMobile).

The template callsThe agent getsWhen
canvas.setState({ values, suggested })Canvas state600 ms after the user stops typing, and when a field loses focus. The agent sees it with the user’s next message.
canvas.setState({ submitted })Canvas stateAfter actions.submit() succeeds. The canvas switches to READ_MODE.
displayed()FUNCTION_TOOL_DISPLAYEDMobile progress card: as soon as it shows.

Besides its data, the template draws these as itself: mountState() on the canvas, mountMobileState() in the mobile card. Pick one on the preview with State.

StateWhen it shows
LoadingThe canvas opens while your app loads the form’s sections and options, and again after Try again. It stays in READ_MODE until the fields show.
ErrorThe form didn’t load, or your app refused a submit outright (no permission). A submit worth retrying keeps its inline message instead.
mountState({ root, head, title: "…", state: { kind: "error", text: "…", retry } });
mountMobileState({ root, head, title: "…", state: { kind: "error", text: "…", retry } });

The hosted action and the in-page handler below show each case. The state types are LoadingState, EmptyState and ErrorState in fs-kit.

FieldTypeNotes
titlestring
intro (optional)string
canvasTitle (optional)stringThe canvas header (setTitle, up to 80 characters). Default: title.
sectionsFormCanvasSection[]
valuesRecord<string, string>Field id to value, as text. The user and the agent both write here. A key the agent leaves out keeps its value.
suggested (optional)string[]Fields the agent filled that the user hasn’t changed yet. The form keeps this list.
submitLabel (optional)string
busyLabel (optional)string
doneTitle (optional)string
doneText (optional)string
receiptFields (optional)string[]Field ids listed on the success screen. Default: the first three required fields.
submitted (optional)FormCanvasReceiptSet by the form after a successful submit. A reopened canvas shows the success screen.
FieldTypeNotes
idstring
titlestring
description (optional)string
icon (optional)IconNameThe section card’s icon. Default: doc.
fieldsFormCanvasField[]
FieldTypeNotes
idstring
labelstring
type (optional)"text" | "email" | "tel" | "url" | "number" | "date" | "select" | "textarea"
required (optional)boolean
wide (optional)booleanFull row in the two-column layout (textareas always are).
options (optional)(string | { value: string; label: string })[]
placeholder (optional)string
hint (optional)string
prefix (optional)stringShown inside the input, e.g. ”$”.
rows (optional)number
format (optional)NumberFormatHow a number shows on the success screen.
FieldTypeNotes
submit() (optional)(values: FormCanvasValues) => Promise<{ id?: string; url?: string } | void>Sends the form through your app. Throw to show the error and keep the draft. Return { id, url } to link the record.
finish() (optional)() => voidThe success screen’s button. Default: close the canvas.

Copy the template and the shared kit into your code: agent/ui/ in an agent repo, or anywhere in your app. The template imports only ./fs-kit.js. Then wire it up from the hosted action or the in-page handler.

The hosted action needs an agent repo with one folder per action (agent/actions/<action_key>/index.ts). If your repo keeps its actions in agent/actions/index.ts, use the in-page handler: it runs the same template in your app.

All templates in machine-readable form: /ui-catalog/catalog.json.