AgentBase
AgentBase is the central class in the SignalWire Server SDK. It provides a
complete framework for building AI-powered voice agents, combining prompt management,
tool definitions, skill loading, speech configuration, and web serving into a single
composable interface.
AgentBase extends SWMLService, inheriting its SWML document
serving and SWAIG tool registry (the /swaig endpoint and tool registration/
dispatch live on SWMLService). On top of that, AgentBase uses
composition internally, assembling functionality from PromptManager,
SwmlBuilder, SessionManager, ContextBuilder, and SkillManager. All setter
methods return this for fluent method chaining.
AgentBase generates a SWML document with the ai verb.
See the SWML reference for the full specification of all
supported parameters and behaviors.
Constructor
Constructor Parameters
name
Display name of the agent. Used in logging, SIP username mapping, and the default prompt fallback.
route
HTTP route path where this agent is served. Used by
AgentServer when hosting multiple agents on one process.
host
Network interface the HTTP server binds to.
port
Port the HTTP server listens on. Defaults to the PORT environment variable,
falling back to 3000.
basicAuth
Explicit [username, password] tuple for HTTP Basic Auth on all endpoints. If not
set, credentials are read from SWML_BASIC_AUTH_USER / SWML_BASIC_AUTH_PASSWORD
env vars, or auto-generated on startup.
usePom
Enable Prompt Object Model for structured prompt building. Set to false to use
plain text prompts only.
tokenExpirySecs
Expiration time in seconds for SWAIG function authentication tokens.
autoAnswer
Automatically add an answer verb before the AI verb in the SWML document.
recordCall
Enable call recording. When true, a record_call verb is added to the SWML document.
recordFormat
Recording file format. Common values: "mp4", "wav".
recordStereo
Record in stereo (separate channels for each party) when true.
defaultWebhookUrl
Base URL for SWAIG function webhooks. If not set, the SDK auto-detects from the
incoming request or uses SWML_PROXY_URL_BASE.
nativeFunctions
List of native SWAIG function names to enable at construction time (e.g.,
["check_time", "wait_for_user"]). Can also be set later via
setNativeFunctions().
agentId
Unique identifier for this agent instance. Auto-generated as a random hex string if not provided.
suppressLogs
Suppress SDK log output. Useful in testing or when integrating with external logging.
enablePostPromptOverride
When true, register the /post_prompt_override route allowing external callers to
replace the post-prompt text at runtime.
checkForInputOverride
When true, register the /check_for_input route allowing external callers to inject
input checks at runtime.
configFile
Path to a JSON configuration file. When provided, its service section supplies
defaults for name, route, host, and port. Constructor arguments still take
precedence over file values.
schemaPath
Path to a custom SWML JSON Schema file used for validation. Falls back to the built-in schema when omitted.
schemaValidation
Enable SWML schema validation on rendered documents. Can also be disabled via
SWML_SKIP_SCHEMA_VALIDATION env var.
signingKey
SignalWire Signing Key used to verify inbound webhook signatures. When set,
the agent auto-mounts webhook signature validation middleware on POST /,
/swaig, and /post_prompt — unsigned or mis-signed requests receive a 403.
Falls back to the SIGNALWIRE_SIGNING_KEY environment variable. When both are
unset, validation is disabled and a one-time startup warning is emitted. Treat
this value as a secret.
webhookTrustProxy
When true, the webhook validation middleware honors X-Forwarded-Proto and
X-Forwarded-Host when reconstructing the public URL for signature
verification. Defaults to false because those proxy headers are spoofable.
SWML_PROXY_URL_BASE always takes precedence.
Properties
name
The agent’s display name. Set at construction time.
route
HTTP route path where this agent is served.
host
Network interface the HTTP server binds to.
port
Port the HTTP server listens on.
agentId
Unique identifier for this agent instance.
signingKey
The Signing Key used for webhook signature validation, from the constructor
option or SIGNALWIRE_SIGNING_KEY. null when validation is disabled.
Static Members
PROMPT_SECTIONS
Class-level attribute. Subclasses can set this to declaratively define prompt sections
instead of calling promptAddSection() in the constructor.