pub struct VecHistory { /* private fields */ }Expand description
A History implementation backed by Vec<Message> + Mutex, with token
accounting.
Implementations§
Source§impl VecHistory
impl VecHistory
Trait Implementations§
Source§impl Default for VecHistory
impl Default for VecHistory
Source§fn default() -> VecHistory
fn default() -> VecHistory
Returns the “default value” for a type. Read more
Source§impl History for VecHistory
impl History for VecHistory
Source§fn snapshot(&self) -> Vec<Message>
fn snapshot(&self) -> Vec<Message>
A snapshot of the current history, to be fed into the next LLM call.
Source§fn replace(&self, messages: Vec<Message>)
fn replace(&self, messages: Vec<Message>)
Replace the entire message list after compression. The turn main loop calls this
to write back the new list consisting of a summary plus the retained tail. The
implementation should also reset the token estimation baseline, since the old
actual token counts no longer apply to the new list.
Source§fn splice_prefix(&self, drop_count: usize, summary: Message) -> usize
fn splice_prefix(&self, drop_count: usize, summary: Message) -> usize
Prefix splice: replaces the first
drop_count messages in the current list
with the single summary message, preserving everything after them. Returns the
actual number of messages dropped (drop_count is clamped to the current length). Read moreSource§fn len(&self) -> usize
fn len(&self) -> usize
Number of messages currently held. Used to record a rollback boundary before a turn
appends its prompt, so
Self::truncate can undo it if the turn fails permanently.Source§fn truncate(&self, len: usize)
fn truncate(&self, len: usize)
Truncates the message list to at most
len messages, dropping any tail beyond it.
A no-op when len >= current length. Read moreSource§fn record_input_tokens(&self, tokens: u64)
fn record_input_tokens(&self, tokens: u64)
Records the actual input token count from the last LLM call
(
input + cache_read + cache_creation). Serves as the precise baseline for
Self::token_estimate; subsequent Self::append messages are accumulated
incrementally using a character heuristic.Source§fn token_estimate(&self) -> Option<u64>
fn token_estimate(&self) -> Option<u64>
Estimates the token count for the current history.
None indicates the history is
empty or no estimate is available.Auto Trait Implementations§
impl !Freeze for VecHistory
impl RefUnwindSafe for VecHistory
impl Send for VecHistory
impl Sync for VecHistory
impl Unpin for VecHistory
impl UnsafeUnpin for VecHistory
impl UnwindSafe for VecHistory
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