AgentBase
What You’ll Learn
This chapter covers everything you need to build production-quality agents:
- AgentBase - The foundation class and its capabilities
- Static vs Dynamic - Choosing the right pattern for your use case
- Prompts & POM - Crafting effective prompts with the Prompt Object Model
- Voice & Language - Configuring voices and multi-language support
- AI Parameters - Tuning conversation behavior
- Hints - Improving speech recognition accuracy
- Call Flow - Customizing when and how calls are answered
Prerequisites
Before building agents, you should understand:
- Core concepts from Chapter 2 (SWML, SWAIG, Lifecycle)
- Basic Python class structure
- How SignalWire processes calls
Agent Architecture Overview

A Complete Agent Example
Here’s what a production agent looks like across all supported languages:
Python
TypeScript
Chapter Contents
Key Patterns
Pattern 1: Class-Based Agent
Best for complex agents with multiple functions:
Pattern 2: Functional Agent
Quick agents for simple use cases:
Pattern 3: Multi-Agent Server
Multiple agents on one server:
Testing Your Agent
Always test before deploying:
Class Overview

Constructor Parameters
The constructor accepts the agent name plus optional configuration:
Full Python constructor with all options:
Parameter Reference
Creating an Agent
Method 1: Class-Based (Recommended)
Method 2: Instance-Based
Method 3: Declarative (PROMPT_SECTIONS)
Key Methods
Configuration Methods
Runtime Methods
Agent Lifecycle

Configuration File
Load configuration from a YAML/JSON file:
Environment Variables
AgentBase respects these environment variables:
Multi-Agent Server
Run multiple agents on one server:
Access agents at:
http://localhost:3000/supporthttp://localhost:3000/sales
Best Practices
- Use class-based agents for anything beyond simple prototypes
- Organize configuration into logical private methods
- Set explicit credentials in production via environment variables
- Use meaningful agent names for logging and debugging
- Test with swaig-test before deploying