Skip to main content

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.

ContextLedger

Defined in the context module.
Rust AI Agent SDK Tracks token usage across different context segments.

Fields

NameTypeDescription
segmentsVec<ContextSegment>Segments in the ledger
total_tokensusizeTotal tokens used
max_tokensusizeMaximum allowed tokens

Methods

new

fn new(max_tokens: usize) -> Self
Create a new ledger with max tokens Parameters:
NameType
max_tokensusize

add

fn add(&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 percentage

Source

View on GitHub

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

Rust Context Management

Rust Token Management