Skip to content

[dotnet-port-fixes] Align workflow message ordering with .NET#538

Open
michelle-clayton-work wants to merge 2 commits into
mainfrom
copilot/dotnet-port-fixes-message-ordering-20260716-af0566627077a9c6
Open

[dotnet-port-fixes] Align workflow message ordering with .NET#538
michelle-clayton-work wants to merge 2 commits into
mainfrom
copilot/dotnet-port-fixes-message-ordering-20260716-af0566627077a9c6

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Summary

Align workflow/agentworkflow response merging with the upstream .NET workflow-hosting fix from microsoft/agent-framework#7123 (05834b56e31f941e90e3337eb0f09d1a6ad8ee88).

The Go port keeps workflow-agent message ordering in first-seen order by:

  • preserving first-seen response/message grouping instead of re-sorting merged messages by timestamp,
  • keeping identifierless update segments in their original position instead of appending all dangling updates at the end,
  • preserving per-message CreatedAt values when stamping merged messages.

It also adds focused parity tests for the ordering cases that regressed upstream: contiguous response ordering, function call/result ordering, and identifierless segment handling.

Ported .NET PRs

Upstream commit: 05834b56e31f941e90e3337eb0f09d1a6ad8ee88

Breaking Changes

No.

Tests and Examples

  • Ran go test ./workflow/agentworkflow/...
  • Added workflow/agentworkflow/message_merger_test.go parity coverage for first-seen ordering, contiguous response grouping, function call/result ordering, and identifierless segments

Notes

  • This port is intentionally scoped to the shared Go message-merging behavior and does not add any public API.
  • The .NET PR also added handoff-orchestration coverage; Go does not have the corresponding handoff builder/executor surface yet, so this PR ports the shared ordering fix and its direct parity tests.

Generated by .NET to Go Fixes and Test Porting Agent · 724.7 AIC · ⌖ 43.2 AIC · ⊞ 21.7K ·

Closes #502

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the upstream .NET workflow-hosting fix to Go by adjusting workflow/agentworkflow response/message merge behavior so merged workflow messages preserve first-seen ordering (instead of being re-sorted by timestamps) and identifierless update segments stay in-place.

Changes:

  • Preserve first-seen response/message ordering by removing timestamp-based re-sorting and tracking message-state order explicitly during merge.
  • Keep identifierless (missing MessageID) segments in their original contiguous position rather than collecting them at the end.
  • Add parity-focused tests covering first-seen ordering, contiguous response grouping, function call/result ordering, and identifierless segment handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
workflow/agentworkflow/message_merger.go Reworks merge state tracking to preserve first-seen ordering and avoid overwriting per-message CreatedAt during stamping.
workflow/agentworkflow/message_merger_test.go Adds ordering/parity tests to lock in the intended merge ordering semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 180 to 184
func messagesWithCreatedAt(response *agent.Response) []*message.Message {
if response == nil {
return nil
}
messages := make([]*message.Message, 0, len(response.Messages))
@github-actions

This comment has been minimized.

@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

@copilot respond to PR comments

… stamping

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@copilot respond to PR comments

Fixed in the latest commit. Changed mergeResponseList to track the maximum CreatedAt across all merged responses (instead of last-wins), so messages with a zero CreatedAt are always stamped with the latest observed timestamp regardless of first-seen ordering. Also added TestMessageMerger_StampsZeroCreatedAtWithMaxTimestamp to lock in this behavior.

@github-actions

Copy link
Copy Markdown
Contributor

Cross-Repo API Consistency Review

Result: No parity issues — out of scope for cross-SDK consistency review.

This PR only modifies internal, unexported implementation details in workflow/agentworkflow/message_merger.go:

  • All affected types (messageMerger, responseMergeState, messageMergeState) are unexported
  • No exported functions, methods, types, fields, or option shapes are added or changed
  • The test file (message_merger_test.go) exercises the same internal package only

The PR is a direct port of the upstream .NET fix (microsoft/agent-framework#7123) and correctly preserves semantic alignment with the .NET ordering behavior (first-seen ordering, contiguous response grouping, identifierless segment handling). No Python or .NET public contract divergence is introduced.

Generated by Go API Consistency Review Agent for issue #538 · 31.8 AIC · ⌖ 11.7 AIC · ⊞ 28.4K ·

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port-fixes] Align workflow message ordering with .NET

3 participants