Skip to content

[dotnet-code] Align compaction equality helpers #1080

Description

@github-actions

Tip

Your pull request is ready to create! 🎉 ✅

Everything is OK—the changes have been pushed to branch dotnet-code-compaction-equality-20260915223009-f396d162ede52596. Please review the changes, including any protected files, before creating the pull request.

Create the pull request

The original pull request description is below.


Summary

Extracts unexported per-content comparison helpers from agent/compaction/equality.go. This keeps the existing compaction equality behavior while making the Go implementation structurally closer to .NET's ChatMessageContentEquality helper layout for future ports.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI/Compaction/ChatMessageContentEquality.cs - defines per-content comparison helpers used by compaction message matching.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • go test ./agent/compaction

Notes

Rejected candidates:

  • dotnet/src/Microsoft.Agents.AI.Abstractions/AgentResponse.cs / AgentResponseUpdate.cs - comparable Go response assembly already had aligned behavior; changing update metadata handling would risk observable behavior changes.
  • dotnet/src/Microsoft.Agents.AI.Workflows/MessageMerger.cs - comparable Go workflow merging internals were close, but usage/raw representation parity questions were behavior-affecting rather than safe cleanup.
  • dotnet/src/Microsoft.Agents.AI/Skills/* - inspected as a sampled area from the upstream directory listing, but no safer small cleanup was found before the compaction equality candidate.

The direct upstream git fetch was blocked by the environment, so the .NET reference was inspected through the read-only GitHub bridge after checking local refs.


Note

GitHub Actions is not permitted to create or approve pull requests in this repository.

The changes have been pushed to branch dotnet-code-compaction-equality-20260915223009-f396d162ede52596 and are ready to review.

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (37 of 104 lines)
From 295c1d94b107196c0eb85b6aecd0d674a7fd8147 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 4b46045b01079041f0b8f5121b4cf66a79be8bd3
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Tue, 15 Sep 2026 22:30:09 +0000
Subject: [PATCH] [dotnet-code] Align compaction equality helpers

Extract unexported content comparison helpers in compaction equality so the Go structure more closely mirrors the .NET ChatMessageContentEquality internals without changing behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/compaction/equality.go | 62 +++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 19 deletions(-)

diff --git a/agent/compaction/equality.go b/agent/compaction/equality.go
index fc0e0fb..2005f4e 100644
--- a/agent/compaction/equality.go
+++ b/agent/compaction/equality.go
@@ -46,32 +46,21 @@ func contentEqual(left, right message.Content) bool {
 	}
 	switch leftContent := left.(type) {
 	case *message.TextContent:
-		rightContent := right.(*message.TextContent)
-		return leftContent.Text == rightContent.Text
+		return textContentEqual(leftContent, right.(*message.TextContent))
 	case *message.TextReasoningContent:
-		rightContent := right.(*message.TextReasoningContent)
-		return leftContent.Text == rightContent.Text && leftContent.ProtectedData == rightContent.ProtectedData
+		return textReasoningContentEqual(leftContent, right.(*message.TextReasoningContent))
 	case *message.DataContent:
-		rightContent := right.(*message.DataContent)
-		return leftContent.MediaType == rightContent.MediaType && leftContent.Name == rightContent.Name && leftContent.Data == rightContent.Data
+		return dataContentEqual(leftContent, right.(*message.DataContent))
 	case *message.URIContent:
-		rightContent := right.(*message.URIContent)
-		return leftContent.URI == rightContent.URI && leftContent.MediaType == rightContent.MediaType
+		return uriContentEqual(leftContent, right.(*message.URIContent))
 	case
... (truncated)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by .NET-to-Go Code Portability Refactoring Agent · copilot · gpt55 · 113.9 AIC · ⌖ 13.8 AIC · ⊞ 17.8K ·

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions