CompactionMessageIndex Class

Definition

A collection of CompactionMessageGroup instances and derived metrics based on a flat list of ChatMessage objects.

public sealed class CompactionMessageIndex
type CompactionMessageIndex = class
Public NotInheritable Class CompactionMessageIndex
Inheritance
CompactionMessageIndex

Remarks

CompactionMessageIndex provides structural grouping of messages into logical CompactionMessageGroup units. Individual groups can be marked as excluded without being removed, allowing compaction strategies to toggle visibility while preserving the full history for diagnostics or storage. Metrics are provided both including and excluding excluded groups, allowing strategies to make informed decisions based on the impact of potential exclusions.

Constructors

Name Description
CompactionMessageIndex(IList<CompactionMessageGroup>, Tokenizer)

Initializes a new instance of the CompactionMessageIndex class with the specified groups.

Properties

Name Description
Groups

Gets the list of message groups in this collection.

IncludedByteCount

Gets the total UTF-8 byte count across all included (non-excluded) groups.

IncludedGroupCount

Gets the total number of groups that are not excluded.

IncludedMessageCount

Gets the total number of messages across all included (non-excluded) groups.

IncludedNonSystemGroupCount

Gets the total number of groups across all included (non-excluded) groups that are not System.

IncludedTokenCount

Gets the total token count across all included (non-excluded) groups.

IncludedTurnCount

Gets the number of user turns that have at least one non-excluded group.

RawMessageCount

Gets the total number of original messages (that are not summaries).

Tokenizer

Gets the tokenizer used for computing token counts, or null if token counts are estimated.

TotalByteCount

Gets the total UTF-8 byte count across all groups, including excluded ones.

TotalGroupCount

Gets the total number of groups, including excluded ones.

TotalMessageCount

Gets the total number of messages across all groups, including excluded ones.

TotalTokenCount

Gets the total token count across all groups, including excluded ones.

TotalTurnCount

Gets the total number of user turns across all groups (including those with excluded groups).

Methods

Name Description
AddGroup(CompactionGroupKind, IReadOnlyList<ChatMessage>, Nullable<Int32>)

Creates a new CompactionMessageGroup with byte and token counts computed using this collection's Tokenizer, and appends it to the end of the Groups list.

GetAllMessages()

Returns all messages from all groups, including excluded ones.

GetIncludedMessages()

Returns only the messages from groups that are not excluded.

GetTurnGroups(Int32)

Returns all groups that belong to the specified user turn.

InsertGroup(Int32, CompactionGroupKind, IReadOnlyList<ChatMessage>, Nullable<Int32>)

Creates a new CompactionMessageGroup with byte and token counts computed using this collection's Tokenizer, and adds it to the Groups list at the specified index.

Applies to