pub struct ContextBudget {
pub limits: ModelContextLimits,
pub available_input: u64,
pub target: u64,
pub auto_compaction_threshold: u64,
pub used: u64,
}Expand description
Token budget derived from ModelContextLimits.
Fields§
§limits: ModelContextLimitsLimits the budget was derived from.
available_input: u64Available input budget (context window − reserved completion − overhead).
target: u64Target selection budget (80% of available input).
auto_compaction_threshold: u64Auto-compaction trigger threshold (92% of available input).
used: u64Estimated tokens of currently rendered (Visible + Pinned) items.
Implementations§
Source§impl ContextBudget
impl ContextBudget
Sourcepub fn from_limits(limits: ModelContextLimits, items: &[ContextItem]) -> Self
pub fn from_limits(limits: ModelContextLimits, items: &[ContextItem]) -> Self
Build a budget from resolved limits and the currently rendered items.
Sourcepub fn exceeds_target(&self) -> bool
pub fn exceeds_target(&self) -> bool
Whether rendered items exceed the target selection budget.
Sourcepub fn exceeds_auto_compaction(&self) -> bool
pub fn exceeds_auto_compaction(&self) -> bool
Whether rendered items exceed the auto-compaction threshold.
Sourcepub fn remaining_to_target(&self) -> u64
pub fn remaining_to_target(&self) -> u64
Remaining tokens before the target budget is reached.
Trait Implementations§
Source§impl Clone for ContextBudget
impl Clone for ContextBudget
Source§fn clone(&self) -> ContextBudget
fn clone(&self) -> ContextBudget
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ContextBudget
impl Debug for ContextBudget
impl Eq for ContextBudget
Source§impl PartialEq for ContextBudget
impl PartialEq for ContextBudget
impl StructuralPartialEq for ContextBudget
Auto Trait Implementations§
impl Freeze for ContextBudget
impl RefUnwindSafe for ContextBudget
impl Send for ContextBudget
impl Sync for ContextBudget
impl Unpin for ContextBudget
impl UnsafeUnpin for ContextBudget
impl UnwindSafe for ContextBudget
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