Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

The session owner: one per conversation, held by the harness.

Non-Clone by design — the owner is the lifecycle anchor. Cloneable SessionHandles are the operation entries; they neither own the lifecycle nor expose the writable state.

Implementations§

Source§

impl Session

Source

pub fn new( state: ConversationState, runner: Arc<TurnRunner>, options: TurnRunOptions, config: SessionConfig, ) -> Result<Session, SessionBuildRejection>

Build an idle session from a validated ConversationState plus the harness’s assembled runner and options.

Construction never calls the model or a tool and never starts work; a work is admitted only by submit. A state with an active turn (or, by the aggregate’s invariant, a leftover stamp) is rejected, and every by-value input (state, runner, options, config) comes back in SessionBuildRejection.

Every work runs through TurnRunner::run_in_conversation, which frames the lossless merged history plus the active turn; TurnRunOptions::frame is deliberately inert on that entry (the driver documents the same for its conversation entries), so per-work material projection is not wired here.

§Errors

Returns SessionBuildRejection carrying SessionError::InvalidInput when state is not idle.

Source

pub fn handle(&self) -> SessionHandle

A cloneable operation entry into this session.

Source

pub fn checkpoint(&self) -> Result<SessionCheckpoint, SessionError>

Export the session’s versioned save envelope — the complete idle state or the complete paused outcome, every retained work, the request-key replay tables, the TurnId allocation progress, and the configuration description.

Only a quiescent session exports: while a work is accepted / running (a cancel in progress included) the export is SessionError::Busy, and a faulted session refuses — no complete outcome exists to save. A closed session still exports, recording closed, so restoring it yields a closed session that replays accepted keys and accepts no new work. The envelope is a plain value: whether and when to persist it stays with the harness, and SessionCheckpoint::restore is the only way back in. Restore never calls the model or a tool, and a restored pause still needs an explicit resume under its remaining (not re-granted) deadline.

Source

pub async fn shutdown(&self)

Shut the session down: stop accepting, then wait for the running work to wind down.

Stops acceptance and fires the active work’s stop signal, then waits until no work is running. The session keeps its retrievable results and paused material readable through surviving SessionHandles; work submitted afterwards reports SessionError::Closed.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Session

Source§

fn drop(&mut self)

Stops acceptance and sends the stop signal to the active work.

The worker keeps its own Arc<SessionCore>, so no strong reference cycle exists and the in-flight run still publishes its terminal state after the owner is gone. Drop cannot await that wind-down, nor persist anything — an explicit shutdown covers those.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more