Context Ledger • AI Agent SDK
ContextLedger: Tracks token usage across context segments.
ContextLedger
Defined in the models module.
AI Agent
Tracks token usage across context segments.
Provides per-segment token counts and total usage.
Properties
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
ResponseField
intNo description available.
Methods
total()
Total tokens across all segments.
get_segment()Get token count for a segment.
set_segment()Set token count for a segment.
add_segment()Add tokens to a segment.
Internal & Generic Methods
- to_dict: Convert to dictionary.
- copy: Create a copy of this ledger.
Source
View on GitHubpraisonaiagents/context/models.py at line 26