.NET: Fail declarative workflows when an agent returns an error - #7497
Open
peibekwe wants to merge 2 commits into
Open
.NET: Fail declarative workflows when an agent returns an error#7497peibekwe wants to merge 2 commits into
peibekwe wants to merge 2 commits into
Conversation
peibekwe
temporarily deployed
to
github-app-auth
August 3, 2026 22:41 — with
GitHub Actions
Inactive
peibekwe
temporarily deployed
to
github-app-auth
August 3, 2026 22:41 — with
GitHub Actions
Inactive
peibekwe
temporarily deployed
to
github-app-auth
August 3, 2026 22:41 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a workflow correctness bug where inner agent failures could be interpreted as successful (but empty) responses, causing declarative workflows to continue executing and finish as “completed” without signaling an error.
Changes:
- Add failure detection in the Foundry
AzureAgentProviderto translateresponse.failed(previously mapped to contentless updates) intoErrorContent. - Update declarative workflow invocation to treat
ErrorContentas a failing outcome (throwing before the response is marked complete or persisted), and avoid streaming raw error updates that would bypass the host’s exception-detail policy. - Add targeted unit tests and workflow fixtures covering failed runs, refusals, autoSend on/off, and streaming/non-streaming hosting behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/AzureAgentProvider.cs | Detect response.failed via raw update shape and emit ErrorContent instead of a contentless “success-looking” update. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/AgentProviderExtensions.cs | Fail the action when an aggregated response contains ErrorContent, and suppress streaming error updates to preserve exception-detail redaction behavior. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/InvokeAgentFailureTest.cs | End-to-end workflow tests proving failures stop downstream actions and hosted agent callers see appropriate error surfacing/redaction. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/AzureAgentProviderFailureTest.cs | Provider-level tests ensuring failed runs become ErrorContent and raw failure representations aren’t forwarded. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/AgentUpdateTestHelpers.cs | Test helper for building failed-run update shapes and exercising the failure-detection transform. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Workflows/AgentFailureFollowup.yaml | Declarative workflow fixture with a downstream action to verify failure prevents follow-up execution. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Workflows/AgentFailureNoAutoSend.yaml | Declarative workflow fixture verifying behavior when autoSend: false. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests.csproj | Adds Foundry project reference needed by the new provider-focused tests. |
peibekwe
marked this pull request as ready for review
August 4, 2026 01:10
peibekwe
temporarily deployed
to
github-app-auth
August 4, 2026 01:10 — with
GitHub Actions
Inactive
westey-m
approved these changes
Aug 4, 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 & Context
When an agent inside a declarative workflow returned a failed response, the workflow treated it as success. It moved on to the next action and finished with a "completed" status and an empty message, so callers got a blank but apparently successful reply
with no indication anything went wrong. This is the source of intermittent "empty response" reports.
There are two reasons this happened:
Description & Review Guide
AzureAgentProvidernow recognises a failed run and converts it into error content, replacing the original update so the provider's raw error text never reaches callers.AgentProviderExtensionsnow stops the action when a response carries an error, before the response is reported as complete or copied into the conversation. The error detail travels on the thrown exception, so hosts that have not opted into exception detail still get a redacted message.autoSendon and off, and streaming and non-streaming callers.Fixes #7496
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.