pub struct Truncation {
pub max_messages: usize,
pub preserve_first_user: bool,
}Expand description
Keep the most recent max_messages, always preserving any leading system
message(s) at the front. Mirrors upstream’s Truncation strategy.
Fields§
§max_messages: usize§preserve_first_user: boolWhen set, the earliest user message is retained alongside the recent
tail — see Truncation::preserve_first_user.
Implementations§
Source§impl Truncation
impl Truncation
pub fn new(max_messages: usize) -> Truncation
Sourcepub fn preserve_first_user(self) -> Truncation
pub fn preserve_first_user(self) -> Truncation
Also retain the earliest user message, whatever the budget.
Truncation drops the oldest turns, and the oldest turn is usually the
one that states the task — so a long conversation can lose the request
it is about while keeping the chatter that followed. Upstream added
this for the same reason (preserve_first_user_group on
TruncationStrategy, #7912).
Like upstream’s protected groups, the preserved message is kept
regardless of budget: the result may exceed max_messages by one.
Off by default, so existing behavior is unchanged.
Trait Implementations§
Source§impl Clone for Truncation
impl Clone for Truncation
Source§fn clone(&self) -> Truncation
fn clone(&self) -> Truncation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more