-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Workflows - Support fidelity when converting to and from ChatMessage in declarative workflows #3505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
.NET: Workflows - Support fidelity when converting to and from ChatMessage in declarative workflows #3505
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for preserving MediaType and MessageId properties when converting between ChatMessage objects and their record representations in declarative workflows. The changes enable better fidelity in round-trip conversions, though the implementation relies partially on inference rather than explicit persistence.
Changes:
- Added MessageId preservation when converting from records to ChatMessage
- Added MediaType parameter support and inference logic for content conversion
- Added comprehensive round-trip unit tests for ChatMessage conversions
- Updated integration tests to support two workflow variants (conversation and auto-send)
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ChatMessageExtensions.cs | Added System.IO import, MessageId extraction, MediaType parameter handling, and InferMediaType helper method |
| AddConversationMessageExecutor.cs | Updated ToContent call to pass MediaType from content model |
| ChatMessageExtensionsTests.cs | Added round-trip tests for ChatMessage as Record and Table, with custom equivalence assertions |
| MediaInputTest.cs | Refactored to test two workflow variants, updated test parameters and assertions |
| MediaInputConversation.yaml | New workflow using conversation-based message handling |
| MediaInputAutoSend.yaml | New workflow using autoSend for message handling |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/ChatMessageExtensions.cs
Show resolved
Hide resolved
…ssage in declarative workflows (#3505) * Builds locally and tests pass * Fix typo * Updated * Updated * Fixed tests failing on net472 but not on dotnet10 --------- Co-authored-by: Chris Rickman <[email protected]>
This is a rebase of PR #3021 to main. Initial description of the change is copied below and the credit for this change goes to Chris (The original PR author).
Motivation and Context
Ensures media-type and message id are persisted when converting between ChatMessage and the object model representation.
Fixes: #3020
Description
Contribution Checklist