.NET: [Feature Branch] Add nested sub-workflow support for durable workflows#4190
Open
kshyju wants to merge 2 commits intofeat/durable_taskfrom
Open
.NET: [Feature Branch] Add nested sub-workflow support for durable workflows#4190kshyju wants to merge 2 commits intofeat/durable_taskfrom
kshyju wants to merge 2 commits intofeat/durable_taskfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for nested sub-workflows in the Durable Task workflow system, enabling workflows to act as executors within other workflows with multi-level nesting capabilities (sub-workflow within sub-workflow). The implementation extends the existing durable workflow infrastructure to support hierarchical workflow execution via Durable Task sub-orchestrations, providing independent checkpointing, replay protection, and dashboard visualization for each sub-workflow instance.
Changes:
- Extended
DurableWorkflowResultwith aSentMessagesproperty to enable message routing from sub-workflows to parent workflow executors - Enhanced
DurableExecutorDispatcherto detect and dispatch sub-workflow executors viaCallSubOrchestratorAsyncwith automatic result format conversion - Modified
DurableWorkflowRunnerto include the final workflow result as a sent message for proper routing in parent workflows - Added comprehensive sample (07_SubWorkflows) demonstrating 2-level workflow nesting, event propagation, and shared state within sub-workflows
- Added integration test validating all executor execution across three nesting levels and event propagation
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowResult.cs |
Added SentMessages property to carry typed messages from sub-workflows to parent workflows |
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableExecutorDispatcher.cs |
Added ExecuteSubWorkflowAsync method to dispatch sub-workflows as sub-orchestrations and convert results to executor output format |
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowRunner.cs |
Modified to include final result as a sent message and added null-conditional operators for defensive deserialization |
dotnet/tests/Microsoft.Agents.AI.DurableTask.IntegrationTests/WorkflowConsoleAppSamplesValidation.cs |
Added SubWorkflowsSampleValidationAsync test validating all executors across three nesting levels |
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/Program.cs |
Sample entry point demonstrating 2-level nested sub-workflow configuration and execution |
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/Executors.cs |
Executor implementations showcasing sub-workflow features including event propagation and shared state |
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/README.md |
Comprehensive documentation explaining sub-workflow concepts and sample structure |
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/07_SubWorkflows.csproj |
Project configuration for the sub-workflows sample |
dotnet/agent-framework-dotnet.slnx |
Added sample project to solution file |
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/07_SubWorkflows.csproj
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowResult.cs
Show resolved
Hide resolved
46e4c52 to
faa4563
Compare
dotnet/samples/Durable/Workflow/ConsoleApps/07_SubWorkflows/README.md
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowRunner.cs
Show resolved
Hide resolved
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.
Summary
Adds support for nested sub-workflows in the Durable Task workflow system. Sub-workflows can now act as executors within other workflows, including multi-level nesting (sub-workflow within sub-workflow).
Changes
Library (
Microsoft.Agents.AI.DurableTask)DurableExecutorDispatcher— Added sub-workflow dispatch viaCallSubOrchestratorAsync, with conversion ofDurableWorkflowResulttoDurableExecutorOutputfor seamless integration with the parent workflow's result processing.DurableWorkflowResult— AddedSentMessagesproperty (List<TypedPayload>) so sub-workflow results carry typed messages that get routed to connected executors in the parent workflow.DurableWorkflowRunner— The final workflow result is now included as aSentMessageso parent workflows can route it to connected executors via the edge map.Public API Changes
None.
Sample (
07_SubWorkflows)New console app sample demonstrating:
Workflow.BindAsExecutor()to embed a workflow as an executorFraudRiskAssessedEventbubbles up from nested sub-workflowsSelectCarrierusesExecutor<TInput>(void return) withSendMessageAsyncto forward typed messages to connected executorsAnalyzePatterns→CalculateRiskScorecommunicate viaQueueStateUpdateAsync/ReadStateAsyncTests
SubWorkflowsSampleValidationAsyncintegration test toWorkflowConsoleAppSamplesValidation— validates all executor log entries across all three nesting levels, verifies event propagation, and confirms end-to-end workflow completion.Contribution Checklist