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
impl AgentSession
Sourcepub fn new(
agent: Agent,
store: Arc<dyn DurableConversationStore>,
conversation_id: ConversationId,
namespace: MemoryNamespace,
policy: ConversationContextPolicy,
) -> Self
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.
Sourcepub fn with_summary_agent(
self,
agent: Agent,
max_passes: ConversationSummaryPassLimit,
) -> Self
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.
Sourcepub fn recovery_usage(
&self,
request_id: CheckpointId,
) -> Result<Usage, AgentSessionError>
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.
Sourcepub fn run<'a>(
&'a self,
request_id: CheckpointId,
input: impl Into<String> + Send + 'a,
run: &'a RunContext,
) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentSessionError>>
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.
Sourcepub fn stream<'a>(
&'a self,
request_id: CheckpointId,
input: impl Into<String> + Send + 'a,
run: &'a RunContext,
) -> AgentEventStream<'a, AgentSessionError>
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.
Sourcepub 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>>
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
impl Clone for AgentSession
Source§fn clone(&self) -> AgentSession
fn clone(&self) -> AgentSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more