pub trait ModelSession: Send {
type Turn: ModelTurn;
// Required method
fn begin_turn<'life0, 'async_trait>(
&'life0 mut self,
request: TurnRequest,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Self::Turn, LoopError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn model_name(&self) -> Option<&str> { ... }
}Expand description
An active model session that can produce sequential turns.
A session is created once per Agent::start call and lives for the
lifetime of the LoopDriver. Each call to begin_turn
hands the full transcript to the model and returns a streaming
ModelTurn.
Required Associated Types§
Required Methods§
Sourcefn begin_turn<'life0, 'async_trait>(
&'life0 mut self,
request: TurnRequest,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Self::Turn, LoopError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_turn<'life0, 'async_trait>(
&'life0 mut self,
request: TurnRequest,
cancellation: Option<TurnCancellation>,
) -> Pin<Box<dyn Future<Output = Result<Self::Turn, LoopError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start a new turn, sending the transcript and available tools to the model.
§Arguments
request– the turn payload including transcript and tool specs.cancellation– optional handle the implementation should poll to detect user-initiated cancellation.
§Errors
Returns LoopError::Cancelled when the turn is cancelled, or a
provider-specific error wrapped in LoopError.
Provided Methods§
Sourcefn model_name(&self) -> Option<&str>
fn model_name(&self) -> Option<&str>
Model identifier this session sends requests to, when known.
Stamped onto inference telemetry spans as the gen_ai.request.model
attribute from the OpenTelemetry GenAI semantic conventions. The
default returns None for sessions without a fixed model.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".