Struct LiveSessionBuilder
pub struct LiveSessionBuilder { /* private fields */ }Expand description
Builder for a callback-driven Live session.
Combines SessionConfig, EventCallbacks, tool dispatching, extractors,
computed state, phase machines, watchers, and temporal patterns into a
single connection setup. Call connect() to establish
the WebSocket connection and start the three-lane event processor.
For ergonomic usage, prefer the L2 Live builder from gemini-adk-fluent-rs
which wraps this with a fluent API.
Implementations§
§impl LiveSessionBuilder
impl LiveSessionBuilder
pub fn new(config: SessionConfig) -> LiveSessionBuilder
pub fn new(config: SessionConfig) -> LiveSessionBuilder
Create a new builder with the given session config.
pub fn with_state(self, state: State) -> LiveSessionBuilder
pub fn with_state(self, state: State) -> LiveSessionBuilder
Provide a pre-created State to use for this session.
If not set, a new State is created at connect time. Use this when the State needs to be shared with tools or other components before the session connects.
pub fn greeting(self, prompt: impl Into<String>) -> LiveSessionBuilder
pub fn greeting(self, prompt: impl Into<String>) -> LiveSessionBuilder
Set a greeting prompt sent on connect to trigger the model to speak first.
pub fn dispatcher(self, dispatcher: ToolDispatcher) -> LiveSessionBuilder
pub fn dispatcher(self, dispatcher: ToolDispatcher) -> LiveSessionBuilder
Set the tool dispatcher for auto-dispatch of tool calls.
pub fn callbacks(self, callbacks: EventCallbacks) -> LiveSessionBuilder
pub fn callbacks(self, callbacks: EventCallbacks) -> LiveSessionBuilder
Set the event callbacks.
pub fn extractor(self, extractor: Arc<dyn TurnExtractor>) -> LiveSessionBuilder
pub fn extractor(self, extractor: Arc<dyn TurnExtractor>) -> LiveSessionBuilder
Add a turn extractor that runs between turns.
pub fn computed(self, registry: ComputedRegistry) -> LiveSessionBuilder
pub fn computed(self, registry: ComputedRegistry) -> LiveSessionBuilder
Set the computed variable registry for derived state.
pub fn phase_machine(self, machine: PhaseMachine) -> LiveSessionBuilder
pub fn phase_machine(self, machine: PhaseMachine) -> LiveSessionBuilder
Set the phase machine for declarative conversation phase management.
pub fn watchers(self, registry: WatcherRegistry) -> LiveSessionBuilder
pub fn watchers(self, registry: WatcherRegistry) -> LiveSessionBuilder
Set the watcher registry for state change watchers.
pub fn temporal(self, registry: TemporalRegistry) -> LiveSessionBuilder
pub fn temporal(self, registry: TemporalRegistry) -> LiveSessionBuilder
Set the temporal pattern registry.
pub fn tool_execution_mode(
self,
tool_name: impl Into<String>,
mode: ToolExecutionMode,
) -> LiveSessionBuilder
pub fn tool_execution_mode( self, tool_name: impl Into<String>, mode: ToolExecutionMode, ) -> LiveSessionBuilder
Set the execution mode for a named tool.
Tools default to ToolExecutionMode::Standard. Set to
ToolExecutionMode::Background for zero-dead-air execution.
pub fn soft_turn_timeout(self, timeout: Duration) -> LiveSessionBuilder
pub fn soft_turn_timeout(self, timeout: Duration) -> LiveSessionBuilder
Enable soft turn detection for proactive silence awareness.
When proactiveAudio is enabled, the model may choose not to respond.
This sets a timeout after VAD end — if the model stays silent, a
lightweight “soft turn” fires to keep state updated without forcing
the model to speak.
pub fn steering_mode(self, mode: SteeringMode) -> LiveSessionBuilder
pub fn steering_mode(self, mode: SteeringMode) -> LiveSessionBuilder
Set the steering mode for how the phase machine delivers instructions.
pub fn context_delivery(self, mode: ContextDelivery) -> LiveSessionBuilder
pub fn context_delivery(self, mode: ContextDelivery) -> LiveSessionBuilder
Set the context delivery timing.
Immediate(default): send batched context during TurnComplete.Deferred: queue context and flush with next user send.
pub fn repair(self, config: RepairConfig) -> LiveSessionBuilder
pub fn repair(self, config: RepairConfig) -> LiveSessionBuilder
Enable the conversation repair protocol.
Tracks need fulfillment per phase and nudges the model when the conversation stalls on gathering required information.
pub fn persistence(
self,
backend: Arc<dyn SessionPersistence>,
) -> LiveSessionBuilder
pub fn persistence( self, backend: Arc<dyn SessionPersistence>, ) -> LiveSessionBuilder
Set a session persistence backend for surviving process restarts.
pub fn session_id(self, id: impl Into<String>) -> LiveSessionBuilder
pub fn session_id(self, id: impl Into<String>) -> LiveSessionBuilder
Set the session ID for persistence.
pub fn tool_advisory(self, enabled: bool) -> LiveSessionBuilder
pub fn tool_advisory(self, enabled: bool) -> LiveSessionBuilder
Enable or disable tool availability advisory on phase transitions.
pub fn telemetry_interval(self, interval: Duration) -> LiveSessionBuilder
pub fn telemetry_interval(self, interval: Duration) -> LiveSessionBuilder
Set the periodic telemetry emission interval.
When set, the processor periodically emits LiveEvent::Telemetry
and LiveEvent::TurnMetrics to the event stream.
pub async fn connect(self) -> Result<LiveHandle, AgentError>
pub async fn connect(self) -> Result<LiveHandle, AgentError>
Connect to Gemini and start the three-lane event processor.