From 4adeb4ba20e21eed64940b1a76349278eda09741 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 03:45:15 +0000 Subject: [PATCH 1/2] [dotnet-port-fixes] Align compaction summary marker handling Support raw JSON _is_summary values in compaction message grouping and add parity tests for bool and raw-token cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- agent/compaction/compaction_test.go | 36 +++++++++++++++++++++++++++++ agent/compaction/index.go | 23 +++++++++++++++--- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/agent/compaction/compaction_test.go b/agent/compaction/compaction_test.go index c9862854..b5cd613b 100644 --- a/agent/compaction/compaction_test.go +++ b/agent/compaction/compaction_test.go @@ -67,6 +67,42 @@ func TestMessageIndex_GroupsToolCallsAtomically(t *testing.T) { } } +func TestMessageIndex_SummaryPropertyKeyIsRespected(t *testing.T) { + tests := []struct { + name string + value any + expected compaction.GroupKind + }{ + {name: "missing", expected: compaction.GroupKindAssistantText}, + {name: "bool false", value: false, expected: compaction.GroupKindAssistantText}, + {name: "raw false", value: json.RawMessage(`false`), expected: compaction.GroupKindAssistantText}, + {name: "raw null", value: json.RawMessage(`null`), expected: compaction.GroupKindAssistantText}, + {name: "raw string", value: json.RawMessage(`"Unexpected string"`), expected: compaction.GroupKindAssistantText}, + {name: "bool true", value: true, expected: compaction.GroupKindSummary}, + {name: "raw true", value: json.RawMessage(`true`), expected: compaction.GroupKindSummary}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + msg := textMessage(message.RoleAssistant, "Hello") + if tt.name != "missing" { + msg.AdditionalProperties = map[string]any{ + "_is_summary": tt.value, + } + } + + index := compaction.CreateMessageIndex([]*message.Message{msg}, nil) + + if len(index.Groups) != 1 { + t.Fatalf("expected one group, got %d", len(index.Groups)) + } + if got := index.Groups[0].Kind; got != tt.expected { + t.Fatalf("group kind = %v, want %v", got, tt.expected) + } + }) + } +} + func TestTruncationStrategy_ExcludesOldestGroups(t *testing.T) { index := compaction.CreateMessageIndex(turnMessages(3), nil) strategy := &compaction.TruncationStrategy{ diff --git a/agent/compaction/index.go b/agent/compaction/index.go index 2ef46162..447486a6 100644 --- a/agent/compaction/index.go +++ b/agent/compaction/index.go @@ -3,6 +3,7 @@ package compaction import ( + "encoding/json" "fmt" "slices" @@ -421,8 +422,24 @@ func isSummaryMessage(msg *message.Message) bool { if !ok { return false } - if boolValue, ok := value.(bool); ok { - return boolValue + switch typed := value.(type) { + case bool: + return typed + case json.RawMessage: + return rawSummaryMessageValue(typed) + case *json.RawMessage: + return typed != nil && rawSummaryMessageValue(*typed) + case []byte: + return rawSummaryMessageValue(typed) + default: + return false + } +} + +func rawSummaryMessageValue(value []byte) bool { + var boolValue bool + if err := json.Unmarshal(value, &boolValue); err != nil { + return false } - return false + return boolValue } From fd1cd28caa1fa1762b5b351a647ac14b648fb485 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 17 Jul 2026 21:21:39 +0000 Subject: [PATCH 2/2] test: add *json.RawMessage and []byte cases; rename test to SummaryPropertyValueParsing Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com> --- agent/compaction/compaction_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/compaction/compaction_test.go b/agent/compaction/compaction_test.go index b5cd613b..c1e4ee75 100644 --- a/agent/compaction/compaction_test.go +++ b/agent/compaction/compaction_test.go @@ -67,7 +67,9 @@ func TestMessageIndex_GroupsToolCallsAtomically(t *testing.T) { } } -func TestMessageIndex_SummaryPropertyKeyIsRespected(t *testing.T) { +func TestMessageIndex_SummaryPropertyValueParsing(t *testing.T) { + rawFalse := json.RawMessage(`false`) + rawTrue := json.RawMessage(`true`) tests := []struct { name string value any @@ -80,6 +82,12 @@ func TestMessageIndex_SummaryPropertyKeyIsRespected(t *testing.T) { {name: "raw string", value: json.RawMessage(`"Unexpected string"`), expected: compaction.GroupKindAssistantText}, {name: "bool true", value: true, expected: compaction.GroupKindSummary}, {name: "raw true", value: json.RawMessage(`true`), expected: compaction.GroupKindSummary}, + {name: "ptr raw nil", value: (*json.RawMessage)(nil), expected: compaction.GroupKindAssistantText}, + {name: "ptr raw false", value: &rawFalse, expected: compaction.GroupKindAssistantText}, + {name: "ptr raw true", value: &rawTrue, expected: compaction.GroupKindSummary}, + {name: "bytes false", value: []byte(`false`), expected: compaction.GroupKindAssistantText}, + {name: "bytes null", value: []byte(`null`), expected: compaction.GroupKindAssistantText}, + {name: "bytes true", value: []byte(`true`), expected: compaction.GroupKindSummary}, } for _, tt := range tests {