Context Manager • Rust AI Agent SDK
ContextManager: High-level context manager facade.
ContextManager
Defined in the context module.
Rust AI Agent SDK
High-level context manager facade.
Fields
| Name | Type | Description |
|---|---|---|
config | ContextConfig | Configuration |
budgeter | ContextBudgeter | Budgeter |
ledger | ContextLedger | Current ledger |
Methods
new
fn new(config: ContextConfig) -> SelfCreate a new context manager
Parameters:
| Name | Type |
|---|---|
config | ContextConfig |
default_for_model
fn default_for_model(model: impl Into<String>) -> SelfCreate with default config
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
allocate_budget
fn allocate_budget(&self) -> BudgetAllocationGet budget allocation
add_segment
fn add_segment(&mut self, segment: ContextSegment) -> ()Add a segment to the ledger
Parameters:
| Name | Type |
|---|---|
segment | ContextSegment |
remaining
fn remaining(&self) -> usizeGet remaining tokens
is_over_budget
fn is_over_budget(&self) -> boolCheck if over budget
utilization
fn utilization(&self) -> f64Get utilization
reset
fn reset(&mut self) -> ()Reset the ledger
track_system
fn track_system(&mut self, system_prompt: &str) -> ()Estimate and track system prompt
Parameters:
| Name | Type |
|---|---|
system_prompt | &str |
track_messages
fn track_messages(&mut self, messages: &[serde_json::Value]) -> ()Estimate and track messages
Parameters:
| Name | Type |
|---|---|
messages | &[serde_json::Value] |
track_tools
fn track_tools(&mut self, tools: &[serde_json::Value]) -> ()Estimate and track tools
Parameters:
| Name | Type |
|---|---|
tools | &[serde_json::Value] |
Source
View on GitHubpraisonai/src/context/mod.rs at line 417