pub struct AgentState {
pub iteration: usize,
pub start_time: Instant,
pub total_tokens: u32,
pub should_continue: bool,
pub stop_reason: Option<StopReason>,
pub error_count: usize,
pub successful_tool_calls: usize,
}Expand description
Current state of the agent during execution
Fields§
§iteration: usizeNumber of iterations completed
start_time: InstantWhen the agent started
total_tokens: u32Total tokens used across all calls
should_continue: boolWhether the agent should continue
stop_reason: Option<StopReason>Reason for stopping (if stopped)
error_count: usizeNumber of errors encountered
successful_tool_calls: usizeNumber of successful tool calls
Implementations§
Source§impl AgentState
impl AgentState
pub fn new() -> Self
Sourcepub fn exceeded_time_limit(&self, max_duration: Option<Duration>) -> bool
pub fn exceeded_time_limit(&self, max_duration: Option<Duration>) -> bool
Check if we’ve exceeded time limit
Sourcepub fn complete(&mut self, reason: StopReason)
pub fn complete(&mut self, reason: StopReason)
Mark the agent as complete
Sourcepub fn next_iteration(&mut self)
pub fn next_iteration(&mut self)
Increment iteration counter
Sourcepub fn add_tokens(&mut self, tokens: u32)
pub fn add_tokens(&mut self, tokens: u32)
Add tokens to the total
Sourcepub fn record_error(&mut self)
pub fn record_error(&mut self)
Record an error
Sourcepub fn record_tool_success(&mut self)
pub fn record_tool_success(&mut self)
Record a successful tool call
Trait Implementations§
Source§impl Clone for AgentState
impl Clone for AgentState
Source§fn clone(&self) -> AgentState
fn clone(&self) -> AgentState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentState
impl Debug for AgentState
Auto Trait Implementations§
impl Freeze for AgentState
impl RefUnwindSafe for AgentState
impl Send for AgentState
impl Sync for AgentState
impl Unpin for AgentState
impl UnwindSafe for AgentState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more