Module callbacks

Module callbacks 

Source
Expand description

Typed callback registry for Live session events.

Fast lane callbacks (sync, < 1ms): audio, text, transcripts, VAD. Control lane callbacks (async, can block): tool calls, lifecycle, interruptions. Outbound interceptors: transform tool responses, inject context at turn boundaries.

§Callback Modes

Each control-lane callback has an associated CallbackMode:

  • Blocking — awaited inline. The event loop waits for completion before processing the next event. Guarantees ordering and state consistency.
  • Concurrent — spawned as a detached tokio task. The event loop continues immediately. Use for fire-and-forget work (logging, background agent dispatch, analytics).

Fast-lane callbacks (audio, text, VAD) are always sync and inline. Interceptors (before_tool_response, on_turn_boundary) are always blocking.

Some control-lane callbacks are forced-blocking (no concurrent variant): on_interrupted (must clear state before audio resumes), on_tool_call (return value is the tool response).

Structs§

EventCallbacks
Typed callback registry for Live session events.

Enums§

CallbackMode
Controls how a control-lane callback is executed relative to the event loop.

Type Aliases§

AsyncCallback
Control-lane async callback with no payload.
AsyncCallbackWith
Control-lane async callback over one payload value.
AsyncCallbackWith2
Control-lane async callback over two payload values.
AudioCallback
Fast-lane sync callback over a raw audio chunk.
BeforeToolResponseCallback
Middleware over outgoing tool responses (inspect/rewrite before send).
InstructionFn
Sync state-reactive instruction generator (None = leave unchanged).
PhaseCallback
Fast-lane sync callback over a session phase change.
SignalCallback
Fast-lane sync callback with no payload (VAD start/end).
TextCallback
Fast-lane sync callback over a text payload (delta, accumulated text, thought).
ToolCallCallback
Tool-call override: return Some(responses) to reply, None to defer to auto-dispatch via the registered ToolDispatcher.
TranscriptCallback
Fast-lane sync callback over a transcript chunk with its is_final flag.
UsageCallback
Fast-lane sync callback over usage metadata.