Files
Chris 904a5b843e Python / .NET Samples - Restructure and Improve Samples (Feature Branc… (#4092)
* Python: .NET Samples - Restructure and Improve Samples (Feature Branch) (#4091)

* Moved by agent (#4094)

* Fix readme links

* .NET Samples - Create `04-hosting` learning path step (#4098)

* Agent move

* Agent reorderd

* Remove A2A section from README 

Removed A2A section from the Getting Started README.

* Agent fixed links

* Fix broken sample links in durable-agents README (#4101)

* Initial plan

* Fix broken internal links in documentation

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* Revert template link changes; keep only durable-agents README fix

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* .NET Samples - Create `03-workflows` learning path step (#4102)

* Fix solution project path

* Python: Fix broken markdown links to repo resources (outside /docs) (#4105)

* Initial plan

* Fix broken markdown links to repo resources

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* Update README to rename .NET Workflows Samples section

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* .NET Samples - Create `02-agents` learning path step (#4107)

* .NET: Fix broken relative link in GroupChatToolApproval README (#4108)

* Initial plan

* Fix broken link in GroupChatToolApproval README

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* Update labeler configuration for workflow samples

* .NET - Reorder Agents samples to start from Step01 instead of Step04 (#4110)

* Fix solution

* Resolve new sample paths

* Move new AgentSkills and AgentWithMemory_Step04 samples

* Fix link

* Fix readme path

* fix: update stale dotnet/samples/Durable path reference in AGENTS.md

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>

* Moved new sample

* Update solution

* Resolve merge (new sample)

* Sync to new sample - FoundryAgents_Step21_BingCustomSearch

* Updated README

* .NET Samples - Configuration Naming Update (#4149)

* .NET: Restore AzureFunctions index parity with ConsoleApps under DurableAgents samples (#4221)

* Clean-up `05_host_your_agent`

* Config setting consistency

* Refine samples

* AGENTS.md

* Move new samples

* Re-order samples

* Move new project and fixup solution

* Fixup model config

* Fix up new UT project

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
904a5b843e · 2026-02-26 00:56:10 +00:00
History
..

Multi-Agent Conditional Orchestration Sample

This sample demonstrates how to use the durable agents extension to create a console app that orchestrates multiple AI agents with conditional logic based on the results of previous agent interactions.

Key Concepts Demonstrated

  • Multi-agent orchestration with conditional branching
  • Using agent responses to determine workflow paths
  • Activity functions for non-agent operations
  • Waiting for orchestration completion using WaitForInstanceCompletionAsync

Environment Setup

See the README.md file in the parent directory for more information on how to configure the environment, including how to install and run common sample dependencies.

Running the Sample

With the environment setup, you can run the sample:

cd dotnet/samples/04-hosting/DurableAgents/ConsoleApps/04_AgentOrchestration_Conditionals
dotnet run --framework net10.0

The app will prompt you for email content. You can test both legitimate emails and spam emails:

Testing with a Legitimate Email

=== Multi-Agent Conditional Orchestration Sample ===
Enter email content:

Hi John, I hope you're doing well. I wanted to follow up on our meeting yesterday about the quarterly report. Could you please send me the updated figures by Friday? Thanks!

The orchestration will analyze the email and display the result:

Orchestration started with instance ID: 86313f1d45fb42eeb50b1852626bf3ff
Waiting for completion...

✓ Orchestration completed successfully!

Result: Email sent: Thank you for your email. I'll prepare the updated figures...

Testing with a Spam Email

=== Multi-Agent Conditional Orchestration Sample ===
Enter email content:

URGENT! You've won $1,000,000! Click here now to claim your prize! Limited time offer! Don't miss out!

The orchestration will detect it as spam and display:

Orchestration started with instance ID: 86313f1d45fb42eeb50b1852626bf3ff
Waiting for completion...

✓ Orchestration completed successfully!

Result: Email marked as spam: Contains suspicious claims about winning money and urgent action requests...

Scriptable Usage

You can also pipe email content to the app:

# Test with a legitimate email
echo "Hi John, I hope you're doing well..." | dotnet run

# Test with a spam email
echo "URGENT! You've won $1,000,000! Click here now!" | dotnet run

The orchestration will proceed as follows:

  1. The SpamDetectionAgent analyzes the email to determine if it's spam
  2. Based on the result:
    • If spam: The orchestration calls the HandleSpamEmail activity function
    • If not spam: The EmailAssistantAgent drafts a response, then the SendEmail activity function is called

Viewing Orchestration State

You can view the state of the orchestration in the Durable Task Scheduler dashboard:

  1. Open your browser and navigate to http://localhost:8082
  2. In the dashboard, you can see:
    • Orchestrations: View the orchestration instance, including its runtime status, input, output, and execution history
    • Agents: View the state of both the SpamDetectionAgent and EmailAssistantAgent

The orchestration instance ID is displayed in the console output. You can use this ID to find the specific orchestration in the dashboard and inspect the conditional branching logic, including which path was taken based on the spam detection result.