Dependency Injection Service Extensions
Service extensions use a dependency injection pattern where agents declare demands that must be fulfilled by the client (your application). The client provides configured access to external services based on these demands. When an agent card is received,handleAgentCard extracts the service extension demands. You then provide fulfillment functions that resolve these demands with actual service configurations:
- LLM Service: Language model access with automatic provider selection
- Embedding Service: Text embedding generation for RAG
- MCP: Integrating pre-defined connectors
- OAuth Provider: OAuth authentication services
- Secrets: Secure credential management
- Settings: Runtime configuration access
- Form: Form service for structured data collection
UI Extensions
UI extensions add extra metadata to messages, enabling your custom UI to render advanced interactive components beyond standard text responses:- Forms: Collect structured user input through interactive forms
- Citations: Display source references with clickable inline links
- Trajectory: Visualize agent reasoning steps with execution traces
- Canvas: Handle visual editing and canvas-based interactions
- Agent Detail: Display agent-specific information and metadata
- Error: Render structured error messages
- OAuth: Handle OAuth authentication flows
- Settings: Display and manage agent settings
Providing metadata
A2A extensions travel in message metadata. When you receive an agent card, callhandleAgentCard(agentCard) to:
- Extract extension demands
- Get a
resolveMetadata(fulfillments)helper that builds the metadata the agent expects
fulfillments object with functions that resolve demands (dependency injection). Many fulfillments can be powered by the Platform API client—for example, using platform-provided LLM or embedding services.
Common fulfilment resolvers
The SDK ships an LLM fulfillment resolver you can wire up quickly:- Use
buildLLMExtensionFulfillmentResolver(api, contextToken)to return a resolver forLLMdemands. It matches suggested models via the Platform API and returns the fulfillment payload automatically. - Feed this resolver into your
fulfillments.llmcallback when callingresolveMetadata(fulfillments).