What the SDK Provides
| Feature | Purpose |
|---|---|
| Server wrapper | Simplified server creation and agent registration |
| Convenience wrappers | Simplified message types like AgentMessage that reduce boilerplate |
| Context management | Built-in conversation history and state management |
| Async generator pattern | Natural task-based execution with pause/resume capabilities |
| Dependency Injection Extensions | Dependency injection for LLM service, RAG embeddings, file storage and MCP integration |
| UI Extensions | Enables advanced interactive components including forms, citations and trajectory |
Server Wrapper Example
Here we show server creation and agent registration:- Create a
Serverinstance and - Register your agent function
Advanced Server SDK Example
Here’s an example that incorporates multiple Server SDK capabilities:- Use the Asynchronous Generator Pattern to await the form request and pause the task while the user completes the form.
- UI Extensions are used to create the forms and add the metadata to messages.
Asynchronous Generator Pattern
Agent functions are asynchronous generators that yield responses. This pattern aligns with A2A’s task model:- One function execution = One A2A task
- Yielding data = Sending messages to the client
- Pausing execution = Waiting for user input
- Stream responses incrementally
- Yield multiple messages during a single task
- Handle long-running operations gracefully
Extension System
Agent Stack utilizes A2A extensions to extend the protocol with Agent Stack-specific capabilities. They enable your agent to access platform services and enhance the user interface beyond what the base A2A protocol provides. There are two types of extensions:UI Extensions
UI extensions add extra metadata to messages, enabling the Agent Stack UI to render more advanced interactive components:- Forms: Collect structured user input through interactive forms
- Citations: Display source references with clickable inline links
- Trajectory: Visualize agent reasoning steps with execution traces
Dependency Injection Service Extensions
Service extensions use a dependency injection pattern where each run of the agent declares a demand that must be fulfilled by the client (consumer). The platform provides configured access to external services based on these demands:- LLM Service: Language model access with automatic provider selection
- Embedding Service: Text embedding generation for RAG
- Platform API: File storage, vector databases, and platform services
- MCP: Model Context Protocol integration