Add an item to the context. Returns Result with the added item or error.
Remove an item from the context. Returns true if removed, false if not found.
Check if an item with the given content can be added to a category.
Get all items in a category, sorted by priority (desc) then addedAt (asc).
Get all items sorted by priority (desc) then addedAt (asc).
Build messages array from context items for model requests.
Get the system prompt from system category items.
Get current context statistics.
Get remaining tokens available in a category.
Get total remaining tokens across all categories.
Clear all items from the context.
Clear items from a specific category. Returns number of items removed.
Count tokens in text using adapter or fallback estimation.
Manages context window for agents with token budget enforcement.