Skip to main content

AgentSession

Struct AgentSession 

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

A durable conversation with exclusive admission before any model or tool work.

All writers must use this boundary. Low-level conversation APIs intentionally remain available and do not honor this admission record. The conversation’s UUID is reserved as its admission checkpoint ID; request IDs must differ.

Implementations§

Source§

impl AgentSession

Source

pub fn new( agent: Agent, store: Arc<dyn DurableConversationStore>, conversation_id: ConversationId, namespace: MemoryNamespace, policy: ConversationContextPolicy, ) -> Self

Binds an Agent and durable store to one conversation and context policy.

Source

pub fn with_summary_agent( self, agent: Agent, max_passes: ConversationSummaryPassLimit, ) -> Self

Compacts older transcript batches with a checkpointed Agent before a turn. Summary work shares the caller’s capabilities, budget, and deadline. The pass limit applies across retries of the same request.

Source

pub fn recovery_usage( &self, request_id: CheckpointId, ) -> Result<Usage, AgentSessionError>

Returns the latest persisted usage for an occupied request. In-flight remote work can consume more than this snapshot; reconcile that uncertainty before explicitly authorizing an interrupted-turn retry.

§Errors

Returns an error for an unoccupied or mismatched request, invalid admission data, or an unreadable checkpoint.

Source

pub fn run<'a>( &'a self, request_id: CheckpointId, input: impl Into<String> + Send + 'a, run: &'a RunContext, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentSessionError>>

Runs one request. Reuse the same ID and exact input for transport retries. Completed requests replay their stored result; active ones return Busy. Failure or cancellation retains admission until explicit recovery.

Source

pub fn stream<'a>( &'a self, request_id: CheckpointId, input: impl Into<String> + Send + 'a, run: &'a RunContext, ) -> AgentEventStream<'a, AgentSessionError>

Streams an admitted request. Dropping it retains admission for recovery. ConversationCommitted is emitted after commit and admission release.

Source

pub fn recover_after_owner_exit<'a>( &'a self, request_id: CheckpointId, input: impl Into<String> + Send + 'a, run: &'a RunContext, expected_revision: u64, policy: ResumePolicy, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentSessionError>>

Recovers an occupied request after the host has stopped its prior owner.

The host MUST ensure the previous execution can no longer run. Revision CAS prevents competing recovery claims; it cannot fence external services. Restore the run’s budget using Self::recovery_usage before calling this. A request interrupted before checkpoint creation starts from its bound input.

Trait Implementations§

Source§

impl Clone for AgentSession

Source§

fn clone(&self) -> AgentSession

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentSession

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.