Skip to navigation

Agent

Orchestrate a complete voice agent by creating a cascaded voice pipeline consisting of your choice of STT, LLM, TTS, VAD and turn-taking components.

session
.agent({
stt: {
vendor: 'deepgram',
language: 'multi',
deepgramOptions: { model: 'nova-3-general' },
},
tts: {
vendor: 'cartesia',
voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc',
},
llm: {
vendor: 'openai',
model: 'gpt-4.1-mini',
llmOptions: {
messages: [
{ role: 'system', content: 'You are a helpful voice assistant.' },
],
tools: [
{
name: 'get_weather',
description: 'Get current weather for a city',
parameters: {
type: 'object',
properties: {
city: { type: 'string' },
},
required: ['city'],
},
},
],
},
},
turnDetection: 'krisp',
earlyGeneration: true,
bargeIn: { enable: true, minSpeechDuration: 0.5 },
noResponseTimeout: 12,
toolHook: '/tool-call',
eventHook: '/agent-event',
actionHook: '/agent-complete',
})
.send();

The agent verb wires together three components — STT, LLM, and TTS — with integrated turn detection to create a complete voice AI agent. Unlike the llm verb (which connects to speech-to-speech APIs like OpenAI Realtime), the agent verb lets you mix and match separate vendors for each component.

The agent verb manages the full conversational turn cycle:

  1. User speaks → STT produces a transcript
  2. Turn detection decides the user is done speaking
  3. Transcript is sent to the LLM
  4. LLM response tokens stream to TTS
  5. TTS audio plays back to the caller
  6. If the user barges in, TTS stops and a new turn begins

For a comprehensive guide on building voice AI agents with the agent verb, see Voice Agents.

Parameters

actionHook
string

A webhook invoked when the agent verb ends. The payload includes a completion_reason field indicating why it terminated.

bargeIn
object

Controls whether and how the user can interrupt the assistant while it is speaking.

bargeIn.enable
booleanDefaults to true

Allow the user to interrupt the assistant while it is speaking.

bargeIn.minSpeechDuration
numberDefaults to 0.5

Seconds of detected speech required before confirming an interruption. Prevents brief noises from cutting off the assistant.

bargeIn.sticky
booleanDefaults to false

If true, once the user interrupts, the assistant does not resume speaking the interrupted response.

earlyGeneration
booleanDefaults to false

Enable speculative LLM prompting before end-of-turn is confirmed. If the transcript matches when the turn ends, buffered tokens are released immediately — reducing response latency. Works with Krisp turn detection, Deepgram Flux and Speechmatics agent mode. With Deepgram Flux you must also set stt.deepgramOptions.eagerEotThreshold, or early generation never starts. Tool calls chosen by a speculative reply run only after the end of turn is confirmed. See Early Generation.

eventHook
string

A webhook invoked for agent events. Receives event types: user_transcript, llm_response, user_interruption, turn_end, history_summarized, overlapping_speech, interrupt_prediction_ignored, no_response_timeout and llm_error. See eventHook Events below.

greeting
boolean | stringDefaults to true

How the agent opens the call. true: the LLM generates a greeting before the user speaks. false: the agent waits silently for the user to speak first. A string: the agent speaks these exact words as its first turn, without calling the LLM; the user can interrupt it, and the conversation history records it as the agent’s first reply.

handoff
object

Declarative transfer-to-human configuration. When present, the runtime injects a transfer_to_human tool into the LLM’s toolset and runs the packaged transfer choreography when the model calls it. See Transfer-to-human handoff.

hangup
object

Enable the built-in hangup tool. When present, the runtime injects a hangup tool into the LLM’s toolset; when the LLM calls it, the call is ended. See Built-in Hangup Tool below.

hangup.reason
string

Default reason placed in the X-Reason SIP header on the outbound BYE. Used as a fallback when the LLM does not supply its own reason at call time.

id
string

An optional unique identifier for this verb instance.

llm
objectRequired

LLM configuration. This is the only required property. See Bring Your Own LLM for the full list of supported vendors and per-vendor setup.

llm.vendor
stringRequired

LLM vendor id. One of: anthropic, azure-openai, baseten, bedrock, deepseek, google, groq, huggingface, moonshot, openai, vertex-gemini, vertex-openai, xai, zai. See Bring Your Own LLM for setup of each.

llm.model
stringRequired

Model name. Format is vendor-specific (e.g., gpt-4o-mini, claude-haiku-4-5-20251001, gemini-2.5-flash, llama-3.3-70b-versatile, meta-llama/Llama-3.3-70B-Instruct). For Azure OpenAI, this is your deployment name, not the model id.

llm.label
string

Only needed when the account has more than one LLM credential for the same vendor — give each a distinct label in the portal at create time and reference it explicitly here. Most accounts have a single credential per vendor and should leave this unset.

llm.auth
object

Inline authentication credentials. Format depends on the vendor — see the per-vendor pages under Bring Your Own LLM. If not provided, jambonz looks up credentials by vendor (and label, if the rare multi-credential case applies) from the LLM Services configured in the portal.

llm.llmOptions
object

LLM options including system prompt, tools, and generation parameters.

llm.llmOptions.messages
array

Initial conversation messages. Typically includes a system message with instructions: [{ role: 'system', content: '...' }].

llm.llmOptions.systemPrompt
string

System prompt for the LLM. Alternative to providing a system message in messages.

llm.llmOptions.tools
array

Tool/function definitions available to the LLM. Uses OpenAI function-calling format. See Tool Calling below.

llm.llmOptions.maxTokens
number

Maximum number of tokens in the LLM response.

llm.llmOptions.vendorParams
object

Vendor-specific request parameters that jambonz has no first-class option for, passed to the vendor as-is. For example, OpenRouter’s provider routing: { provider: { sort: 'latency' }, models: ['openai/gpt-4.1-mini'] } (see OpenRouter).

  • Fields are added to the request body for OpenAI-compatible vendors (openai, openrouter, groq, deepseek, xai, azure-openai, …) and to the generation config for google and vertex-gemini. anthropic and bedrock ignore it.
  • It can only add fields. Anything jambonz sets on the request wins: model, messages and tools always, and max tokens and temperature when you set maxTokens or temperature.
  • Commonly used parameters, tested by us: OpenAI, Google, DeepSeek, OpenRouter.
  • jambonz does not validate the contents. A misspelled field, or one the vendor rejects, surfaces as a vendor error on the first turn.
mcpServers
array

External MCP servers that provide tools to the LLM. The agent verb connects to each server at startup, discovers available tools, and makes them callable by the LLM. Each entry requires a url property and optionally auth and roots.

noiseIsolation
string or object

Enable server-side noise isolation to reduce background noise. As a string, pass "krisp", "rnnoise" or "kugelaudio" for default settings. As an object: { mode: "krisp", level: 80, direction: "read" }. direction can be "read" (filter caller audio, default) or "write" (filter outbound audio). Krisp requires an API key on self-hosted systems. For "kugelaudio", the object also takes label (which KugelAudio speech credential to use) and auth ({apiKey, apiUri} on the verb instead of a credential); see KugelAudio Clarity.

noResponseTimeout
numberDefaults to 12

Seconds to wait after the assistant finishes speaking before prompting the user to respond. When triggered, the LLM is prompted with a system cue to check if the user is still there. Set to 0 to disable.

noResponseMaxPrompts
numberDefaults to 0

End the agent after this many no-response prompts in a row get no reply. The actionHook then fires with completion_reason: "no_response", so your application decides what happens next, for example saying goodbye and hanging up. The count resets whenever the user speaks. 0 or unset: no limit. Added in 11.1.6.

stt
object

Speech-to-text configuration. See recognizer for available properties. Key properties: vendor, language, hints, and vendor-specific options like deepgramOptions.

toolHook
string

A webhook invoked when the LLM requests a tool/function call. The payload includes tool_call_id, name, and arguments (already parsed as an object). See Tool Calling below.

tts
object

Text-to-speech configuration. See synthesizer for available properties. Key properties: vendor, voice, language, and vendor-specific options.

turnDetection
string or objectDefaults to stt

Turn detection strategy. Controls when the agent verb decides the user has finished speaking.

As a string:

  • "stt" — Uses the STT vendor’s native end-of-utterance signal. For most vendors this is silence-based. Vendors with smarter built-in turn detection (deepgramflux, assemblyai, speechmatics) always use their native detection regardless of this setting.
  • "krisp" — Uses the Krisp acoustic end-of-turn model, which analyzes speech patterns rather than just silence.

As an object (Krisp only):

  • mode — "krisp" (required)
  • threshold — Confidence threshold 0.0–1.0. Lower values trigger earlier turn transitions. Default: 0.5.
  • model — Optional Krisp model name override.
Krisp Licensing for Self-Hosted Systems

Krisp turn detection and noise isolation features require a Krisp API license key on self-hosted jambonz deployments. This license is not included with the jambonz software license and must be obtained separately from Krisp.

Contact support@jambonz.org for information on obtaining a Krisp license for your self-hosted deployment.

This requirement does not apply to jambonz.cloud customers — Krisp features are included with all jambonz.cloud plans.

Tool Calling

Define tools in llm.llmOptions.tools and handle calls via toolHook. The tool call payload includes tool_call_id, name, and arguments (already parsed — an object, not a JSON string).

In WebSocket mode, respond with session.sendToolOutput(tool_call_id, result):

session.on('/tool-call', async (evt) => {
const { tool_call_id, name, arguments: args } = evt;
if (name === 'get_weather') {
const weather = await fetchWeather(args.city);
session.sendToolOutput(tool_call_id, weather);
return;
}
session.sendToolOutput(tool_call_id, `Unknown tool: ${name}`);
});

In webhook mode, return the tool result as JSON in the HTTP response body.

Alternatively, connect external MCP servers to provide tools automatically without defining them inline.

MCP Servers

Instead of (or in addition to) defining tools inline, you can connect to external MCP servers. The agent verb connects to each server at startup via SSE or Streamable HTTP transport, discovers available tools, and makes them callable by the LLM.

session
.agent({
llm: { vendor: 'openai', model: 'gpt-4.1', llmOptions: {
messages: [{ role: 'system', content: 'You are a sports assistant.' }],
}},
stt: { vendor: 'deepgram', language: 'en-US' },
tts: { vendor: 'cartesia', voice: 'sonic-english' },
mcpServers: [
{ url: 'https://livescoremcp.com/sse' },
],
actionHook: '/agent-complete',
})
.send();

When the LLM requests a tool call, the agent verb checks MCP servers first. If the tool name matches one discovered from an MCP server, the call is dispatched there directly. If no MCP server provides the tool, it falls through to the toolHook.

Transfer-to-human handoff

Add a handoff block to let the agent transfer the caller to a human. The runtime injects a transfer_to_human tool into the LLM’s toolset — you don’t write a toolHook for it. When the caller asks for a human and the model calls the tool, jambonz runs the packaged transfer choreography to the configured destination.

session
.agent({
stt: { vendor: 'deepgram', language: 'en-US' },
tts: { vendor: 'cartesia', voice: 'sonic-english' },
llm: { vendor: 'openai', model: 'gpt-4.1', llmOptions: {
messages: [{ role: 'system', content: 'You are a helpful support agent.' }],
}},
handoff: {
mode: 'blind',
blindMethod: 'dial',
brief: 'none',
target: [{ type: 'user', name: 'agent-desk@sip.example.com' }],
},
actionHook: '/agent-complete',
})
.send();

The handoff block accepts every transfer option (mode, target, blindMethod, disposition, confirm, etc.), plus:

handoff.brief
string or objectDefaults to auto

Controls the spoken summary delivered to the human on a warm transfer. 'auto' lets the LLM write the summary; 'none' sends no spoken brief (and keeps the injected tool argument-free); { template: '...' } guides the LLM’s summary.

handoff.briefSynthesizer
object

Optional voice/vendor (synthesizer object) for the spoken brief. Defaults to the session synthesizer.

handoff.toolName
stringDefaults to transfer_to_human

Override the injected tool name.

handoff.toolDescription
string

Override the injected tool description shown to the LLM.

When the human leg bridges, the agent’s actionHook reports the transfer outcome (see the transfer actionHook properties).

Built-in Hangup Tool

Set hangup to let the LLM end the call on its own. The runtime injects a hangup tool into the LLM’s toolset; you do not define it in llm.llmOptions.tools and you do not handle it in your toolHook — the runtime intercepts the call, hangs up, and ends the agent verb.

session
.agent({
llm: { vendor: 'openai', model: 'gpt-4.1-mini', llmOptions: {
messages: [{ role: 'system', content: 'You are a helpful assistant. When the caller says goodbye, call the hangup tool.' }],
}},
stt: { vendor: 'deepgram', language: 'en-US' },
tts: { vendor: 'cartesia', voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc' },
hangup: { reason: 'conversation complete' },
actionHook: '/agent-complete',
})
.send();

The injected tool accepts an optional reason argument that the LLM may fill in when it decides to end the call. The reason placed in the X-Reason SIP header on the outbound BYE is resolved as follows:

  1. The LLM-supplied reason argument, if present.
  2. Otherwise the app-supplied hangup.reason default, if configured.
  3. Otherwise no X-Reason header is sent.

Pass an empty object (hangup: {}) to enable the tool with no default reason.

When the LLM calls the hangup tool, the call is released immediately. The actionHook still fires (with completion_reason: "hangup"), but any follow-on verbs it returns are discarded because the call is already being torn down.

eventHook Events

The eventHook receives real-time events during the conversation. In WebSocket mode, listen with session.on('/your-event-hook', handler).

Sent at the end of each conversational turn, including the agent’s greeting. The most useful event for observability.

The greeting’s turn_end has "greeting": true and an empty transcript.

{
"type": "turn_end",
"transcript": "What's the weather in Portland?",
"confidence": 0.998,
"response": "The current temperature in Portland is 52°F with wind speed 12 km/h.",
"interrupted": false,
"latency": {
"stt_ms": 320,
"eot_ms": 180,
"llm_ms": 890,
"tool_ms": 420,
"tts_ms": 210,
"preflight": {
"result": "hit",
"tokens": 12
}
},
"tool_calls": [
{ "name": "get_weather", "rtt_ms": 420 }
]
}

Latency fields (all in milliseconds):

  • stt_ms — STT processing time (user stops talking → final transcript received)
  • eot_ms — Additional wait for end-of-turn detection after transcript
  • llm_ms — Pure LLM thinking time (tool RTT subtracted)
  • tool_ms — Total time spent in tool calls
  • tts_ms — TTS engine latency (text sent → first audio received)
  • preflight — Early generation metrics: result (hit, miss, or pending) and tokens buffered on a hit

Timing fields (epoch milliseconds, at the top level of the event):

  • caller_started_at — when the caller began speaking in this turn; absent when the caller did not speak (for example the greeting)
  • agent_started_at — when the agent began speaking in this turn; absent when the agent did not speak

Sent when the user’s final transcript is available.

{
"type": "user_transcript",
"transcript": "What's the weather in Portland?"
}

Sent when the LLM finishes generating its response.

{
"type": "llm_response",
"response": "The current temperature in Portland is 52°F."
}

Sent when the user barges in while the assistant is speaking.

{
"type": "user_interruption",
"cause": "interrupt_prediction",
"probability": 0.81,
"spoken_text": "Your balance is one hundred"
}
  • cause — what confirmed the barge-in: vad (speech still active after bargeIn.minSpeechDuration), transcript (words from the recognizer) or interrupt_prediction (the turn-taking model)
  • probability — the interrupt prediction’s probability; only with interrupt_prediction
  • spoken_text — the part of the reply the caller heard; absent when not known
  • spoken_estimated — true when spoken_text is estimated from playout time because the TTS vendor reports no word alignment

Speech-to-speech engines send user_interruption with no other fields.

Sent when the caller speaks during the assistant’s reply and it is not treated as an interruption (barge-in off, or the interrupt prediction model judged it not an attempt to take the floor).

{
"type": "overlapping_speech",
"outcome": "held",
"transcript": "call me back tomorrow please",
"word_count": 5
}
  • outcome — ignored: too short to be a turn (a backchannel such as “okay”), dropped. held: kept and added to the caller’s next turn. answered: the reply ended and the held speech became the caller’s turn; transcript is then all the held speech.

Sent when the interrupt prediction model fires before the assistant has started speaking. It is usually the tail of the utterance being answered, so it is not treated as an interruption.

{
"type": "interrupt_prediction_ignored",
"probability": 0.62,
"state": "thinking"
}

state is thinking or awaiting_turn_gate.

Sent when the caller has said nothing for noResponseTimeout and the agent prompts them to check they are still there.

{
"type": "no_response_timeout",
"count": 1,
"timeout_ms": 10000
}

count is how many times in a row the agent has prompted the silent caller, this one included.

Sent when a request to the LLM fails. Unless retrying is true, the agent verb then ends with completion reason llm_failure.

{
"type": "llm_error",
"stage": "prompt",
"vendor": "openai",
"model": "gpt-4.1-mini",
"message": "429 Rate limit reached for gpt-4.1-mini",
"retrying": true
}
  • stage — prompt (the request for a reply), retry_without_tools (the retry of that request without tools) or tool_result (the request that follows a tool result)
  • message — the vendor’s error message, at most 200 characters, with anything that looks like a key or token masked
  • retrying — true when the agent retries the request without tools

Sent when conversation history summarization completes (requires JAMBONES_PIPELINE_SUMMARIZE_TURNS environment variable).

{
"type": "history_summarized",
"turn": 8,
"messages_dropped": 5,
"messages_kept": 6,
"summary": "The user is a software developer looking for a MacBook Pro..."
}

Mid-conversation Updates

The agent verb supports asynchronous updates while a conversation is in progress. Updates can be sent via WebSocket (session.updateAgent(data)) or REST API.

update_instructions

Replace the LLM system prompt mid-conversation.

session.updateAgent({
type: 'update_instructions',
instructions: 'You are now a billing support agent.',
});

inject_context

Append messages to the LLM conversation history. System messages are routed to the system prompt for vendors that don’t support inline system messages.

session.updateAgent({
type: 'inject_context',
messages: [
{ role: 'user', content: 'CRM context: Customer name: Sarah Mitchell. Account tier: Gold.' },
],
});

update_tools

Replace the tool set available to the LLM.

session.updateAgent({
type: 'update_tools',
tools: [
{
name: 'transfer_call',
description: 'Transfer the caller to a specialist',
parameters: { type: 'object', properties: { department: { type: 'string' } } },
},
],
});

generate_reply

Prompt the LLM to generate a new response. Use interrupt: true to cancel the current response and generate immediately.

session.updateAgent({
type: 'generate_reply',
interrupt: true,
user_input: 'URGENT: Tell the customer about the flash sale.',
});

Supported LLM Vendors

Vendorllm.vendorExample models
Anthropicanthropicclaude-haiku-4-5-20251001, claude-sonnet-4-6
AWS Bedrockbedrockamazon.nova-micro-v1:0, us.anthropic.claude-haiku-4-5-20251001-v1:0
Azure OpenAIazure-openaiyour deployment name
Basetenbasetendeepseek-ai/DeepSeek-V3.1, zai-org/GLM-5, moonshotai/Kimi-K2.6, openai/gpt-oss-120b
DeepSeekdeepseekdeepseek-v4-flash, deepseek-v4-pro
Google AI Studiogooglegemini-2.5-flash, gemini-2.5-pro
Groqgroqllama-3.3-70b-versatile, llama-3.1-8b-instant
HuggingFacehuggingfacemeta-llama/Llama-3.3-70B-Instruct, …:fastest
Moonshot (Kimi)moonshotkimi-k2-0711-preview, kimi-latest, moonshot-v1-8k
OpenAIopenaigpt-5.4-mini, gpt-5.4, gpt-5.5, gpt-4o-mini
Vertex AI — Geminivertex-geminigemini-2.5-flash, gemini-2.5-pro
Vertex AI — Partner Modelsvertex-openaimeta/llama-3.3-70b-instruct-maas, mistral-large
Z.ai (GLM)zaiglm-4.6, glm-4.5-air

See Bring Your Own LLM for per-vendor credential setup, model recommendations, and known issues.

Example Applications

See the agent examples for runnable demos covering basic usage, tool calling, MCP servers, CRM injection, persona switching, and more.