pub struct TokenBudget {
pub max_tokens: usize,
pub compact_at_tokens: usize,
}Expand description
Token budget that triggers automatic compaction before the hard limit is hit.
The runtime estimates request size locally (via
ModelProvider::estimate_tokens)
and compacts when usage exceeds compact_at_tokens. If a request still
exceeds max_tokens after compaction, the turn ends to avoid an API
rejection.
compact_at_tokens defaults to 80% of max_tokens.
Fields§
§max_tokens: usizeHard ceiling — the turn ends before the model is called if exceeded.
compact_at_tokens: usizeSoft ceiling — proactively compact when crossed.
Implementations§
Trait Implementations§
Source§impl Clone for TokenBudget
impl Clone for TokenBudget
Source§fn clone(&self) -> TokenBudget
fn clone(&self) -> TokenBudget
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenBudget
impl Debug for TokenBudget
Source§impl PartialEq for TokenBudget
impl PartialEq for TokenBudget
impl Copy for TokenBudget
impl Eq for TokenBudget
impl StructuralPartialEq for TokenBudget
Auto Trait Implementations§
impl Freeze for TokenBudget
impl RefUnwindSafe for TokenBudget
impl Send for TokenBudget
impl Sync for TokenBudget
impl Unpin for TokenBudget
impl UnsafeUnpin for TokenBudget
impl UnwindSafe for TokenBudget
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.