pub struct ConversationHistory { /* private fields */ }Expand description
Conversation history manager with forge-style compaction support
Implementations§
Source§impl ConversationHistory
impl ConversationHistory
pub fn new() -> Self
Sourcepub fn with_config(config: CompactConfig) -> Self
pub fn with_config(config: CompactConfig) -> Self
Create with custom compaction configuration
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Create with aggressive compaction for limited context windows
Sourcepub fn estimate_tokens(text: &str) -> usize
pub fn estimate_tokens(text: &str) -> usize
Estimate tokens in a string (~4 characters per token) Public so it can be used for pre-request context size estimation
Sourcepub fn add_turn(
&mut self,
user_message: String,
assistant_response: String,
tool_calls: Vec<ToolCallRecord>,
)
pub fn add_turn( &mut self, user_message: String, assistant_response: String, tool_calls: Vec<ToolCallRecord>, )
Add a new conversation turn
Sourcepub fn add_turn_droppable(
&mut self,
user_message: String,
assistant_response: String,
tool_calls: Vec<ToolCallRecord>,
droppable: bool,
)
pub fn add_turn_droppable( &mut self, user_message: String, assistant_response: String, tool_calls: Vec<ToolCallRecord>, droppable: bool, )
Add a turn with explicit droppable flag
Sourcepub fn needs_compaction(&self) -> bool
pub fn needs_compaction(&self) -> bool
Check if compaction is needed using forge-style thresholds
Sourcepub fn compaction_reason(&self) -> Option<String>
pub fn compaction_reason(&self) -> Option<String>
Get the reason for compaction (for logging)
Sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Get current token count
Sourcepub fn turn_count(&self) -> usize
pub fn turn_count(&self) -> usize
Get number of turns
Sourcepub fn user_turn_count(&self) -> usize
pub fn user_turn_count(&self) -> usize
Get number of user turns
Sourcepub fn compact(&mut self) -> Option<String>
pub fn compact(&mut self) -> Option<String>
Perform forge-style compaction with smart eviction Returns the summary that was created (for logging/display)
Sourcepub fn emergency_compact(&mut self) -> Option<String>
pub fn emergency_compact(&mut self) -> Option<String>
Emergency compaction - more aggressive than normal Used when “input too long” error occurs and we need to reduce context urgently. Temporarily switches to aggressive config, compacts, then restores original.
Sourcepub fn to_messages(&self) -> Vec<Message>
pub fn to_messages(&self) -> Vec<Message>
Convert history to Rig Message format for the agent Uses structured summary frames to preserve context
Sourcepub fn files_read(&self) -> impl Iterator<Item = &str>
pub fn files_read(&self) -> impl Iterator<Item = &str>
Get files that have been read during this session
Sourcepub fn files_written(&self) -> impl Iterator<Item = &str>
pub fn files_written(&self) -> impl Iterator<Item = &str>
Get files that have been written during this session
Trait Implementations§
Source§impl Clone for ConversationHistory
impl Clone for ConversationHistory
Source§fn clone(&self) -> ConversationHistory
fn clone(&self) -> ConversationHistory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConversationHistory
impl Debug for ConversationHistory
Auto Trait Implementations§
impl Freeze for ConversationHistory
impl RefUnwindSafe for ConversationHistory
impl Send for ConversationHistory
impl Sync for ConversationHistory
impl Unpin for ConversationHistory
impl UnwindSafe for ConversationHistory
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more