pub struct AgentState { /* private fields */ }Expand description
Context and control state, without a model, executor, clock, or event sink. Every transition is synchronous; the caller interprets returned effects.
Implementations§
Source§impl AgentState
impl AgentState
pub fn history(&self) -> &[Message]
pub fn last_usage(&self) -> Option<TokenUsage>
pub fn run_usage(&self) -> Option<TokenUsage>
pub fn is_idle(&self) -> bool
pub fn pending_operation(&self) -> Option<PendingOperation>
Sourcepub fn is_model_boundary(&self) -> bool
pub fn is_model_boundary(&self) -> bool
A pending tool batch leaves a call/result boundary incomplete. It must settle before this history can be used as model input or forked.
Sourcepub fn effect(&self) -> Option<Effect>
pub fn effect(&self) -> Option<Effect>
The next effect, or terminal outcome, without advancing the controller.
Sourcepub fn begin_effect(&mut self, operation: OperationId) -> Result<(), StateError>
pub fn begin_effect(&mut self, operation: OperationId) -> Result<(), StateError>
An interpreter must not dispatch a dropped future’s operation again.
pub fn can_replace_at_boundary(&self) -> bool
pub fn cancel_at_boundary(&mut self) -> Result<(), StateError>
Sourcepub fn replace_at_boundary(
&mut self,
history: Vec<Message>,
usage: Option<TokenUsage>,
) -> Result<(), StateError>
pub fn replace_at_boundary( &mut self, history: Vec<Message>, usage: Option<TokenUsage>, ) -> Result<(), StateError>
Install derived context between generations while retaining run policy counters. The old operation identity can no longer complete this state.
Sourcepub fn recover_interrupted(&mut self) -> Result<(), StateError>
pub fn recover_interrupted(&mut self) -> Result<(), StateError>
Explicitly abandon work whose future was dropped. Completed observations survive; an executing tool batch is reconciled as unknown, never replayed.
pub fn replace_context( &mut self, history: Vec<Message>, usage: Option<TokenUsage>, ) -> Result<(), StateError>
pub fn append_input(&mut self, message: Message) -> Result<(), StateError>
Sourcepub fn append_system(&mut self, parts: Vec<Content>) -> Result<(), StateError>
pub fn append_system(&mut self, parts: Vec<Content>) -> Result<(), StateError>
Record runtime observations at a settled boundary without changing the run’s result, usage, or truncation counters.
pub fn truncate_history( &mut self, index: usize, ) -> Result<Vec<Message>, StateError>
pub fn set_max_truncated_resumes(&mut self, resumes: u32)
pub fn start(&mut self) -> Result<Effect, StateError>
Sourcepub fn generation_failed(
&mut self,
operation: OperationId,
) -> Result<(), StateError>
pub fn generation_failed( &mut self, operation: OperationId, ) -> Result<(), StateError>
Stop a failed or cancelled generation without adding a partial response.
pub fn generated( &mut self, operation: OperationId, output: GenerateOutput, ) -> Result<Effect, StateError>
Sourcepub fn tools_completed(
&mut self,
operation: OperationId,
results: Vec<ToolResult>,
cancelled: bool,
) -> Result<Effect, StateError>
pub fn tools_completed( &mut self, operation: OperationId, results: Vec<ToolResult>, cancelled: bool, ) -> Result<Effect, StateError>
Results are in call order, including cancellation or unknown outcomes. Cancellation settles the entire batch and prevents another generation.
Trait Implementations§
Source§impl Clone for AgentState
impl Clone for AgentState
Source§fn clone(&self) -> AgentState
fn clone(&self) -> AgentState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more