Agents
An agent configuration defines the personality, capabilities, and behavior of your AI voice assistant. Usephone.agent() to validate your agent config before connecting it to a phone number.
Basic Agent
The simplest form leans on env-var fallback and a default engine (OpenAIRealtime):
OpenAILLM, AnthropicLLM, GroqLLM, CerebrasLLM, GoogleLLM. Tool calling works across all five. See LLM for the full reference. For fully custom logic (multi-model routing, local models), drop llm and pass an onMessage callback to serve() instead — llm and onMessage are mutually exclusive.
AgentOptions
Validation Rules
Thephone.agent() method validates:
- Engine / pipeline: exactly one of
engine,(stt+tts)must resolve correctly. - Tools: must be an array. Each tool requires a
namefield and either awebhookUrlor ahandler. - Variables: must be a plain object (not an array).
Dynamic Variables
Use{placeholder} syntax in your system prompt. Variables are replaced at call time:
System Tools
Two system tools are automatically injected into every agent:transfer_call— Transfers the call to a specified phone number (E.164 format).end_call— Ends the current call with an optional reason.
tools array. The AI model can invoke them based on conversation context.
Voice Activity Detection (VAD)
Pipeline-mode agents can plug a VAD provider into thevad option to gate STT around real speech and drive barge-in detection. The SDK ships Silero VAD (an ONNX model, ~1 MB) with a telephony-tuned factory:
SileroVAD.forPhoneCall(options?) is identical to SileroVAD.load(...) but pins sampleRate to 16 000 Hz — the only sample rate Patter’s pipeline-mode audio bus uses (8 kHz mulaw from Twilio is upsampled to 16 kHz PCM before reaching the VAD). All other parameters use the upstream snakers4/silero-vad defaults:
Override per call site rather than as a global default. A common tweak: deployments that experience truncation on natural pauses raise
minSilenceDuration to 0.5–1.0 s:
SileroVAD.forPhoneCall() returns a Promise<SileroVAD> — await it once at process startup before constructing your agent. The underlying ONNX session is reused across calls.
