pub struct Session { /* private fields */ }Expand description
Thin multi-turn orchestrator (one agent, persistent conversation state).
Implementations§
Source§impl Session
impl Session
Sourcepub const fn turn_count(self) -> u64
pub const fn turn_count(self) -> u64
Number of turns completed successfully (or cancelled) through this session.
Sourcepub async fn run_turn(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
state: &mut dyn ConversationState,
input: TurnInput,
options: TurnOptions,
) -> Result<TurnOutcome, MachiError>
pub async fn run_turn( &mut self, agent: &Agent, sampler: &dyn LlmSampler, state: &mut dyn ConversationState, input: TurnInput, options: TurnOptions, ) -> Result<TurnOutcome, MachiError>
Sourcepub async fn run_turn_with_metrics(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
state: &mut dyn ConversationState,
input: TurnInput,
options: TurnOptions,
metrics: &dyn MetricsSink,
) -> Result<TurnOutcome, MachiError>
pub async fn run_turn_with_metrics( &mut self, agent: &Agent, sampler: &dyn LlmSampler, state: &mut dyn ConversationState, input: TurnInput, options: TurnOptions, metrics: &dyn MetricsSink, ) -> Result<TurnOutcome, MachiError>
Sourcepub async fn run_turn_on_handle(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
handle: &ChatStateHandle,
input: TurnInput,
options: TurnOptions,
) -> Result<TurnOutcome, MachiError>
pub async fn run_turn_on_handle( &mut self, agent: &Agent, sampler: &dyn LlmSampler, handle: &ChatStateHandle, input: TurnInput, options: TurnOptions, ) -> Result<TurnOutcome, MachiError>
Run a turn against a ChatStateHandle: snapshot → local turn → replace + usage.
The turn loop remains synchronous over a local buffer; the actor is the durable source of truth between turns.
§Errors
Propagates turn or handle channel failures.
Sourcepub async fn run_turn_on_handle_with_metrics(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
handle: &ChatStateHandle,
input: TurnInput,
options: TurnOptions,
metrics: &dyn MetricsSink,
) -> Result<TurnOutcome, MachiError>
pub async fn run_turn_on_handle_with_metrics( &mut self, agent: &Agent, sampler: &dyn LlmSampler, handle: &ChatStateHandle, input: TurnInput, options: TurnOptions, metrics: &dyn MetricsSink, ) -> Result<TurnOutcome, MachiError>
Sourcepub async fn run_turn_on_handle_checkpointed(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
handle: &ChatStateHandle,
input: TurnInput,
options: TurnOptions,
metrics: &dyn MetricsSink,
store: Option<&dyn ChatPersistence>,
) -> Result<TurnOutcome, MachiError>
pub async fn run_turn_on_handle_checkpointed( &mut self, agent: &Agent, sampler: &dyn LlmSampler, handle: &ChatStateHandle, input: TurnInput, options: TurnOptions, metrics: &dyn MetricsSink, store: Option<&dyn ChatPersistence>, ) -> Result<TurnOutcome, MachiError>
Session turn with optional durable checkpoint after each turn.
When store is Some, the handle snapshot is written after the turn
(including failed turns that still mutated history).
§Errors
Turn failures or persistence I/O.
Sourcepub async fn open_checkpointed_turn(
&mut self,
agent: &Agent,
sampler: &dyn LlmSampler,
store: &dyn ChatPersistence,
input: TurnInput,
options: TurnOptions,
metrics: &dyn MetricsSink,
) -> Result<(ChatStateHandle, TurnOutcome), MachiError>
pub async fn open_checkpointed_turn( &mut self, agent: &Agent, sampler: &dyn LlmSampler, store: &dyn ChatPersistence, input: TurnInput, options: TurnOptions, metrics: &dyn MetricsSink, ) -> Result<(ChatStateHandle, TurnOutcome), MachiError>
Open a handle from store (or empty), run one checkpointed turn, return handle + outcome.
Convenience for hosts that own a single file/session path.
§Errors
Load / turn / save failures.