Uh oh!
There was an error while loading. Please reload this page.
.NET: Map workflow lifecycle to AG-UI - #7738
.NET: Map workflow lifecycle to AG-UI#7738Javier Calvarro Nelson (javiercn) wants to merge 17 commits into
Conversation
Map workflow supersteps and safe lifecycle metadata through an opt-in AG-UI agent decorator while preserving existing response, interrupt, tool, and error conversion behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Map only executor invoked, completed, and failed workflow events in the AG-UI response stream. Preserve the existing conversion for every other update. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Keep the standard AgentResponseUpdate to ChatResponseUpdate conversion and apply the minimal executor lifecycle mapping as a dedicated AG-UI stream transformation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
There was a problem hiding this comment.
Pull request overview
Adds native AG-UI step lifecycle events for .NET workflow executors.
Changes:
- Maps executor invocation, completion, and failure to AG-UI step events.
- Preserves failure error updates after closing the step.
- Adds workflow dependencies and unit coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
WorkflowAGUIExtensionsTests.cs | Tests lifecycle mapping and failure ordering. |
Unit test .csproj | References the workflow project. |
WorkflowAGUIExtensions.cs | Implements workflow-to-AG-UI mapping. |
Hosting .csproj | Adds the workflow dependency. |
AGUIEndpointRouteBuilderExtensions.cs | Integrates mapping into the endpoint pipeline. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| internal static async IAsyncEnumerable<ChatResponseUpdate> MapWorkflowEventsToAGUI( | ||
| this IAsyncEnumerable<ChatResponseUpdate> updates) |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (3 commit(s)): febdce30c765, 5ade34cbc74f, a04cec0ec4ba
Model:gpt-5.6-sol
Overview
The PR adds a focused post-conversion stream transform and preserves the existing error update after closing a failed executor step. Its unit tests cover the basic invoked, completed, failed, and pass-through cases. However, using an executor ID as the sole AG-UI step correlation key makes concurrent nested workflows with repeated child IDs emit ambiguous lifecycle pairs.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas:dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/WorkflowAGUIExtensions.cs
| switch (update.RawRepresentation) | ||
| { | ||
| case AgentResponseUpdate { RawRepresentation: ExecutorInvokedEvent invoked }: | ||
| update.RawRepresentation = new StepStartedEvent { StepName = invoked.ExecutorId }; |
There was a problem hiding this comment.
When concurrent nested workflows reuse a child executor ID, their forwarded events can produce overlapping steps with the same StepName, so clients cannot tell which invocation a StepFinishedEvent closes. Please qualify nested executor identities or propagate a per-invocation correlation value so every started step can be paired with its own terminal event.
Demonstrate ordered executor step events through an AG-UI client/server sample and verify the sample workflow over HTTP/SSE. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Demonstrate independent executor step lifecycles for concurrently running agents and verify the sample workflow over HTTP/SSE. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Demonstrate balanced AG-UI step lifecycle events when a workflow executor fails and verify the sample over HTTP/SSE. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Demonstrate executor steps alongside backend tool calls, results, and text, with HTTP/SSE integration coverage preventing duplicate content. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Characterize duplicate local executor IDs from parallel subworkflows and the resulting active-step collision tracked by issue #7763. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Map workflow input requests to AG-UI interruptions, preserve resumable workflow sessions, and demonstrate approval pause and resume over HTTP/SSE. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Demonstrate three same-turn interruptions, partial out-of-order responses, persisted workflow state, and final completion after the remaining input arrives. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Synchronize the duplicate Analyze executors so the integration test reliably characterizes overlapping nested step IDs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Close active AG-UI message, reasoning, tool, and step streams before emitting terminal RUN_ERROR, and suppress the SDK's synthetic success outcome. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Show each server constructing a Workflow before adapting it with AsAIAgent, use Producer and Reviewer in the sequential scenario, and distinguish remote client agents and sessions by name. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
This reverts commit 3f824b1.
Call AGUIChatClient through the IChatClient abstraction directly and remove the unnecessary AIAgent and AgentSession client adapters. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Build the approval workflow around one expense-review agent with an explicit checklist and approval-required submission tool. Handle the native approval request/response pair through IChatClient, deduplicate the workflow-correlated request, and map generic interrupt responses unconditionally to function results. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
Motivation & Context
Workflow agents expose executor lifecycle and external-input events through nested
RawRepresentationvalues, but the AG-UI host did not translate those events into native AG-UI steps and interruptions. Consequently, workflow text and tool content could stream while clients lacked executor progress, resumable external-input handling, and correct terminal failure semantics.This change adds native workflow mapping to the existing AG-UI hosting pipeline and provides runnable samples plus HTTP/SSE integration coverage for the supported scenarios.
Description & Review Guide
AsChatResponseUpdatesAsync()conversion, then applies an internal workflow transformation. Executor invocation/completion/failure becomes AG-UI step lifecycle; failed runs close active protocol streams and terminate with redactedRUN_ERROR; workflow request ports become AG-UI input interruptions whose responses resume persisted workflow sessions. Seven standalone client/server samples cover sequential, concurrent, failing, tool-enabled, nested, approval, and multiple-input workflows. Matching integration tests execute each sample topology through ASP.NET Core TestServer and the AG-UI HTTP/SSE protocol.MapAGUIServernow expose native executor steps and workflow interruptions without an opt-in decorator. Existing text and tool conversion remains in the standard AG-UI pipeline. The nested-workflow sample characterizes the duplicate local executor-ID limitation tracked by .NET: Preserve nested executor identity in workflow lifecycle events #7763. The current terminal-error adapter compensates for AG-UI .NET 0.0.3 behavior and can be simplified after upstream AG-UI PR .NET: Updated package versions #2455 is released and consumed.Related Issue
Fixes#2494
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.