Leverage UI Forms to request structured input from the user.
Import the Form extension
Add form parameter to your agent
Annotated
type hint.Define your form structure
FormRender
object with the fields you want to collect from users.Process form data
parse_form_response()
for initial forms or request_form()
for dynamic forms.FormExtensionServer
, FormExtensionSpec
, FormRender
, and field types from beeai_sdk.a2a.extensions.ui.form
.
Inject the extension: Add a form parameter to your agent function using the Annotated
type hint with FormExtensionServer
and FormExtensionSpec
.
For initial forms: Specify the form structure in the FormExtensionSpec
parameters and use parse_form_response()
to extract data from the initial message.
For dynamic forms: Use an empty FormExtensionSpec()
and call await form.request_form()
with your form definition when needed.
Access form data: Use form_data.values['field_id'].value
to access the submitted values from your form fields. Different field types return different value types:
str | None
list[FileInfo] | None
where each FileInfo
has uri
, name
, and mime_type
list[str] | None
(list of selected option IDs)bool | None
FormRender
configuration:
id
: Unique identifier for the form (required)title
: Main heading displayed above the formdescription
: Optional description text displayed below the titlecolumns
: Number of columns in the form grid (1-4)submit_label
: Custom text for the submit button (default: “Submit”)fields
: List of form field definitions (required)col_span
on individual fields to control how they span across the grid. For example, with columns=2
, a field with col_span=2
will take the full width, while col_span=1
will take half the width.