Reference
TurnOptions Turn-detection mode, endpointing, interruption, and preemptive generation.
TurnOptions (set on AgentSessionOptions.Turn) tunes how the session decides a
user turn ended, how interruptions work, and speculative generation. Every knob
has a safe default — you only set what you need.
session := agents. MustNewAgentSession ( agents . AgentSessionOptions {
Turn: agents . TurnOptions {Mode: agents.TurnModeVAD},
})
ModeValue Ends a turn on TurnModeAuto"" (default)VAD if configured, else STT, else manual. TurnModeVAD"vad"VAD end-of-speech + endpointing delay. TurnModeSTT"stt"STT final transcripts + endpointing delay. TurnModeManual"manual"Nothing automatic — you call GenerateReply.
Detector (a TurnDetector) optionally supplies a model-assisted end-of-turn
detector. It is opt-in and external : build one from the inference package
(inference.NewHTTP(baseURL) → inference.NewEOUTurnDetector(client)) pointed at
the Python EOU sidecar, and assign it here. Leave it nil to use plain VAD/STT
endpointing with no sidecar. See Latency & interruption .
Field Default Notes MinEndpointingDelay500ms Silence debounce before committing a turn. MaxEndpointingDelay3s Upper bound when dynamic endpointing / an EOU model extends the delay. DynamicEndpointingfalse Adapt the delay to the user's observed pauses. EndpointingAlpha0.9 EMA coefficient for dynamic endpointing (0 < α < 1).
Field Default Notes AllowInterruptionstrue Enable barge-in during playout. InterruptionMinDuration500ms Minimum user speech before it interrupts. InterruptionMinWords0 (off) Minimum recognised words before interrupting (STT only). DiscardAudioIfUninterruptibletrue Exclude audio from STT while an uninterruptible reply plays (VAD still sees it).
Field Default Notes ResumeFalseInterruptiontrue Resume a paused reply if no real turn is committed. Requires an output that reports CanPause. FalseInterruptionTimeout2s Silence before a paused reply is classed false and resumed. Non-positive disables.
Field Default Notes MaxSpeechDurationoff Cap one reply after its first audio frame. MaxSpeechRetries0 Replacement replies allowed after MaxSpeechDuration cuts one off. MaxUserTurnWords0 (off) Cap final-transcript words before the agent must speak. MaxUserTurnDurationoff Wall-clock cap before the agent must speak.
Speculative replies are generated from final STT transcripts and promoted only if
the committed transcript and request snapshot are unchanged.
Field Default Notes PreemptiveGenerationtrue Enable speculative replies. PreemptiveTTSfalse Also start synthesis speculatively (buffered, never played until promotion). PreemptiveMaxSpeechDuration10s Skip speculation past this much user speech. PreemptiveMaxRetries3 Speculative requests per user turn.
*bool fields (e.g. AllowInterruptions) distinguish "unset → default" from an
explicit false. Use a pointer helper to set them.