Context Budgeter • Rust AI Agent SDK

ContextBudgeter: Manages context budget allocation.

ContextBudgeter

Defined in the context module.

Rust AI Agent SDK

Manages context budget allocation.

Fields

NameTypeDescription
modelStringModel name
max_tokensusizeMaximum tokens
output_reserveusizeOutput reserve

Methods

new

rust
fn new(model: impl Into<String>) -> Self

Create a new budgeter for a model

Parameters:

NameType
modelimpl Into&lt;String&gt;

with_limits

rust
fn with_limits(model: impl Into<String>, max_tokens: usize, output_reserve: usize) -> Self

Create with custom limits

Parameters:

NameType
modelimpl Into&lt;String&gt;
max_tokensusize
output_reserveusize

available

rust
fn available(&self) -> usize

Get available tokens (total – output reserve)

allocate

rust
fn allocate(&self) -> BudgetAllocation

Allocate budget

allocate_custom

rust
fn allocate_custom(
        &self,
        system_pct: f64,
        history_pct: f64,
        tools_pct: f64,
    ) -> BudgetAllocation

Allocate with custom ratios

Parameters:

NameType
system_pctf64
history_pctf64
tools_pctf64

Source

View on GitHub

praisonai/src/context/mod.rs at line 359


Related Documentation