agents-go
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},
})

Turn-detection mode

ModeValueEnds 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.

Endpointing

FieldDefaultNotes
MinEndpointingDelay500msSilence debounce before committing a turn.
MaxEndpointingDelay3sUpper bound when dynamic endpointing / an EOU model extends the delay.
DynamicEndpointingfalseAdapt the delay to the user's observed pauses.
EndpointingAlpha0.9EMA coefficient for dynamic endpointing (0 < α < 1).

Interruption

FieldDefaultNotes
AllowInterruptionstrueEnable barge-in during playout.
InterruptionMinDuration500msMinimum user speech before it interrupts.
InterruptionMinWords0 (off)Minimum recognised words before interrupting (STT only).
DiscardAudioIfUninterruptibletrueExclude audio from STT while an uninterruptible reply plays (VAD still sees it).

False interruptions

FieldDefaultNotes
ResumeFalseInterruptiontrueResume a paused reply if no real turn is committed. Requires an output that reports CanPause.
FalseInterruptionTimeout2sSilence before a paused reply is classed false and resumed. Non-positive disables.

Reply guards

FieldDefaultNotes
MaxSpeechDurationoffCap one reply after its first audio frame.
MaxSpeechRetries0Replacement replies allowed after MaxSpeechDuration cuts one off.
MaxUserTurnWords0 (off)Cap final-transcript words before the agent must speak.
MaxUserTurnDurationoffWall-clock cap before the agent must speak.

Preemptive (speculative) generation

Speculative replies are generated from final STT transcripts and promoted only if the committed transcript and request snapshot are unchanged.

FieldDefaultNotes
PreemptiveGenerationtrueEnable speculative replies.
PreemptiveTTSfalseAlso start synthesis speculatively (buffered, never played until promotion).
PreemptiveMaxSpeechDuration10sSkip speculation past this much user speech.
PreemptiveMaxRetries3Speculative requests per user turn.

*bool fields (e.g. AllowInterruptions) distinguish "unset → default" from an explicit false. Use a pointer helper to set them.

On this page