Create an Agent
Agent Config
Agents using the
bedrock LLM provider or the aws S2S provider also take a
top-level aws block for region and credentials — one per agent, shared by
both. See AWS credentials.skills names the project’s skills the agent may load
mid-call. The model sees each one’s name and description, and loads one with
the built-in load_skill tool when the conversation needs it.
max_loaded_skills (default 3, 1 to 10) caps how many it holds loaded at
once; loading one more unloads the one loaded longest ago. An entry follows
the skill’s live published version, so a skill publish reaches the agent’s
next call without republishing it, unless the entry pins one with version_id
(see Pin a version). Each name must have a
published version in the project (a pin: a published or archived version of
that skill), and no skill
tool may share a name with a built-in, the agent’s own tool or another listed
skill’s tool: saving the agent otherwise is a 422 naming both sides (see
Skills).
Procedures
A procedure is a graph of steps the agent follows on a call: diagnostic questions in order, checks the caller performs, the conditions that decide the next step, and where it ends. TurnCall holds the route; on every caller turn the model is shown only a window of it, and reports each move. This section is the reference. For the concepts — how a procedure sits beside the system prompt, what it buys you and what it costs — see Procedures.
The window. Before each caller turn the model is given one message, right
before the turn and replacing the previous turn’s: the current step and what
to do there, the allowed moves with their conditions, the move back to the
previous step, and a preview of the steps up to
window_depth ahead. When a
move from the current step leads to an escalate step, it also says to take
it when the procedure cannot resolve the caller’s problem (If the procedure cannot resolve the caller's problem, escalate: move to technician.). The rest
of the graph never enters the prompt.
move_to_step
({procedure, to}); it is never listed in tools (a 422 there). A move the
current step allows, or back to the previous step, is accepted: the procedure
moves and the result tells the model what to do at the new step. Anything
else is refused, the result naming the moves that are allowed and why, and the
procedure and its window stay where they were.
Reaching an end or escalate step finishes the procedure: its window is no
longer shown, and any later move in it, a move back included, is refused as
finished. So a procedure that completed or escalated stays that way, and a
finished on_request procedure is not started again.
A move adds no pause. When the model’s reply already said something to the
caller, reporting the move beside it costs no second model call: the next
call is the caller’s next turn, which sees the move’s result (or its refusal)
and the window at the new step. A move with nothing said beside it gets one
model call so the caller is answered, and a move beside another tool, such
as a step’s lookup, gets one once both results are in.
Start modes and several procedures. An agent can carry several
procedures, such as one per fault family. A start: "call" one runs from the
first turn. A start: "on_request" one lets the agent handle general
questions and run the procedure only when it applies: until it starts, the
prompt names it with its description and its start step’s id, and no step’s
text:
move_to_step to its start step; the result says
what to do there, and from the next turn its window is shown. A move in a
procedure that is not running is otherwise refused with the reason (an
on_request one’s names its start step). The model is never shown the steps
of a procedure that is not running, and when several run, each has its own
window in the one message.
Step tools and variables. A step’s tool names a tool the model should
call at that point, so an API check happens where it belongs and its result
informs the next move. The window says so, at the step and in the preview
(after_restart (check, tool: line_status)). It is one of the agent’s own
tools (or a built-in, or query_knowledge) and runs like any other: it
reaches its webhook and is recorded in the call’s tool invocations. Naming a
tool the agent does not have is a 422 naming the procedure and the step; an
agent with mcp_servers is not checked, since its MCP tools are only known
once a call connects. A step’s text renders the call’s
template variables like the rest of the config:
422 naming the procedure and the step rather than something found on a call:
- step ids are unique within the procedure, and procedure names within the agent;
- exactly one step has
start: true; - every move goes to a step that exists;
- every step can be reached from the start step by its moves;
- at least one step is of kind
endorescalate; - each
escalatestep names exactly one action (below), and no other step names one; - a handoff escalation names an agent of the project;
- at most 50 steps, and
window_depthat most 5.
escalate step names its action, and when the model moves the call there,
TurnCall runs it. A transfer takes the transfer_call tool’s
fields, briefing included (a text, or {"from_summary": true} for a summary
of the call so far), and goes the way that tool does (see Call transfer), so it works on every carrier the tool
works on and is refused the same way where it does not (a warm transfer on
Asterisk, say); a handoff names an agent and goes the way handoff_to_agent
does.
procedures then reads completed: false and escalated_at the step.
Have the step’s text say what the caller should hear: the model says it in
the same reply as the move.
A handoff ends the procedures. Whatever hands the call off — an escalate
step, the handoff_to_agent tool or
POST /v1/calls/{id}/handoff — the first agent’s
running procedures end where they stood, each recorded as left (one that had
finished is not), and the target agent’s own procedures start as they would
at the start of a call. The target never sees the first agent’s.
A call-init inline agent skips that check, so the same
rule runs when its call is built: a broken procedure, or an entry that is not
a procedure at all, fails the call with ended_reason: pipeline_error and an
error.raised event naming the problem — never a call that runs without it.
Procedures are part of the agent’s config, so they version, publish, roll back
and A/B-route with the agent, and a call-init inline
agent can carry its own. Cascade voice calls only: on an S2S agent they are
skipped, said on its read (procedures_ignored_on_s2s, below) and in the
build’s log.
What a call records
Every move is on the call’s event log (GET /v1/calls/{id}/events), in the
order it was made, after the procedure’s start (a procedure.step from null
to its start step, for a start: "call" one as the call starts and for an
on_request one when the model starts it): a procedure.step for a move the
procedure allowed, a
procedure.refused for one it refused, and a procedure.left for one a
handoff ended before it reached an end or escalate step ({procedure, from, reason: "handoff"}). They are stored, never sent to webhook subscribers, and
an eval run records none.
call.ended both carry procedures, worked out from those
events, so the two always agree:
A procedure is listed once it started, so one the caller never got past the
first step of is listed (
path: ["lights"], not completed); an on_request
one the model never started is not. The list is empty
for a call that followed none, and null once retention
deleted the call’s transcript: the moves go with it.
Warnings on a Read
GET /v1/agents/{id} returns a warnings list beside the config: things
worth telling you about a config that must not be refusals, because refusing
them would break working agents.
Warnings are derived on every read, never stored, so an agent whose model
moved out from under its pronunciations starts saying so without being edited.
An empty list means nothing to report.
Template Variables
Personalize agents per-call using{{variable}} placeholders:
Pipeline Mode
Processing is the sum of each stage’s time-to-first-byte. It is not what the
caller waits — the agent must first decide the turn has ended. With
smart_turn_detection on (the default) that decision is the model’s, and VAD
waits only 0.2s; silence_timeout_ms is the window when Smart Turn is off, and
on S2S. See Latency.
Set pipeline_mode in the agent config:
Voice Activity Detection
TurnCall uses Silero VAD for barge-in (interruption handling) and Smart Turn V3 (ML-based, local ONNX) for accurate end-of-turn detection.Spoken digits
Smart Turn judges a turn by how the caller sounds at its end, and a string of digits — a phone, order or account number — often ends without the falling intonation of a finished sentence. Measured on synthesized speech (8 voices), utterances ending in a digit string were judged incomplete 14 times in 40; plain sentences, 2 in 16 (both one robotic voice). An incomplete verdict is not a stuck turn: the turn still ends once the caller has been silent forsmart_turn_stop_secs (default 1.0s), so the cost is that much extra wait
before the agent answers.
For an agent whose callers mostly read out numbers, any of these removes it:
stt.model: "flux-general-en"— Deepgram Flux decides the turn from the transcript as well as the audio.smart_turn_detection: false— the turn ends onsilence_timeout_msof silence alone. Lower that window with care: callers pause between digit groups.- A lower
smart_turn_stop_secs— keeps Smart Turn for everything else and shortens the wait it adds when it is unsure.
Deepgram Flux
Flux is Deepgram streaming STT that detects the end of the caller’s turn itself. Pick aflux-* model on the deepgram provider — same account, same
key:
interruption_enabled is false).
Smart Turn is not run for a Flux agent whatever smart_turn_detection says —
it would only wait again after Flux had decided — and silence_timeout_ms is
not used. Tune Flux with its own eot_threshold (confidence needed to end a
turn) and eot_timeout_ms (silence that ends one regardless) in stt.extra;
min_confidence and language_hints (for flux-general-multi) go there too.
Other keys are ignored. stt.language is not sent: flux-general-en is English
and flux-general-multi detects the language.
eager_eot_threshold (at most eot_threshold, e.g. 0.5) starts the reply
early: when Flux predicts the turn is ending, the LLM starts answering, and the
answer is held until Flux confirms the turn — or dropped if the caller keeps
talking or the final transcript differs. The agent answers sooner by the gap
between the two, at the price of one extra LLM request for every prediction
Flux takes back. A tool call is never made on a prediction: it waits for the
confirmed turn.
Each turn’s metrics.turn event (GET /v1/calls/{id}/events?event_type=metrics.turn)
carries turn_end_ms, the time from the caller going quiet to the turn being
called over — the number Flux shortens.
Callers Who Go Quiet
A caller who puts the phone down without hanging up holds the line open. After the agent finishes speaking,user_idle_timeout_ms of silence prompts it to
check in; a second consecutive silence ends the call with an ended_reason of
customer_silent. Speaking resets the count.
On cascade the line is spoken through TTS verbatim. S2S has no TTS stage, so
the model is asked to check in and words it itself — expect a paraphrase rather
than your exact string.
Not to be confused with
silence_timeout_ms, the pause within a turn that
decides you have finished your sentence. That one is measured in hundreds of
milliseconds; this one in seconds, and only after the agent has spoken.Voicemail Detection
For outbound calls, detect voicemail and leave a message:Voicemail detection cannot be combined with
pipeline_mode: "s2s".