Agents

Agents

Python API reference for AgentBase, SWMLService, SWAIG functions, skills, contexts, LiveWire, search, and more
View as MarkdownOpen in Claude

The Agents namespace provides the core framework for building AI-powered voice agents with SignalWire. It includes the central AgentBase class, SWML document generation, tool/function definitions, skills, multi-agent hosting, CLI tools for local testing and deployment, and configuration management for security and environment settings.

The Agents SDK generates SWML documents under the hood. Each agent produces a SWML document with the ai verb that the SignalWire platform executes.

Example

A complete agent that answers calls, uses an AI prompt, and exposes a custom tool:

1from signalwire import AgentBase
2from signalwire.core.function_result import FunctionResult
3
4agent = AgentBase(name="support-agent", route="/support")
5agent.set_prompt_text(
6 "You are a friendly support agent for Acme Corp. "
7 "Help customers check their order status. "
8 "Be concise and professional."
9)
10agent.set_params({"temperature": 0.5, "end_of_speech_timeout": 800})
11
12@agent.tool(description="Look up an order by ID")
13def check_order(args, raw_data):
14 order_id = args.get("order_id", "unknown")
15 return FunctionResult(f"Order {order_id} shipped on March 28 and arrives tomorrow.")
16
17agent.add_skill("datetime")
18
19if __name__ == "__main__":
20 agent.serve()

Classes

AgentBase

The central class for building AI agents. Manages prompts, tools, skills, and serving.

SWMLService

SWML document generation and FastAPI service base class.

SWMLBuilder

Fluent builder for constructing SWML documents programmatically.

SWAIGFunction

Wraps Python functions as callable SWAIG tools with validation and metadata.

FunctionResult

Fluent interface for returning actions and responses from tool functions.

ContextBuilder

Multi-step agent workflows with context and step navigation.

DataMap

Server-side API tools that execute REST calls without agent webhooks.

SkillBase

Base class for building reusable skill plugins.

PomBuilder

Prompt Object Model builder for structured prompt composition.

AgentServer

Host multiple agents on a single FastAPI process with route-based dispatch.

BedrockAgent

Amazon Bedrock voice-to-voice agent extending AgentBase.

Prefabs

Pre-built agent templates for common conversational patterns.

Skills

Built-in skills catalog with 17 pluggable capabilities.

CLI Tools

Command-line tools for testing, searching, scaffolding, and deployment.

Configuration

Environment variables, config files, security settings, and authentication.

LiveWire

LiveKit-compatible API layer — use familiar livekit-agents classes on SignalWire infrastructure.

Search

Vector search engine for building knowledge bases with document processing and indexing.

MCP Gateway

Model Context Protocol bridge connecting MCP servers to SWAIG functions.

WebService

Static file serving with security, CORS, and SSL support.

Helper Functions

Convenience functions for creating contexts, API tools, and managing skills.