Files
agent-framework/dotnet/samples/03-workflows
T
Roger Barreto e7961571a8 .NET: Update Azure.AI.Projects 2.0.0-beta.1 (#4270)
* Update Microsoft.Agents.AI.AzureAI for Azure.AI.Projects SDK 2.0.0

- Bump Azure.AI.Projects to 2.0.0-alpha.20260213.1
- Bump Azure.AI.Projects.OpenAI to 2.0.0-alpha.20260213.1
- Bump System.ClientModel to 1.9.0 (transitive dependency)
- Switch both GetAgent and CreateAgentVersion to protocol methods
  with MEAI user-agent policy injection via RequestOptions
- Migrate 29 CREATE-path tests from FakeAgentClient to HttpHandlerAssert
  pattern for real HTTP pipeline testing
- Fix StructuredOutputDefinition constructor (BinaryData -> IDictionary)
- Fix responses endpoint path (openai/responses -> /responses)
- Add local-packages NuGet source for pre-release nupkgs

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

* Update Azure.AI.Projects to 2.0.0-beta.1 from NuGet.org

- Update Azure.AI.Projects and Azure.AI.Projects.OpenAI to 2.0.0-beta.1
- Remove local-packages NuGet source (packages now on nuget.org)
- Fix MemorySearchTool -> MemorySearchPreviewTool rename
- Fix RedTeams.CreateAsync ambiguous call
- Fix CreateAgentVersion/Async signature change (BinaryData -> string)
- Suppress AAIP001 experimental warning for WorkflowAgentDefinition

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

* Move s_modelWriterOptionsWire field before methods that use it

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

* Fix flaky test: prevent spurious workflow_invoke Activity on timeout wake-up

The StreamingRunEventStream run loop uses a 1-second timeout on
WaitForInputAsync. When the timeout fires before the consumer calls
StopAsync, the loop would create a spurious workflow_invoke Activity
even though no actual input was provided. This caused the
WorkflowRunActivity_IsStopped_Streaming_OffThread_MultiTurnAsync test
to intermittently fail (expecting 2 activities but finding 3).

Fix: guard the loop body with a HasUnprocessedMessages check. On
timeout wake-ups with no work, the loop waits again without creating
an activity or changing the run status.

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

* Fix epoch race condition causing unit tests to hang on net10.0 and net472

The HasUnprocessedMessages guard (previous commit) correctly prevents
spurious workflow_invoke Activity creation on timeout wake-ups, but
exposed a latent race in the epoch-based signal filtering.

The race: when the run loop processes messages quickly and calls
Interlocked.Increment(ref _completionEpoch) before the consumer calls
TakeEventStreamAsync, the consumer reads the already-incremented epoch
and sets myEpoch = epoch + 1. This causes the consumer to skip the
valid InternalHaltSignal (its epoch < myEpoch) and block forever
waiting for a signal that will never arrive (since the guard prevents
spurious signal generation).

Fix: read _completionEpoch without +1. The +1 was originally needed to
filter stale signals from timeout-driven spurious loop iterations, but
those no longer exist thanks to the HasUnprocessedMessages guard.

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

* Revert "Fix epoch race condition causing unit tests to hang on net10.0 and net472"

This reverts commit 6ce7f01be8.

* Revert "Fix flaky test: prevent spurious workflow_invoke Activity on timeout wake-up"

This reverts commit 98963e17f2.

* Skip hanging multi-turn declarative integration tests

The ValidateMultiTurnAsync tests (ConfirmInput.yaml, RequestExternalInput.yaml)
hang indefinitely in CI, blocking the merge queue. The hang is SDK-independent
(reproduces with both Azure.AI.Projects 1.2.0-beta.5 and 2.0.0-beta.1) and
is a pre-existing issue in the declarative workflow multi-turn test logic.

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

* Remove unused using directive in IntegrationTest.cs

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

* Restore Azure.AI.Projects 2.0.0-beta.1 version bump

The merge from main accidentally reverted the package versions back to
1.2.0-beta.5. This is the primary change of this PR.

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

* Address merge conflict

* Skip flaky WorkflowRunActivity_IsStopped_Streaming_OffThread_MultiTurnAsync test

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

* Skip CheckSystem test cases temporarily

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e7961571a8 · 2026-03-04 11:36:39 +00:00
History
..

Workflow Getting Started Samples

The getting started with workflow samples demonstrate the fundamental concepts and functionalities of workflows in Agent Framework.

Samples Overview

Foundational Concepts - Start Here

Please begin with the Start Here samples in order. These three samples introduce the core concepts of executors, edges, agents in workflows, streaming, and workflow construction.

The folder name starts with an underscore (_StartHere) to ensure it appears first in the explorer view.

Sample Concepts
Streaming Extends workflows with event streaming
Agents Use agents in workflows
Agentic Workflow Patterns Demonstrates common agentic workflow patterns
Multi-Service Workflows Shows using multiple AI services in the same workflow
Sub-Workflows Demonstrates composing workflows hierarchically by embedding workflows as executors
Mixed Workflow with Agents and Executors Shows how to mix agents and executors with adapter pattern for type conversion and protocol handling
Writer-Critic Workflow Demonstrates iterative refinement with quality gates, max iteration safety, multiple message handlers, and conditional routing for feedback loops

Once completed, please proceed to other samples listed below.

Note that you don't need to follow a strict order after the foundational samples. However, some samples build upon concepts from previous ones, so it's beneficial to be aware of the dependencies.

Agents

Sample Concepts
Foundry Agents in Workflows Demonstrates using Azure Foundry Agents within a workflow
Custom Agent Executors Shows how to create a custom agent executor for more complex scenarios
Workflow as an Agent Illustrates how to encapsulate a workflow as an agent
Group Chat with Tool Approval Shows multi-agent group chat with tool approval requests and human-in-the-loop interaction

Concurrent Execution

Sample Concepts
Fan-Out and Fan-In Introduces parallel processing with fan-out and fan-in patterns

Loop

Sample Concepts
Looping Shows how to create a loop within a workflow

Workflow Shared States

Sample Concepts
Shared States Demonstrates shared states between executors for data sharing and coordination

Conditional Edges

Sample Concepts
Edge Conditions Introduces conditional edges for dynamic routing based on executor outputs
Switch-Case Routing Extends conditional edges with switch-case routing for multiple paths
Multi-Selection Routing Demonstrates multi-selection routing where one executor can trigger multiple downstream executors

These 3 samples build upon each other. It's recommended to explore them in sequence to fully grasp the concepts.

Declarative Workflows

Sample Concepts
Declarative Demonstrates execution of declartive workflows.

Checkpointing

Sample Concepts
Checkpoint and Resume Introduces checkpoints for saving and restoring workflow state for time travel purposes
Checkpoint and Rehydrate Demonstrates hydrating a new workflow instance from a saved checkpoint
Checkpoint with Human-in-the-Loop Combines checkpointing with human-in-the-loop interactions

Human-in-the-Loop

Sample Concepts
Basic Human-in-the-Loop Introduces human-in-the-loop interaction using input ports and external requests