Skip to main content

ContextManager

Defined in the context module.
Rust AI Agent SDK High-level context manager facade.

Fields

NameTypeDescription
configContextConfigConfiguration
budgeterContextBudgeterBudgeter
ledgerContextLedgerCurrent ledger

Methods

new

fn new(config: ContextConfig) -> Self
Create a new context manager Parameters:
NameType
configContextConfig

default_for_model

fn default_for_model(model: impl Into<String>) -> Self
Create with default config Parameters:
NameType
modelimpl Into&lt;String&gt;

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:
NameType
segmentContextSegment

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:
NameType
system_prompt&str

track_messages

fn track_messages(&mut self, messages: &[serde_json::Value]) -> ()
Estimate and track messages Parameters:
NameType
messages&[serde_json::Value]

track_tools

fn track_tools(&mut self, tools: &[serde_json::Value]) -> ()
Estimate and track tools Parameters:
NameType
tools&[serde_json::Value]

Source

View on GitHub

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