pub struct AgentState { /* private fields */ }Expand description
Agent runtime state.
Manages all mutable state during agent execution. All fields are private to enforce encapsulation.
Implementations§
Source§impl AgentState
impl AgentState
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to history.
Sourcepub fn messages_mut(&mut self) -> &mut Vec<Message>
pub fn messages_mut(&mut self) -> &mut Vec<Message>
Get mutable reference to message history.
Sourcepub fn set_messages(&mut self, messages: Vec<Message>)
pub fn set_messages(&mut self, messages: Vec<Message>)
Replace message history (used in compression).
This method validates and cleans orphaned tool results/tool uses before setting the message history to prevent API errors.
Sourcepub fn track_usage(&self, usage: &Usage)
pub fn track_usage(&self, usage: &Usage)
Track token usage from API response.
Sourcepub fn total_input_tokens(&self) -> u64
pub fn total_input_tokens(&self) -> u64
Get total input tokens consumed.
Sourcepub fn total_output_tokens(&self) -> u64
pub fn total_output_tokens(&self) -> u64
Get total output tokens generated.
Sourcepub fn last_input_tokens(&self) -> u64
pub fn last_input_tokens(&self) -> u64
Get last input tokens (for compression decisions).
Sourcepub fn set_total_input_tokens(&self, value: u64)
pub fn set_total_input_tokens(&self, value: u64)
Set total input tokens (used after compression).
Sourcepub fn set_total_output_tokens(&self, value: u64)
pub fn set_total_output_tokens(&self, value: u64)
Set total output tokens.
Sourcepub fn set_last_input_tokens(&self, value: u64)
pub fn set_last_input_tokens(&self, value: u64)
Set last input tokens (used after compression).
Sourcepub fn mark_tool_input_previewed(&mut self, tool_id: String)
pub fn mark_tool_input_previewed(&mut self, tool_id: String)
Mark a tool input as previewed during streaming.
Sourcepub fn was_tool_input_previewed(&self, tool_id: &str) -> bool
pub fn was_tool_input_previewed(&self, tool_id: &str) -> bool
Check if a tool input was already previewed.
Sourcepub fn remove_previewed_tool_input(&mut self, tool_id: &str) -> bool
pub fn remove_previewed_tool_input(&mut self, tool_id: &str) -> bool
Remove a tool input from previewed set (after processing).
Sourcepub fn increment_todo_reminder(&mut self, todo_hash: String) -> usize
pub fn increment_todo_reminder(&mut self, todo_hash: String) -> usize
Increment todo reminder count for a todo item. Returns the new count.
Sourcepub fn todo_reminder_count(&self, todo_hash: &str) -> usize
pub fn todo_reminder_count(&self, todo_hash: &str) -> usize
Get todo reminder count for a todo item.
Sourcepub fn todo_reminder_count_map(&self) -> &HashMap<String, usize>
pub fn todo_reminder_count_map(&self) -> &HashMap<String, usize>
Get reference to the entire todo reminder count map.
Sourcepub fn todo_reminder_count_map_mut(&mut self) -> &mut HashMap<String, usize>
pub fn todo_reminder_count_map_mut(&mut self) -> &mut HashMap<String, usize>
Get mutable reference to the entire todo reminder count map.
Sourcepub fn is_todo_reminder_limit_reached(
&self,
todo_hash: &str,
max_reminders: usize,
) -> bool
pub fn is_todo_reminder_limit_reached( &self, todo_hash: &str, max_reminders: usize, ) -> bool
Check if todo reminder limit reached.
Sourcepub fn read_history(&self) -> &ReadHistoryTracker
pub fn read_history(&self) -> &ReadHistoryTracker
Get reference to read history tracker.
Sourcepub fn read_history_mut(&mut self) -> &mut ReadHistoryTracker
pub fn read_history_mut(&mut self) -> &mut ReadHistoryTracker
Get mutable reference to read history tracker.
Sourcepub fn add_pending_input(&mut self, input: String)
pub fn add_pending_input(&mut self, input: String)
Add a pending input to queue.
Sourcepub fn has_pending_inputs(&self) -> bool
pub fn has_pending_inputs(&self) -> bool
Check if there are pending inputs.
Sourcepub fn pending_inputs_vec(&self) -> &Vec<String>
pub fn pending_inputs_vec(&self) -> &Vec<String>
Get reference to pending inputs vector.
Sourcepub fn pending_inputs_vec_mut(&mut self) -> &mut Vec<String>
pub fn pending_inputs_vec_mut(&mut self) -> &mut Vec<String>
Get mutable reference to pending inputs vector.
Sourcepub fn take_pending_inputs(&mut self) -> Vec<String>
pub fn take_pending_inputs(&mut self) -> Vec<String>
Take all pending inputs (drains the queue).
Sourcepub fn pending_input_count(&self) -> usize
pub fn pending_input_count(&self) -> usize
Get count of pending inputs.
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get message count.