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
| Name | Type | Description |
|---|---|---|
model | String | Model name |
max_tokens | usize | Maximum tokens |
output_reserve | usize | Output reserve |
Methods
new
fn new(model: impl Into<String>) -> SelfCreate a new budgeter for a model
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
with_limits
fn with_limits(model: impl Into<String>, max_tokens: usize, output_reserve: usize) -> SelfCreate with custom limits
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
max_tokens | usize |
output_reserve | usize |
available
fn available(&self) -> usizeGet available tokens (total – output reserve)
allocate
fn allocate(&self) -> BudgetAllocationAllocate budget
allocate_custom
fn allocate_custom(
&self,
system_pct: f64,
history_pct: f64,
tools_pct: f64,
) -> BudgetAllocationAllocate with custom ratios
Parameters:
| Name | Type |
|---|---|
system_pct | f64 |
history_pct | f64 |
tools_pct | f64 |
Source
View on GitHubpraisonai/src/context/mod.rs at line 359