Core Architecture
The SDK is built around these modules:Backend
Agents Backend - Get the arguments your agent loop (for example Agno) needs to run an agent.
Agents
Agents - List and load agents; read their skills and knowledge bases; start a task on one.
Tasks
Tasks - Create a task, stream its events, read its result and usage.
Skills Repository
Skills Integration - Register local skills, connect outside services, and manage skills served over MCP.
Knowledge Bases
Knowledge bases - Create a knowledge base, add documents, run a semantic search.
Events
Events - The
@on_task, @on_boot and @on_tool_* decorators the task handler is built from.Installation
Key Features
- 🤖 Agent Access: List and load agents, and work with their skills, sessions, database, and knowledge bases. Creating, updating, and deleting agents is done through the REST API or Xpander Chat
- ⚡ Task Execution: Handle complex multi-step workflows with real-time event streaming
- 🔧 Skills Integration: Register local skills and connect outside services via MCP
- 📚 Knowledge Bases: Semantic search across document repositories
- 🎯 Event-Driven: Event handling with decorators for responsive agent applications
- 🔄 Async/Sync Support: Both asynchronous and synchronous interfaces for flexibility
- 📊 Real-time Monitoring: Track agent performance, metrics, and execution in real-time
- 🏗️ Modular Architecture: Independent modules that work together
Quick Start Example
Asynchronous Usage
The REST stream ends with
task_finished for every agent type. For a CLI agent (external-harness), SDK 2.0.537 drops the turn events and aevents() can stop without yielding task_finished. After the loop, call await task.areload() and read task.result.Synchronous Usage
Event-Driven Development
The SDK supports event-driven programming with decorators for task handling and lifecycle management. A task handler serves one agent, so setXPANDER_AGENT_ID (or Configuration.agent_id) to that agent’s ID. Without it, the handler fails at start with XPANDER_AGENT_ID is required for the /invoke server.
Asynchronous Usage
Synchronous Usage
Lifecycle Management
Module Documentation
Agents Module
Load, run and manage agents, with their skills and knowledge bases
Tasks Module
Create, stream, stop and read tasks
Skills Repository
Local skill registration, outside services, and skills served over MCP
Knowledge Bases
Documents in, semantic search out
Events Module
The decorators the task handler is built from
Configuration
Configuration: API key, organization id, base URL, self-hosted endpointsTypes
Data types, enumerations, and models used across the SDK
Authentication
Credentials reach the SDK one of these ways:- Environment Variables (Recommended)
- Explicit Configuration
- From File
XPANDER_BASE_URL at your Agent Controller. The SDK adds /<organization id> to the URL itself only when the host name contains agent-controller, the port is 9016, or the path starts with /agent-controller. For any other address, either publish the controller under an agent-controller host name, or include the organization ID in the URL yourself, for example https://<controller-host>/<organization id>.Error Handling
Additional Resources
Getting Started
Begin building with xpander.ai
Quickstart
Step-by-step guide to a first agent
GitHub Repository
View source code and contribute

