.NET: Forward agent response details in workflows - #7975
.NET: Forward agent response details in workflows#7975Vincent Biret (baywet) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds opt-in forwarding of complete .NET agent responses to downstream workflow executors while preserving default chat-message behavior.
Changes:
- Adds
AIAgentHostResponseandForwardAgentResponse. - Sends response metadata with sanitized conversation messages.
- Adds unit and public API coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
AIAgentHostExecutorTests.cs |
Tests enabled and default forwarding behavior. |
AIAgentHostExecutor.cs |
Sends the optional response envelope. |
AIAgentHostOptions.cs |
Defines the option and envelope API. |
PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt |
Records the new API. |
PublicAPI/net8.0/PublicAPI.Unshipped.txt |
Records the new API. |
PublicAPI/net9.0/PublicAPI.Unshipped.txt |
Records the new API. |
PublicAPI/net10.0/PublicAPI.Unshipped.txt |
Records the new API. |
PublicAPI/net472/PublicAPI.Unshipped.txt |
Records the new API. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 2cabd71f53fc
Model: gpt-5.6-sol
Overview
The PR adds an opt-in envelope for complete agent responses while preserving the default chat-only behavior and filtering provider-specific artifacts from portable messages. Runtime type declarations, edge filtering, null guards, and tests constrain the new path. However, the framework does not register the new queued message with its default checkpoint serializer, so checkpointed workflows using the feature fail before downstream handling.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 high) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIAgentHostExecutor.cs
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall line coverage in commit e005213 in the Show a line coverage summary of the most covered files.
Updated |
Add an opt-in AIAgentHostResponse workflow message that carries the complete AgentResponse, portable full conversation, and sanitized forwarded messages from AIAgentHostExecutor. This lets downstream custom executors inspect response metadata such as finish reason and usage without changing the default chat-message forwarding behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 41390b8c-4c07-493a-bb2d-d1a087bd94bc
Add AIAgentHostResponse to the workflows source-generated JSON context so PortableValue checkpoint serialization can resolve the framework-owned message envelope without reflection serialization. Cover the checkpoint-style PortableMessageEnvelope round trip for the new response envelope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 41390b8c-4c07-493a-bb2d-d1a087bd94bc
b38cd44 to
5779b70
Compare
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Motivation & Context
.NET workflow agent hosts currently forward only sanitized
ChatMessageinstances to downstream executors. Custom executors that need response-level details, such as detectingChatFinishReason.Lengthafter a lowMaxOutputTokensrun, must observe workflow events externally and manually bridge that state back into the workflow.This adds an opt-in workflow message that carries the complete
AgentResponseto downstream executors while keeping the existing chat-message forwarding path unchanged by default.Description & Review Guide
AIAgentHostResponse, a public workflow message envelope containing the producing executor ID, completeAgentResponse, portable full conversation, and sanitized forwarded response messages.AIAgentHostOptions.ForwardAgentResponseto opt into forwarding that envelope fromAIAgentHostExecutor.AIAgentHostExecutorprotocol metadata and adds unit coverage for forwarding response metadata and preserving default behavior.Related Issue
Fixes #2148
No other open PR was found for this issue.
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.