Controls and observes one agent speech turn.

Constructors

Properties

parent?: SpeechHandle
SPEECH_PRIORITY_HIGH: number = 10

Priority for important messages that should be played before others.

SPEECH_PRIORITY_LOW: number = 0

Priority for messages that should be played after all other messages in the queue

SPEECH_PRIORITY_NORMAL: number = 5

Every speech generates by the VoiceAgent defaults to this priority.

Accessors

  • get allowInterruptions(): boolean
  • Returns boolean

  • set allowInterruptions(value): void
  • Allow or disallow interruptions on this SpeechHandle.

    When set to false, the SpeechHandle will no longer accept any incoming interruption requests until re-enabled. If the handle is already interrupted, clearing interruptions is not allowed.

    Parameters

    • value: boolean

      true to allow interruptions, false to disallow

    Returns void

    Throws

    Error If attempting to disable interruptions when already interrupted

Methods

  • Returns the error that caused this SpeechHandle to complete, if any.

    Returns unknown

    Throws

    Error if the SpeechHandle is not done yet.

  • Makes the SpeechHandle awaitable: await handle resolves to the handle itself once its playout has finished.

    Implementation note: naively returning this from onFulfilled would trigger infinite Promise assimilation recursion (the returned thenable gets unwrapped, calling .then() again, forever). We side-step this by shadowing .then with undefined on the instance for the duration of the synchronous Resolve(this) call. The spec-level IsCallable check reads undefined, fulfills the outer promise with this as a plain value, and we restore the prototype method immediately after.

    Type Parameters

    Parameters

    • Optional onFulfilled: null | ((value) => R1 | PromiseLike<R1>)
    • Optional onRejected: null | ((reason) => R2 | PromiseLike<R2>)

    Returns Promise<R1 | R2>

  • Waits for the entire assistant turn to complete playback.

    This method waits until the assistant has fully finished speaking, including any finalization steps beyond initial response generation. This is appropriate to call when you want to ensure the speech output has entirely played out, including any tool calls and response follow-ups.

    Returns Promise<void>

    Throws

    SpeechHandleCircularWaitError if called on the SpeechHandle that owns the currently-running function tool — that would be a real circular wait (the tool is blocked waiting for this handle, and the handle cannot finish until the tool returns). Awaiting a different handle scheduled from inside a tool (e.g. session.generateReply().waitForPlayout()) is safe, because the main speech-queue loop frees the owning handle's generation slot via _markGenerationDone() before awaiting tool execution.