A2UIAction
autogen.agents.experimental.a2ui.actions.A2UIAction dataclass #
A2UIAction(name, action_type='event', tool_name=None, description='', example_context=None, example_args=None)
Defines an action that can be triggered by A2UI buttons.
Actions are registered on an A2UIAgent and define how button clicks are handled. There are two action types matching the A2UI spec:
- event (server action): Dispatches a named event to the server. The
namefield matches the button'sevent.name. Optionally routed to a tool viatool_name, or handled by the LLM. - functionCall (client action): Executes a client-side function (e.g.,
openUrl) without server communication. Thenamefield is the function name andexample_argsshows the expected arguments.
| PARAMETER | DESCRIPTION |
|---|---|
name | Action identifier. For TYPE: |
action_type | The action type — TYPE: |
tool_name | Name of a registered tool/function on the agent to call when this action is triggered. Only applicable to TYPE: |
description | Human-readable description of what this action does. Injected into the system prompt so the LLM knows what actions are available. TYPE: |
example_context | Example context dict for |
example_args | Example args dict for |
Example::
# Server action routed to a tool
A2UIAction(
name="schedule_2pm",
tool_name="schedule_posts",
description="Schedule all posts for 2:00 PM",
example_context={"time": "2:00 PM"},
)
# Server action handled by the LLM
A2UIAction(
name="rewrite_previews",
description="Regenerate all previews with a different creative angle",
)
# Client-side action
A2UIAction(
name="openUrl",
action_type="functionCall",
description="Open a URL in the user's browser",
example_args={"url": "https://example.com"},
)