[dotnet-code] Consolidate compaction group predicates - #829
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the Go compaction MessageIndex aggregation logic by consolidating repeated compaction-group predicates into unexported MessageGroup helper methods, aligning the predicate “shape” more closely with the referenced .NET implementation while preserving existing behavior and avoiding public API changes.
Changes:
- Added
MessageGroup.isIncluded()andMessageGroup.isRaw()helper predicates. - Updated
MessageIndexaggregation methods to use these helpers instead of repeating inline conditions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| agent/compaction/group.go | Introduces unexported predicate helpers (isIncluded, isRaw) and refactors isIncludedNonSystem to reuse them. |
| agent/compaction/index.go | Replaces repeated inline predicates with the new MessageGroup helper methods across included/raw aggregation paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Parity Review: ✅ No IssuesThis PR consolidates repeated compaction group predicates into unexported helper methods ( Scope assessment: Internal refactor only. Changed files:
Cross-repo parity: The refactor is explicitly modeled after the .NET Label actions:
|
Summary
Consolidated repeated compaction group predicates into unexported
MessageGrouphelpers. This keeps the GoMessageIndexaggregation paths closer to the .NETCompactionMessageIndexpredicate shape while preserving existing behavior and avoiding public API changes..NET Reference
dotnet/src/Microsoft.Agents.AI/Compaction/CompactionMessageGroup.cs- group state such asIsExcludedand summary classification metadata.dotnet/src/Microsoft.Agents.AI/Compaction/CompactionMessageIndex.cs- index aggregation predicates over included and raw/non-summary groups.Public API and Behavior
No public Go API changed. No intentional behavior change was made.
Tests
go test ./agent/compactionNotes
Rejected candidates from the random .NET sample:
dotnet/src/Microsoft.Agents.AI.Workflows/ProtocolBuilder.csmaps to public Go protocol builder behavior, so cleanup risked API-facing churn.dotnet/src/Microsoft.Agents.AI.Workflows/Checkpointing/EdgeInfo.csmaps to public Go checkpoint edge metadata with different serialization constraints, so no safe tiny internal-only change was obvious.dotnet/src/Microsoft.Agents.AI.Workflows/RequestInfoEvent.csalready has a minimal direct Go counterpart, so there was no meaningful structural cleanup to make.Closes #821