Skip to main content
Agent Stack extends the A2A Protocol with A2A extensions that enable agents to access platform services and enhance the user interface beyond what the base protocol provides. Extensions fall into two categories:
  1. Service extensions: Demands in the agent card that your client fulfills (LLMs, embeddings, OAuth, secrets)
  2. UI extensions: Message metadata your UI renders (forms, approvals, citations, trajectories)
All extension definitions are exported from agentstack-sdk/extensions if you prefer a narrower import surface.

Core Helpers

The SDK includes helpers for reading and producing extension metadata:
  • extractServiceExtensionDemands(extension) reads demands from an agent card.
  • fulfillServiceExtensionDemand(extension) merges fulfillments into metadata.
  • extractUiExtensionData(extension) reads UI metadata from a message.
  • resolveUserMetadata(inputs) builds metadata for form, approval, and canvas responses.
  • handleAgentCard(agentCard) returns demands and a resolveMetadata function.
  • handleTaskStatusUpdate(event) maps status updates to actionable UI results.
  • buildMessageBuilder(agentCard) builds user messages with resolved metadata.
Use these directly when you want fine grained control beyond handleAgentCard. extractServiceExtensionDemands, fulfillServiceExtensionDemand, and extractUiExtensionData are factories. You pass an extension definition once and reuse the returned function for that extension. For end to end usage, see A2A Client Integration and User Messages.

Service Extensions

Service extensions use a dependency injection pattern. The agent declares demands and the client provides fulfillments.

LLM Service

Provides OpenAI compatible LLM access with api_base, api_key, and api_model.

Embedding Service

Provides OpenAI compatible embedding access with api_base, api_key, and api_model.

MCP

Provides Model Context Protocol transports for tool and connector access.

OAuth

Provides OAuth redirect metadata for authentication flows.

Secrets

Provides secret values required by the agent.

Settings (deprecated)

Deprecated. Planned for removal in the next release. Use Settings Form instead. This extension lives under ui/settings in the SDK, but it is treated as a service extension because it carries demands and fulfillments.

Migration guide

  • Agent cards: replace the ui/settings extension with the services/form extension and move settings fields to form_demands.settings_form.
  • Single select: change type single_select to singleselect, and change options items from { value } to { id }.
  • Checkbox group: checkbox_group now requires a non empty label.
  • Checkbox items: checkbox now requires content for the visible text. Keep label populated too and map the legacy checkbox label to content when migrating.
  • Fulfillments: change checkbox group values from { values: { [id]: { value } } } to { value: { [id]: boolean | null } }.

Form

Provides form responses when the agent requests structured input.

Settings Form

Settings UI is delivered through the Form service extension. Agents request settings with form_demands.settings_form, and clients respond with form_fulfillments.settings_form.
Prefer settings_form when both settings_form and legacy settings demands are present.

Platform API

Adds context token metadata so the agent can call platform services. This is typically used only when you cannot pass the token through A2A client headers. getContextToken is deprecated and kept for backward compatibility. Prefer passing the context token via A2A client headers when possible.
getContextToken is deprecated. Prefer sending the context token via A2A client headers when possible.

UI Extensions

UI extensions are message metadata your UI can render. The SDK includes typed schemas for extracting these payloads.

Form Request

Requests a form render payload.

Approval

Requests user approval for an action or tool call.

Canvas

Requests a canvas edit with indices and description.

Citation

Provides citation ranges and URLs for inline references.

Trajectory

Provides trace entries for reasoning or execution steps.

Agent Detail

Provides agent metadata to display in the UI. This extension is sent in the agent card capabilities, not in message metadata.

Error

Provides structured error information.

OAuth Request

Provides an OAuth authorization endpoint to redirect the user.

Secrets Request

Provides secret demand prompts.

Handling task status updates

Use handleTaskStatusUpdate to parse status updates into UI actions. This covers OAuth, secrets, forms, and approval flows.

Sending user metadata

When the user responds to a form, approval, or canvas request, use resolveUserMetadata to build message metadata:

Type Safety

All extension schemas are typed in TypeScript and validated with Zod at runtime. This helps catch malformed extension payloads early and keeps your UI logic aligned with the protocol.