Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion agent/compaction/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ func newMessageGroup(kind GroupKind, messages []*message.Message, byteCount, tok
}
}

func (group *MessageGroup) isIncluded() bool {
return !group.IsExcluded
}

func (group *MessageGroup) isIncludedNonSystem() bool {
return !group.IsExcluded && group.Kind != GroupKindSystem
return group.isIncluded() && group.Kind != GroupKindSystem
}

func (group *MessageGroup) isRaw() bool {
return group.Kind != GroupKindSummary
}

func cloneTurnIndex(turnIndex *int) *int {
Expand Down
16 changes: 8 additions & 8 deletions agent/compaction/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (index *MessageIndex) AddGroup(kind GroupKind, messages []*message.Message,
func (index *MessageIndex) IncludedMessages() []*message.Message {
var messages []*message.Message
for _, group := range index.Groups {
if !group.IsExcluded {
if group.isIncluded() {
messages = append(messages, group.Messages...)
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func (index *MessageIndex) TotalTokenCount() int {
func (index *MessageIndex) IncludedGroupCount() int {
var total int
for _, group := range index.Groups {
if !group.IsExcluded {
if group.isIncluded() {
total++
}
}
Expand All @@ -243,7 +243,7 @@ func (index *MessageIndex) IncludedGroupCount() int {
func (index *MessageIndex) IncludedMessageCount() int {
var total int
for _, group := range index.Groups {
if !group.IsExcluded {
if group.isIncluded() {
total += group.MessageCount
}
}
Expand All @@ -254,7 +254,7 @@ func (index *MessageIndex) IncludedMessageCount() int {
func (index *MessageIndex) IncludedByteCount() int {
var total int
for _, group := range index.Groups {
if !group.IsExcluded {
if group.isIncluded() {
total += group.ByteCount
}
}
Expand All @@ -265,7 +265,7 @@ func (index *MessageIndex) IncludedByteCount() int {
func (index *MessageIndex) IncludedTokenCount() int {
var total int
for _, group := range index.Groups {
if !group.IsExcluded {
if group.isIncluded() {
total += group.TokenCount
}
}
Expand All @@ -287,7 +287,7 @@ func (index *MessageIndex) TotalTurnCount() int {
func (index *MessageIndex) IncludedTurnCount() int {
seen := make(map[int]bool)
for _, group := range index.Groups {
if !group.IsExcluded && group.TurnIndex != nil && *group.TurnIndex > 0 {
if group.isIncluded() && group.TurnIndex != nil && *group.TurnIndex > 0 {
seen[*group.TurnIndex] = true
}
}
Expand Down Expand Up @@ -321,7 +321,7 @@ func (index *MessageIndex) includedNonSystemGroupIndices() []int {
func (index *MessageIndex) RawMessageCount() int {
var total int
for _, group := range index.Groups {
if group.Kind != GroupKindSummary {
if group.isRaw() {
total += group.MessageCount
}
}
Expand All @@ -331,7 +331,7 @@ func (index *MessageIndex) RawMessageCount() int {
func (index *MessageIndex) includedRawMessageCount() int {
var total int
for _, group := range index.Groups {
if !group.IsExcluded && group.Kind != GroupKindSummary {
if group.isIncluded() && group.isRaw() {
total += group.MessageCount
}
}
Expand Down