What You’ll Learn
This chapter covers the foundational concepts you need to build effective voice AI agents:
Architecture - How AgentBase and its mixins work together
SWML - The markup language that controls call flows
SWAIG - The gateway that lets AI call your functions
Lifecycle - How requests flow through the system
Security - Authentication and token-based function security
Prerequisites
Before diving into these concepts, you should have:
Completed the Getting Started chapter
A working agent running locally
Basic understanding of HTTP request/response patterns
The Big Picture
SignalWire Agents SDK Architecture
Key Terminology
Chapter Contents
Why These Concepts Matter
Understanding these core concepts helps you:
Debug effectively - Know where to look when things go wrong
Build efficiently - Use the right tool for each task
Scale confidently - Understand how the system handles load
Extend properly - Add custom functionality the right way
The Mixin Composition Pattern
AgentBase doesn’t inherit from a single monolithic class. Instead, it combines nine specialized mixins plus the SWMLService base class:
AgentBase mixin composition
Each Mixin’s Role
AuthMixin - Authentication & Security
Handles basic HTTP authentication for webhook endpoints.
Key methods:
Validates incoming requests against stored credentials
Generates credentials if not provided via environment
Protects SWAIG function endpoints
WebMixin - HTTP Server & Routing
Manages the FastAPI application and HTTP endpoints.
Key features:
Runs uvicorn server via agent.run()
Handles proxy detection (ngrok, load balancers)
Manages request/response lifecycle
SWMLService - SWML Document Generation
The foundation for building SWML documents.
Key responsibilities:
Validates SWML structure against JSON schema
Registers verb handlers (answer, ai, connect, etc.)
Renders final SWML JSON
PromptMixin - Prompt Management
Manages AI system prompts using POM (Prompt Object Model).
Key features:
Structured prompt building with sections
Support for bullets, subsections
Post-prompt for call summaries
Handles registration and execution of SWAIG functions.
Key features:
Multiple registration methods (define_tool, decorators, DataMap)
Parameter validation
Security token generation
SkillMixin - Skill Plugin Management
Loads and manages reusable skill plugins.
Key features:
Auto-discovery of skill modules
Dependency checking
Configuration validation
AIConfigMixin - AI Behavior Configuration
Configures the AI’s voice, language, and behavior parameters.
Key features:
Voice and language settings
Speech recognition hints
AI behavior parameters
ServerlessMixin - Deployment Adapters
Provides handlers for serverless deployments.
Key features:
Environment auto-detection
Request/response adaptation
URL generation for each platform
StateMixin - State Management
Manages session and call state.
Key features:
Session tracking
State persistence patterns
Call context management
MCPServerMixin - MCP Protocol Support
Exposes agent tools as an MCP (Model Context Protocol) server endpoint.
Key features:
MCP JSON-RPC 2.0 protocol support
Automatic tool exposure at /mcp endpoint
Converts SWAIG functions to MCP tool format
Key Internal Components
Beyond the mixins, AgentBase uses several internal managers:
Stores SWAIG functions
Handles function lookup
Generates webhook URLs
PromptManager
Manages prompt sections
Builds POM structure
Handles post-prompts
SessionManager
Token generation
Token validation
Security enforcement
SkillManager
Skill discovery
Skill loading
Configuration validation
SchemaUtils
SWML schema loading
Document validation
Schema-driven help
VerbHandlerRegistry
Verb registration
Handler dispatch
Custom verb support
Creating Your Own Agent
When you create an agent, you get all functionality automatically:
Benefits of This Architecture
Next Steps
Now that you understand how AgentBase is structured, let’s look at the SWML documents it generates.