pub struct SessionRunner { /* private fields */ }Expand description
Coordinator that drives run_agent while persisting the session after
every turn. Implements TurnSink so the loop calls back after each turn.
Implementations§
Source§impl SessionRunner
impl SessionRunner
Sourcepub fn new(
adapter: Arc<dyn PersistenceAdapter>,
session_id: SessionId,
model: impl Into<String>,
max_turns: usize,
system_message: Option<String>,
) -> Self
pub fn new( adapter: Arc<dyn PersistenceAdapter>, session_id: SessionId, model: impl Into<String>, max_turns: usize, system_message: Option<String>, ) -> Self
Create a runner for a new or empty session.
Sourcepub async fn load(
adapter: Arc<dyn PersistenceAdapter>,
session_id: SessionId,
) -> RuntimeResult<Option<Self>>
pub async fn load( adapter: Arc<dyn PersistenceAdapter>, session_id: SessionId, ) -> RuntimeResult<Option<Self>>
Load a persisted session into a runner, if the adapter has one.
Sourcepub fn messages(&self) -> Vec<AgentMessage>
pub fn messages(&self) -> Vec<AgentMessage>
Snapshot the runner’s current messages.
Sourcepub fn system_message(&self) -> Option<String>
pub fn system_message(&self) -> Option<String>
The system message (instructions) for this session, if any.
Trait Implementations§
Source§impl TurnSink for SessionRunner
impl TurnSink for SessionRunner
Source§fn after_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
_turn: usize,
messages: &'life1 [AgentMessage],
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_turn<'life0, 'life1, 'async_trait>(
&'life0 self,
_turn: usize,
messages: &'life1 [AgentMessage],
) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after turn
turn (1-indexed) with the full message history so
far. Returning Err aborts the run with that error.Auto Trait Implementations§
impl !RefUnwindSafe for SessionRunner
impl !UnwindSafe for SessionRunner
impl Freeze for SessionRunner
impl Send for SessionRunner
impl Sync for SessionRunner
impl Unpin for SessionRunner
impl UnsafeUnpin for SessionRunner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more