.NET: fix: Expose WorkflowErrorEvent as ErrorContent#2762
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where workflows hosted using .AsAgent() were not exposing inner errors coming from exceptions through the WorkflowErrorEvent. The fix converts error events to ErrorContent objects so they can be properly surfaced to consumers.
Key Changes:
- Added an
Exceptionproperty toWorkflowErrorEventfor direct access to the underlying exception - Modified
WorkflowThread.CreateUpdateto accept a raw representation parameter - Added handling for
WorkflowErrorEventin workflow execution to convert exceptions toErrorContent
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| WorkflowErrorEvent.cs | Adds public Exception property to expose the underlying exception data |
| WorkflowThread.cs | Updates CreateUpdate signature to include raw representation and adds error event handling to convert exceptions to ErrorContent |
| WorkflowHostSmokeTests.cs | Adds comprehensive smoke tests validating both direct error content streaming and exception-to-error-content conversion |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs
Show resolved
Hide resolved
alliscode
approved these changes
Dec 10, 2025
25ea844 to
e86f587
Compare
e86f587 to
fcd90d2
Compare
fcd90d2 to
a39ecc9
Compare
a39ecc9 to
0cee333
Compare
0cee333 to
7bb7356
Compare
7bb7356 to
4838b3a
Compare
This was referenced Feb 9, 2026
This was referenced Feb 16, 2026
This was referenced Feb 23, 2026
Open
This was referenced Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When hosted using
AsAgent(),Workflows were not exposing inner errors coming asExceptions (through raisedWorkflowErrorEvent)Description
The fix is to convert the
Messageproperty to anErrorContenton the way out, rather than rely on the default "empty update" to collect the raw event.Contribution Checklist
Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.