CompactionMessageGroup Class

Definition

Represents a logical group of ChatMessage instances that must be kept or removed together during compaction.

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

Remarks

Message groups ensure atomic preservation of related messages. For example, an assistant message containing tool calls and its corresponding tool result messages form a ToolCall group — removing one without the other would cause LLM API errors.

Groups also support exclusion semantics: a group can be marked as excluded (with an optional reason) to indicate it should not be included in the messages sent to the model, while still being preserved for diagnostics, storage, or later re-inclusion.

Each group tracks its MessageCount, ByteCount, and TokenCount so that CompactionMessageIndex can efficiently aggregate totals across all or only included groups.

Fields

Name Description
SummaryPropertyKey

The AdditionalProperties key used to identify a message as a compaction summary.

Properties

Name Description
ByteCount

Gets the total UTF-8 byte count of the text content in this group's messages.

ExcludeReason

Gets or sets an optional reason explaining why this group was excluded.

IsExcluded

Gets or sets a value indicating whether this group is excluded from the projected message list.

Kind

Gets the kind of this message group.

MessageCount

Gets the number of messages in this group.

Messages

Gets the messages in this group.

TokenCount

Gets the estimated or actual token count for this group's messages.

TurnIndex

Gets user turn index this group belongs to, or null for groups that precede the first user message (e.g., system messages). A turn index of 0 corresponds with any non-system message that precedes the first user message, turn index 1 corresponds with the first user message and its subsequent non-user messages, and so on...

Applies to