Skip to content

.NET: Add durable workflow support#4436

Open
kshyju wants to merge 17 commits intomainfrom
feat/durable_task
Open

.NET: Add durable workflow support#4436
kshyju wants to merge 17 commits intomainfrom
feat/durable_task

Conversation

@kshyju
Copy link
Contributor

@kshyju kshyju commented Mar 3, 2026

Motivation and Context

The Agent Framework needs support for long-running, reliable agent orchestrations that can survive process restarts, scale across machines, and handle complex multi-step workflows. This PR brings durable workflow support backed by the Durable Task framework, enabling scenarios like multi-agent pipelines, fan-out/fan-in patterns, and human-in-the-loop approvals.

Description

This PR merges the feat/durable_task feature branch, adding comprehensive durable workflow support across two packages. The feature was developed across 5 PRs into the feature branch:

  • Basic durable workflow support (#3648) — Core workflow engine including IWorkflowClient, IWorkflowRun, DurableWorkflowRunner, DurableWorkflowContext, edge routers (direct and fan-out), activity executors, workflow analyzer, and streaming
    support via IStreamingWorkflowRun.

  • Azure Functions hosting (#3935) — Hosting layer for running durable workflows in Azure Functions, including WorkflowOrchestrator, DurableWorkflowsFunctionMetadataTransformer, and DI extensions.

  • Events & shared state (#4020) — Support for publishing and subscribing to workflow events, and sharing state across workflow executors.

  • Nested sub-workflows (#4190) — Ability to compose workflows by nesting sub-workflows within a parent workflow.

  • Human-in-the-loop (HITL) (#4358) — Support for pausing workflow execution to wait for human input, including DurableWorkflowWaitingForInputEvent, PendingRequestPortStatus, and DurableHaltRequestedEvent.

Packages changed:

Package Files changed Diff
Microsoft.Agents.AI.DurableTask 49 +4,488 / −318
Microsoft.Agents.AI.Hosting.AzureFunctions 12 +778 / −51

Key new types:

  • IWorkflowClient / DurableWorkflowClient — Client for starting and managing workflow runs
  • IWorkflowRun / IStreamingWorkflowRun — Handles for monitoring workflow execution
  • DurableWorkflowRunner — Core orchestration runner
  • DurableWorkflowContext — Execution context available to workflow steps
  • DurableExecutorDispatcher — Routes execution to registered executors
  • IDurableEdgeRouter — Abstraction for routing between workflow nodes (direct, fan-out)
  • WorkflowAnalyzer / WorkflowGraphInfo — Static analysis of workflow graphs
  • WorkflowOrchestrator — Azure Functions orchestrator for durable workflows

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

kshyju and others added 5 commits February 6, 2026 16:02
* Add basic durable workflow support.

* PR feedback fixes

* Add conditional edge sample.

* PR feedback fixes.

* Minor cleanup.

* Minor cleanup

* Minor formatting improvements.

* Improve comments/documentation on the execution flow.
…e workflows (#3935)

* Adding azure functions workflow support.

* - PR feedback fixes.
- Add example to demonstrate complex Object as payload.

* rename instanceId to runId.

* Use custom ITaskOrchestrator to run orchestrator function.
…rable workflows (#4020)

* Adding support for events & shared state in durable workflows.

* PR feedback fixes

* PR feedback fixes.

* Add YieldOutputAsync calls to 05_WorkflowEvents sample executors

The integration test asserts that WorkflowOutputEvent is found in the
stream, but the sample executors only used AddEventAsync for custom
events and never called YieldOutputAsync. Since WorkflowOutputEvent is
only emitted via explicit YieldOutputAsync calls, the assertion would
fail. Added YieldOutputAsync to each executor to match the test
expectation and demonstrate the API in the sample.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix deserialization to use shared serializer options.

* PR feedback updates.

* Sample cleanup

* PR feedback fixes

* Addressing PR review feedback for DurableStreamingWorkflowRun

   - Use -1 instead of 0 for taskId in TaskFailedException when task ID is not relevant.
   - Add [NotNullWhen(true)] to TryParseWorkflowResult out parameter following .NET TryXXX conventions.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rkflows (#4190)

* .NET: [Feature Branch] Add nested sub-workflow support for durable workflows

* fix readme path

* Switch Orchestration output from string to DurableWorkflowResult.

* PR feedback fixes

* Minor cleanup based on PR feedback.
…flows (#4358)

* Add Azure Functions HITL workflow sample

Add 06_WorkflowHITL Azure Functions sample demonstrating Human-in-the-Loop
workflow support with HTTP endpoints for status checking and approval responses.

The sample includes:
- ExpenseReimbursement workflow with RequestPort for manager approval
- Custom HTTP endpoint to check workflow status and pending approvals
- Custom HTTP endpoint to send approval responses via RaiseEventAsync
- demo.http file with step-by-step interaction examples

* PR feedback fixes

* Minor comment cleanup

* Minor comment clReverted the `!context.IsReplaying` guards on `PendingEvents.Add`/`RemoveAll` and `SetCustomStatus` in `ExecuteRequestPortAsync`. The guards broke fan-out scenarios where parallel RequestPorts      need to be discoverable after replay. `SetCustomStatus` is idempotent metadata that doesn't affect replay determinism.eanup

* fix  for PR feedback

* PR feedback updates

* Improvements to samples

* Improvements to README

* Update samples to use parallel request ports.

* Unit tests

* Introduce local variables to improve readability of Workflows.Workflows access patter

* Use GitHub-style callouts and add PowerShell command variants in HITL sample README
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET workflows Related to Workflows in agent-framework labels Mar 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kshyju added a commit that referenced this pull request Mar 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.13.1 requires
Microsoft.DurableTask.Worker >= 1.19.1 via its transitive dependency on
Microsoft.DurableTask.Worker.Grpc 1.19.1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kshyju and others added 3 commits March 3, 2026 13:00
- Create Workflow/README.md with environment setup docs
- Fix ../README.md -> ../../README.md in ConsoleApps 01, 02, 03, 08
- Fix SubWorkflows relative path (3 levels -> 4 levels up)
- Fix dead Durable Task Scheduler URL

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…, GetNewSessionAsync rename

- Remove InjectSharedThrow from DurableTask csproj (uses Workflows' internal Throw via InternalsVisibleTo)
- Update ExecuteAsync -> ExecuteCoreAsync with WorkflowTelemetryContext.Disabled
- Update GetNewSessionAsync -> CreateSessionAsync

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aligns with main branch sample reorganization where durable samples
live under 04-hosting/ (alongside DurableAgents/).

- Move samples/Durable/Workflow/ -> samples/04-hosting/DurableWorkflows/
- Add Directory.Build.props matching DurableAgents pattern
- Update slnx project paths
- Update integration test sample paths
- Update README cd paths and cross-references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… APIs

- Remove duplicate OutputLog, WriteInputAsync, CreateTestTimeoutCts, etc. from
  ConsoleAppSamplesValidation (already in SamplesValidationBase)
- Update AddFanInEdge -> AddFanInBarrierEdge in workflow samples
- Update GetNewSessionAsync -> CreateSessionAsync in workflow samples
- Update SourceId -> ExecutorId (obsolete) in workflow samples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add UTF-8 BOM to 20 .cs files across DurableTask, AzureFunctions,
  unit tests, and workflow samples
- Remove unnecessary using directive in 07_SubWorkflows/Executors.cs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kshyju kshyju force-pushed the feat/durable_task branch from ecc41ea to ae6b23c Compare March 4, 2026 01:47
@kshyju kshyju marked this pull request as ready for review March 4, 2026 02:43
Copilot AI review requested due to automatic review settings March 4, 2026 02:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Durable Task–backed durable workflow orchestration support to the .NET Agent Framework, including Azure Functions hosting integration, new workflow client/run abstractions, and end-to-end samples to demonstrate common patterns (fan-out/fan-in, events, shared state, sub-workflows, HITL).

Changes:

  • Introduces durable workflow execution APIs and internal infrastructure in Microsoft.Agents.AI.DurableTask (client/run interfaces, orchestration runner inputs/outputs, routing helpers, serialization payloads).
  • Adds Azure Functions hosting support for durable workflows via dynamic function metadata generation, built-in function dispatch, and Functions-specific options (status/respond endpoints for HITL).
  • Adds durable workflow samples (console + Azure Functions) and updates solution/package metadata accordingly.

Reviewed changes

Copilot reviewed 119 out of 119 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/WorkflowNamingHelperTests.cs Adds unit tests for durable workflow naming helper.
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Microsoft.Agents.AI.DurableTask.UnitTests.csproj Adds project reference needed by new unit tests.
dotnet/src/Microsoft.Agents.AI.Workflows/Microsoft.Agents.AI.Workflows.csproj Exposes internals to DurableTask assembly.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/WorkflowOrchestrator.cs Adds custom orchestrator delegating to DurableWorkflowRunner.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowsFunctionMetadataTransformer.cs Dynamically registers workflow orchestration/activity/entity/http functions.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowOptionsExtensions.cs Adds Functions-specific workflow option for status endpoint exposure.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Microsoft.Agents.AI.Hosting.AzureFunctions.csproj Updates warnings (adds AD0001 suppression).
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Logs.cs Adds workflow-related metadata transformation log messages.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionsDurableOptions.cs Adds Functions-specific durable options (status endpoint enablement).
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionsApplicationBuilderExtensions.cs Adds ConfigureDurableWorkflows/ConfigureDurableOptions for Functions hosting.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs Centralizes creation of function metadata (http/entity/activity/orchestration).
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs Refactors to reuse FunctionMetadataFactory and BuiltInFunctions.ScriptFile.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md Adds unreleased entry for durable workflows hosting.
dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs Extends dispatcher to support workflow orchestration/http/status/respond/activity entrypoints.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/WorkflowNamingHelper.cs Adds naming helpers for durable workflow orchestration and executor IDs.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/WorkflowGraphInfo.cs Adds durable graph representation for routing and condition evaluation.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/WorkflowExecutorInfo.cs Adds executor metadata model (agentic/request port/sub-workflow).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/TypedPayload.cs Adds typed payload wrapper for cross-boundary serialization.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/PendingRequestPortStatus.cs Adds pending HITL request status record.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/IWorkflowRun.cs Adds workflow run handle API (events + bookmarking).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/IWorkflowClient.cs Adds workflow client API (run + streaming).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/IStreamingWorkflowRun.cs Adds streaming run API and HITL response submission API.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/IAwaitableWorkflowRun.cs Adds awaitable completion API for runs.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/ExecutorRegistry.cs Adds executor binding registry for durable workflow dispatch.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/EdgeRouters/IDurableEdgeRouter.cs Adds router abstraction for durable message routing.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/EdgeRouters/DurableFanOutEdgeRouter.cs Adds fan-out router implementation.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowWaitingForInputEvent.cs Adds streaming event for HITL wait points (RequestPort).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowRun.cs Adds durable run implementation (await completion + event sink).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowResult.cs Adds orchestration output wrapper (result + events + sent messages + halt).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowOptions.cs Adds workflow registration + executor/agent auto-registration.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowLiveStatus.cs Adds custom status payload for live streaming + pending HITL requests.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowJsonContext.cs Adds source-gen JSON context for internal durable workflow payloads.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowInput.cs Adds orchestration input envelope type.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowFailedEvent.cs Adds terminal failure event for durable workflows.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowCompletedEvent.cs Adds terminal completion event for durable workflows.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableWorkflowClient.cs Adds Durable Task–based workflow client implementation.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableSerialization.cs Adds shared JSON options for user-defined workflow types.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableRunStatus.cs Adds run status enum surfaced for durable workflows.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableMessageEnvelope.cs Adds durable message envelope for serialized message passing.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableHaltRequestedEvent.cs Adds event representing workflow halt requests.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableExecutorOutput.cs Adds activity output wrapper (result/state/events/messages/halt).
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityInput.cs Adds activity input wrapper (input + type + state).
dotnet/src/Microsoft.Agents.AI.DurableTask/Microsoft.Agents.AI.DurableTask.csproj Adds Workflows project reference; adjusts injection settings.
dotnet/src/Microsoft.Agents.AI.DurableTask/Logs.cs Adds workflow-related structured logs (supersteps, routing, HITL).
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableServicesMarker.cs Adds marker to prevent duplicate core service registration.
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableOptions.cs Adds workflows options to durable configuration container.
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableDataConverter.cs Adds custom DataConverter for durable agent/workflow serialization.
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAgentsOptions.cs Adds ContainsAgent helper used for workflow agent auto-registration.
dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md Adds unreleased entry and reorganizes release sections.
dotnet/samples/04-hosting/DurableWorkflows/README.md Adds top-level README for durable workflow samples.
dotnet/samples/04-hosting/DurableWorkflows/Directory.Build.props Adjusts sample build props (removes SampleEnvironment alias).
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/08_WorkflowHITL/README.md Adds console HITL sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/08_WorkflowHITL/Program.cs Adds console HITL sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/08_WorkflowHITL/Executors.cs Adds console HITL sample executors/models.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/08_WorkflowHITL/08_WorkflowHITL.csproj Adds console HITL sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/07_SubWorkflows/README.md Adds console sub-workflows sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/07_SubWorkflows/Program.cs Adds console sub-workflows sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/07_SubWorkflows/07_SubWorkflows.csproj Adds console sub-workflows sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/06_WorkflowSharedState/README.md Adds console shared-state sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/06_WorkflowSharedState/Program.cs Adds console shared-state sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/06_WorkflowSharedState/06_WorkflowSharedState.csproj Adds console shared-state sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/05_WorkflowEvents/README.md Adds console events/streaming sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/05_WorkflowEvents/Program.cs Adds console events/streaming sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/05_WorkflowEvents/Executors.cs Adds console events/streaming sample executors/events.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/05_WorkflowEvents/05_WorkflowEvents.csproj Adds console events/streaming sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/04_WorkflowAndAgents/Program.cs Adds console sample showing combined agent + workflow configuration patterns.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/04_WorkflowAndAgents/ParseQuestionExecutor.cs Adds executors used by WorkflowAndAgents sample.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/04_WorkflowAndAgents/04_WorkflowAndAgents.csproj Adds WorkflowAndAgents sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/03_ConditionalEdges/README.md Adds console conditional-edges sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/03_ConditionalEdges/Program.cs Adds console conditional-edges sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/03_ConditionalEdges/NotifyFraud.cs Adds conditional-edges sample executors/models.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/03_ConditionalEdges/03_ConditionalEdges.csproj Adds conditional-edges sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/02_ConcurrentWorkflow/README.md Adds console fan-out/fan-in sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/02_ConcurrentWorkflow/Program.cs Adds console fan-out/fan-in sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/02_ConcurrentWorkflow/ExpertExecutors.cs Adds fan-out/fan-in sample executors.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/02_ConcurrentWorkflow/02_ConcurrentWorkflow.csproj Adds fan-out/fan-in sample project.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/01_SequentialWorkflow/README.md Adds console sequential workflow sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/01_SequentialWorkflow/Program.cs Adds console sequential workflow sample implementation.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/01_SequentialWorkflow/OrderCancelExecutors.cs Adds sequential sample executors/models.
dotnet/samples/04-hosting/DurableWorkflows/ConsoleApps/01_SequentialWorkflow/01_SequentialWorkflow.csproj Adds sequential sample project.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/03_WorkflowHITL/host.json Adds Functions HITL sample host configuration.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/03_WorkflowHITL/demo.http Adds Functions HITL sample HTTP demo script.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/03_WorkflowHITL/Program.cs Adds Functions HITL sample entrypoint/workflow definition.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/03_WorkflowHITL/Executors.cs Adds Functions HITL sample executors/models.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/03_WorkflowHITL/03_WorkflowHITL.csproj Adds Functions HITL sample project.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/host.json Adds Functions fan-out/fan-in sample host configuration.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/demo.http Adds Functions fan-out/fan-in sample HTTP demo script.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/README.md Adds Functions fan-out/fan-in sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/Program.cs Adds Functions fan-out/fan-in sample entrypoint/workflow definition.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/ExpertExecutors.cs Adds Functions fan-out/fan-in sample executors.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/02_ConcurrentWorkflow/02_ConcurrentWorkflow.csproj Adds Functions fan-out/fan-in sample project.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/host.json Adds Functions sequential workflows sample host configuration.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/demo.http Adds Functions sequential workflows sample HTTP demo script.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/README.md Adds Functions sequential workflows sample documentation.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/Program.cs Adds Functions sequential workflows sample entrypoint/workflow definitions.
dotnet/samples/04-hosting/DurableWorkflows/AzureFunctions/01_SequentialWorkflow/01_SequentialWorkflow.csproj Adds Functions sequential workflows sample project.
dotnet/agent-framework-dotnet.slnx Adds durable workflow samples to the .NET solution.
dotnet/Directory.Packages.props Updates DurableTask + Functions DurableTask extension package versions.

kshyju and others added 2 commits March 3, 2026 19:50
…EADME

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Split on last underscore instead of first, and validate that the
suffix is a 32-char hex string (sanitized GUID) before stripping it.
This prevents truncation of agent names like 'my_agent' when the
executor ID is 'my_agent_<guid>'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kshyju kshyju requested a review from Copilot March 4, 2026 04:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 119 out of 119 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (6)

dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs:1

  • The activity trigger input binding is named input, but the workflow activity dispatch path in BuiltInFunctionExecutor checks for encodedEntityRequest when handling InvokeWorkflowActivityFunctionEntryPoint. This will cause activity invocations to fail due to missing bindings. Align the binding name with what the executor expects (either change the activity trigger binding name here, or update BuiltInFunctionExecutor to read input for workflow activities).
    dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs:1
  • DeserializeInput assumes any non-string[] array input is the fan-in format (string[] containing JSON strings). If a caller provides a regular JSON array (e.g., [{"id":"x"}, ...]) for an executor expecting T[], JsonSerializer.Deserialize<string[]> will throw a JsonException, even though directly deserializing to T[] would succeed. Consider attempting the fan-in string[] path inside a try/catch (or by validating the JSON token types) and falling back to JsonSerializer.Deserialize(input, targetType, ...) when it isn’t the fan-in shape. Adding a unit test for the “direct JSON typed array” case would help prevent regressions.
    dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs:1
  • supportedTypes is an ISet<Type>, so FirstOrDefault() is not guaranteed to be deterministic across runtimes/implementations. That means the fallback type selection can vary unpredictably (and tests that assert a particular “first” type can be flaky). Consider making the fallback deterministic (e.g., prefer string when present, or order by FullName, or change the API to accept an ordered collection when ordering matters).
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowsFunctionMetadataTransformer.cs:1
  • Both orchestration trigger functions and workflow activity functions are being named via ToOrchestrationFunctionName(...). If an executor name matches a workflow name, these will collide (same function name), and registeredFunctions.Add(...) will cause one of the required functions to be skipped. Use distinct naming schemes for orchestration vs activity functions (e.g., different prefixes) so they cannot clash.
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowsFunctionMetadataTransformer.cs:1
  • Both orchestration trigger functions and workflow activity functions are being named via ToOrchestrationFunctionName(...). If an executor name matches a workflow name, these will collide (same function name), and registeredFunctions.Add(...) will cause one of the required functions to be skipped. Use distinct naming schemes for orchestration vs activity functions (e.g., different prefixes) so they cannot clash.
    dotnet/samples/04-hosting/DurableWorkflows/Directory.Build.props:1
  • This props file is formatted as a single line, which makes it harder to edit/review and more likely to produce noisy diffs later. Consider formatting it with standard XML indentation/newlines (and keeping the comment on its own line) for readability and maintainability.

<PackageVersion Include="Microsoft.DurableTask.Worker" Version="1.18.0" />
<PackageVersion Include="Microsoft.DurableTask.Worker.AzureManaged" Version="1.18.0" />
<PackageVersion Include="Microsoft.DurableTask.Client" Version="1.19.1" />
<PackageVersion Include="Microsoft.DurableTask.Client.AzureManaged" Version="1.19.0" />
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The Durable Task package versions are mixed (Client.AzureManaged is 1.19.0 while the others are 1.19.1). Unless there’s a known compatibility constraint, it’s safer to keep these aligned to the same patch version to reduce the risk of subtle API/behavior mismatches.

Suggested change
<PackageVersion Include="Microsoft.DurableTask.Client.AzureManaged" Version="1.19.0" />
<PackageVersion Include="Microsoft.DurableTask.Client.AzureManaged" Version="1.19.1" />

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to 1.19.1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 119 out of 119 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (8)

dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs:1

  • DeserializeInput treats any non-string array target as the fan-in format (JSON array of strings) and will throw JsonException for a normal JSON array payload (e.g., [{...}, {...}]) even though JsonSerializer could deserialize it directly to the typed array. Consider catching JsonException around the string[] attempt (or detecting the payload shape) and falling back to JsonSerializer.Deserialize(input, targetType, ...) when the payload is not a string-array fan-in encoding.
    dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs:1
  • ResolveInputType can return a loaded Type that is not in supportedTypes (e.g., inputTypeName = "System.Int32"), which will later cause the executor to receive an unexpected input type. If the executor’s supportedTypes are meant to be authoritative, consider returning the first supported type (or throwing) whenever the resolved/loaded type is not contained in supportedTypes (except for the explicit string/string[] fallback cases you already handle).
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowsFunctionMetadataTransformer.cs:1
  • Activity functions are being named using ToOrchestrationFunctionName (prefix 'dafx-'), which is the same naming scheme used for orchestration functions. If an executorName matches a workflow key (or otherwise collides), you can end up skipping registrations or registering the wrong trigger type for a single function name. Consider introducing a distinct naming convention/prefix for activity triggers (e.g., 'dafx-activity-' or similar) and using that for CreateActivityTrigger, while keeping the orchestration naming for orchestrators only.
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/Workflows/DurableWorkflowsFunctionMetadataTransformer.cs:1
  • Activity functions are being named using ToOrchestrationFunctionName (prefix 'dafx-'), which is the same naming scheme used for orchestration functions. If an executorName matches a workflow key (or otherwise collides), you can end up skipping registrations or registering the wrong trigger type for a single function name. Consider introducing a distinct naming convention/prefix for activity triggers (e.g., 'dafx-activity-' or similar) and using that for CreateActivityTrigger, while keeping the orchestration naming for orchestrators only.
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionsApplicationBuilderExtensions.cs:1
  • ConfigureDurableWorkflows validates 'configure' but does not validate 'builder' (unlike ConfigureDurableOptions). If a null builder is passed, this will throw later with a less direct exception. Consider adding ArgumentNullException.ThrowIfNull(builder); for consistency and clearer failure behavior.
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionsApplicationBuilderExtensions.cs:1
  • GetOrCreateSharedOptions only detects an existing DurableOptions registration when it's an ImplementationInstance. If DurableOptions was registered earlier via ImplementationType or factory, this will add another singleton registration (changing which instance is resolved and making behavior order-dependent). Consider handling any existing DurableOptions descriptor (instance/type/factory) explicitly (e.g., replace it, or throw with guidance) so you reliably end up with one shared options instance.
    dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/FunctionMetadataFactory.cs:1
  • RawBindings JSON is composed via string interpolation, which can produce invalid JSON if 'route' (or other interpolated values) contain characters that require escaping (e.g., quotes). Since workflow names/keys can be caller-provided configuration, this can become a reliability and injection surface in metadata generation. Consider building the binding objects (anonymous types / dictionaries) and serializing them with JsonSerializer so values are correctly escaped, and/or validating allowed route/name shapes up front.
    dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableActivityExecutorTests.cs:1
  • DeserializeInput has special handling for non-string arrays, but current tests only cover the fan-in encoding (JSON array of strings). Add a test for the normal case where the payload is a JSON array of objects (e.g., [{"id":...}, ...]) and targetType is TestRecord[], to ensure the method can handle non–fan-in array serialization (and to prevent regressions around the string[] probing logic).

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

Labels

documentation Improvements or additions to documentation .NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants