voice.agents.attach
plus the turn-detection knobs. TypeScript is primary. Python is shown where it
differs.
Attach a speech-to-speech agent to a call
This one-liner binds a registered agent to a live call sid.Originate and attach in one call
Passagent to originate. ClutchCall then bridges the model at the moment
the callee answers.
Attach with an inline agent spec
Skip the registry. Select the model leg and the turn-detection policy inline.Pick the codec the model wants
Most speech-to-speech models ingest raw PCM16. Set the model codec. The bridge transcodes the caller leg.A PSTN caller leg can be
g711_ulaw / g711_alaw. A browser leg is opus.
You never set the caller codec here. You set only what the model expects.Tighten end-of-turn for snappier replies
Lower the trailing-silence threshold so the agent answers sooner after the caller stops.Stop backchannels from triggering a reply
Continuers such as “mhm” / “ok” / “right” must not make the model answer. Raise the minimum speech length that counts as a turn.Make barge-in forgiving (hold-and-confirm)
Require sustained speech before the barge-in cancels the agent. Then a muttered continuer mid-reply does not kill the turn.Make barge-in instant (browser / AEC legs)
When the caller leg has client-side echo cancellation, cut the agent on the first speech frame.Stop the agent self-triggering on a no-AEC SIP/PSTN leg
When there is no echo cancellation, the agent’s own audio bleeds into the mic. Raise the post-audio mic guard so that the agent does not read its own voice as barge-in.Inject a pre-roll prompt before the model speaks
Attach the audio bridge. Push a downlink clip before the first model turn.Record the caller leg while the agent runs
Tap the uplink without disturbing the agent bridge.- TypeScript
- Python
Watch turn boundaries and barge events
Subscribe to call status to see when the agent commits a turn or is interrupted.Detach the agent but keep the call up
Hand the call back to a human (or another app). Attach a bare bridge, and do not re-attach the agent.Attach a speech-to-speech agent in Python
This is the same flow, in snake_case.Give the agent an HTTP tool
Declare anhttp tool on the agent. The model can then call it
mid-conversation. The URL substitutes {{argument}} values from the model’s
tool arguments. ClutchCall feeds the result back, and the model speaks it.
Call a remote MCP server as a tool
Point anmcp tool at an MCP server. ClutchCall sends a JSON-RPC
tools/call and gives the result back to the model. The auth shapes are the
same as http.
You declare each MCP tool explicitly by name. Auto-discovery via
tools/list is not yet wired. List the tools that you want the model to
see.Make a tool silent (no narration)
Setsilent: true so that the model does not say “let me look that up”. The
model stays quiet until it has the result. Then it answers directly.
Handle a structured tool error
A failed or denied tool call returns a structured error to the model, not raw text. The model can then recover: fall back, ask for a different input, or explain the limitation. Make your endpoint return a clear error body and a non-2xx status. The model reasons over it.Related
- Inference — Recipes — full worked examples
- Inference — SDK Methods — every method and the full knob table
- Turn Detection & Barge-In — the policy these knobs drive

