- Service extensions: Demands in the agent card that your client fulfills.
- UI extensions: Message metadata your UI renders.
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)returnsdemandsand aresolveMetadatafunction.handleTaskStatusUpdate(event)maps status updates to actionable UI results.buildMessageBuilder(agentCard)builds user messages with resolved metadata.
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 Message Building.
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 withapi_base, api_key, and api_model.
Embedding Service
Provides OpenAI compatible embedding access withapi_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
Provides runtime configuration values that match the requested fields. This extension lives underui/settings in the SDK, but it is treated as a service extension because it carries demands and fulfillments.
Form
Provides form responses when the agent requests structured input.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. 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
UsehandleTaskStatusUpdate 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, useresolveUserMetadata to build message metadata: