Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
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) -> Self
Create a new context manager
Parameters:
| Name | Type |
|---|
config | ContextConfig |
default_for_model
fn default_for_model(model: impl Into<String>) -> Self
Create with default config
Parameters:
| Name | Type |
|---|
model | impl Into<String> |
allocate_budget
fn allocate_budget(&self) -> BudgetAllocation
Get 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) -> usize
Get remaining tokens
is_over_budget
fn is_over_budget(&self) -> bool
Check if over budget
utilization
fn utilization(&self) -> f64
Get 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] |
fn track_tools(&mut self, tools: &[serde_json::Value]) -> ()
Estimate and track tools
Parameters:
| Name | Type |
|---|
tools | &[serde_json::Value] |
Source
View on GitHub
praisonai/src/context/mod.rs at line 417