Skip to main content

ModelSession

Trait ModelSession 

Source
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;
}
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§

Source

type Turn: ModelTurn

The turn type produced by this session.

Required Methods§

Source

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.

Implementors§