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

NameTypeDescription
configContextConfigConfiguration
budgeterContextBudgeterBudgeter
ledgerContextLedgerCurrent ledger

Methods

new

rust
fn new(config: ContextConfig) -> Self

Create a new context manager

Parameters:

NameType
configContextConfig

default_for_model

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

Create with default config

Parameters:

NameType
modelimpl Into&lt;String&gt;

allocate_budget

rust
fn allocate_budget(&self) -> BudgetAllocation

Get budget allocation

add_segment

rust
fn add_segment(&mut self, segment: ContextSegment) -> ()

Add a segment to the ledger

Parameters:

NameType
segmentContextSegment

remaining

rust
fn remaining(&self) -> usize

Get remaining tokens

is_over_budget

rust
fn is_over_budget(&self) -> bool

Check if over budget

utilization

rust
fn utilization(&self) -> f64

Get utilization

reset

rust
fn reset(&mut self) -> ()

Reset the ledger

track_system

rust
fn track_system(&mut self, system_prompt: &str) -> ()

Estimate and track system prompt

Parameters:

NameType
system_prompt&str

track_messages

rust
fn track_messages(&mut self, messages: &[serde_json::Value]) -> ()

Estimate and track messages

Parameters:

NameType
messages&[serde_json::Value]

track_tools

rust
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


Related Documentation