Agent Base
Reference
Complete API reference for all SignalWire Agents SDK classes, methods, CLI tools, and configuration options.
This chapter provides detailed reference documentation for the SignalWire Agents SDK.
Reference Overview
API Reference
- AgentBase - Main agent class with all methods
- SWMLService - Base service for SWML generation
- SwaigFunctionResult - Function return values and actions
- DataMap - Serverless REST API integration
- SkillBase - Custom skill development
- ContextBuilder - Multi-step workflows
CLI Tools
- swaig-test - Test agents and functions locally
- sw-search - Build and query search indexes
- sw-agent-init - Create new agent projects
Configuration
- Environment Variables - Runtime configuration
- Config Files - YAML/JSON configuration
- SWML Schema - Document structure reference
Quick Reference
Creating an Agent
Defining a Function
Returning Actions
Import Patterns
Chapter Contents
Class Definition
Constructor
Constructor Parameters
Prompt Methods
prompt_add_section
Add a section to the agent’s prompt.
prompt_add_text
Add raw text to the prompt.
get_prompt
Get the complete prompt. Returns POM structure if use_pom=True, otherwise plain text.
Language and Voice Methods
add_language
Add a supported language with voice configuration.
set_voice
Set the default voice for the agent.
Tool Definition Methods
tool (decorator)
Decorator to register a SWAIG function.
define_tool
Programmatically define a SWAIG function.
Skill Methods
add_skill
Add a skill to the agent.
list_available_skills
List all available skills.
AI Configuration Methods
set_params
Set AI model parameters (temperature, top_p, etc.).
add_hints
Add speech recognition hints.
add_pronounce
Add pronunciation rules.
State Methods
set_global_data
Set initial global data for the agent session.
URL Methods
get_full_url
Get the full URL for the agent endpoint.
set_web_hook_url
Override the default webhook URL.
set_post_prompt_url
Override the post-prompt summary URL.
Server Methods
run
Start the development server.
get_app
Get the FastAPI application instance.
Serverless Methods
serverless_handler
Handle AWS Lambda invocations.
cloud_function_handler
Handle Google Cloud Function invocations.
azure_function_handler
Handle Azure Function invocations.
Callback Methods
on_summary
Override to handle post-prompt summaries.
set_dynamic_config_callback
Set a callback for dynamic configuration.
SIP Routing Methods
enable_sip_routing
Enable SIP-based routing.
register_sip_username
Register a SIP username for routing.
Method Chaining
All setter methods return self for method chaining: