Gemini Live speech-to-speech as one stage: InputAudio in (16 kHz),
OutputAudio out (24 kHz). The model does its own turn-taking. When it
reports that someone talked over it, this stage pushes an Interruption.
When its reply is done generating, it pushes an AssistantMessage, though
the audio may play for a while yet.
Turns from the agent come in as text: a Transcription (typed by a
participant, sent as [speaker] text), a Prompt (from the app), and
LLMText (Octoroom.Agent.say/3, which asks the model to say it word for
word: close, but it's the model's voice saying it, not text-to-speech).
An Interruption from elsewhere (the agent's, for a typed turn or
interrupt/2) drops the rest of the reply being generated; the model
isn't told, so it thinks it was heard. Gemini doesn't know when its audio
has played either, so this stage also notifies :user_speaking when it
hears someone start a turn: the agent interrupts if its reply is still
playing.
Tool calls run in tasks of their own, which interruptions don't kill, and
their results go back to the model. Their context's speaker is the
participant who typed the last turn, or nil for speech (the model hears
everyone mixed).
Conversation items go to the owner (Octoroom.Agent.ConversationEvents):
the model's transcripts of what it heard and what it said. User items
have no speaker unless typed.
Options: :model (needed, such as "gemini-3.1-flash-live-preview"),
:voice, :api_key (default GOOGLE_API_KEY, then GEMINI_API_KEY),
:context_window_compression (false to disable, or
[trigger_tokens: ..., target_tokens: ...]; defaults to 104_857 / 52_428),
:input_audio_transcription (default true), :output_audio_transcription
(default true), :response_modalities (default ["AUDIO"]), and,
defaulting to the runner context's, :instructions, :initial_text,
:tools and :context. The socket starts only under a runner; for tests,
pass send: fn message -> ... end to capture what would go to Gemini, and
feed its events with {:gemini_live_socket, event} messages.