pub struct AgentMemory { /* private fields */ }Expand description
Memory structure that replaces raw Vec<Value> messages
Maintains the agent’s reasoning steps and converts them to OpenAI format
Implementations§
Source§impl AgentMemory
impl AgentMemory
Sourcepub fn new(system_prompt: Option<String>) -> Self
pub fn new(system_prompt: Option<String>) -> Self
Create a new memory with optional system prompt
Sourcepub fn with_default_system() -> Self
pub fn with_default_system() -> Self
Create memory with default system prompt
Sourcepub fn as_messages(&self) -> Vec<Value>
pub fn as_messages(&self) -> Vec<Value>
Convert memory to OpenAI message format
Sourcepub fn clear_steps(&mut self)
pub fn clear_steps(&mut self)
Clear all steps but keep system prompt
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get number of steps
Sourcepub fn filter_steps<F>(&self, predicate: F) -> Vec<&AgentStep>
pub fn filter_steps<F>(&self, predicate: F) -> Vec<&AgentStep>
Get all steps of a specific type
Sourcepub fn count_actions(&self) -> usize
pub fn count_actions(&self) -> usize
Count steps of a specific variant
pub fn count_observations(&self) -> usize
pub fn set_final_answer_structured(&mut self, structured: Value)
Trait Implementations§
Source§impl Clone for AgentMemory
impl Clone for AgentMemory
Source§impl Debug for AgentMemory
impl Debug for AgentMemory
Source§impl Default for AgentMemory
impl Default for AgentMemory
Source§impl<'de> Deserialize<'de> for AgentMemory
impl<'de> Deserialize<'de> for AgentMemory
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AgentMemory
impl RefUnwindSafe for AgentMemory
impl Send for AgentMemory
impl Sync for AgentMemory
impl Unpin for AgentMemory
impl UnsafeUnpin for AgentMemory
impl UnwindSafe for AgentMemory
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