Skip to content

.NET: Include workflow outputs in hosted agent responses - #8020

Open
宇宙的山峰 (UniversePeak) wants to merge 1 commit into
microsoft:mainfrom
UniversePeak:issue-8013-workflow-output
Open

.NET: Include workflow outputs in hosted agent responses#8020
宇宙的山峰 (UniversePeak) wants to merge 1 commit into
microsoft:mainfrom
UniversePeak:issue-8013-workflow-output

Conversation

@UniversePeak

Copy link
Copy Markdown

Motivation & Context

When a workflow is registered with IHostedWorkflowBuilder.AddAsAIAgent() and exposed through the OpenAI Responses or Conversations endpoints, workflow outputs represented as chat messages were not included in the completed agent response. The stream could show the workflow event while the completed response contained no output items, making the hosting sample unclear and requiring users to discover the lower-level Workflow.AsAIAgent option.

Description & Review Guide

  • What are the major changes?
    • Configure hosted workflows registered with AddAsAIAgent() to include workflow outputs in the hosted AIAgent response.
    • Add a regression test that runs a chat-protocol workflow yielding a ChatMessage workflow output and verifies the hosted agent response contains it.
    • Document the behavior in the DevUI hosting sample, including the equivalent option for workflows hosted directly with Workflow.AsAIAgent.
  • What is the impact of these changes?
    • Hosted workflow agents now return their workflow output in non-streaming responses, while direct Workflow.AsAIAgent behavior remains unchanged.
    • Existing hosted workflow registrations keep the same API and DI lifetime behavior.
  • What do you want reviewers to focus on?
    • Whether hosted workflow registration should always include workflow outputs, and whether the sample explanation clearly distinguishes hosted-builder registration from direct workflow hosting.

Related Issue

Fixes #8013

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Validation: dotnet test tests/Microsoft.Agents.AI.Hosting.UnitTests/Microsoft.Agents.AI.Hosting.UnitTests.csproj --no-restore -f net10.0 (200 passed); dotnet format agent-framework-dotnet.slnx whitespace --no-restore --verify-no-changes passed; git diff --check passed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation, regression test, and documentation consistently address the reported missing output.

Pull request overview

Enables hosted .NET workflows to return chat-message workflow outputs in completed agent responses.

Changes:

  • Enables workflow-output inclusion for AddAsAIAgent().
  • Adds regression coverage for chat-message output.
  • Documents hosted and direct workflow behavior.
File summaries
File Description
HostedWorkflowBuilderExtensions.cs Enables workflow outputs in hosted responses.
HostApplicationBuilderWorkflowExtensionsTests.cs Tests completed response output.
ChatMessageOutputWorkflow.cs Provides the regression-test workflow.
README.md Documents output behavior and direct opt-in.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@UniversePeak

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [.NET] Unclear how to return Workflow Output as Agent Response

2 participants