-
Notifications
You must be signed in to change notification settings - Fork 587
.NET: Sample on Worflows mixing Agents And Executors, showcasing best patte… #1562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Sample on Worflows mixing Agents And Executors, showcasing best patte… #1562
Conversation
…rns which are reusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a foundational workflow sample demonstrating how to combine executors and agents sequentially, addressing a critical learning gap in the Agent Framework documentation. The sample implements a content moderation pipeline that shows developers how to bridge type mismatches between executors (working with simple types) and agents (requiring ChatMessage/TurnToken) using adapter executors.
Key Changes:
- Introduces sample 07_MixedWorkflowAgentsAndExecutors showing sequential Executor → Agent → Executor → Agent chaining
- Demonstrates adapter pattern for type conversion (string to ChatMessage) and chat protocol handling (TurnToken)
- Implements practical content moderation pipeline with jailbreak detection and safety-aware responses
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| 07_MixedWorkflowAgentsAndExecutors/README.md | Comprehensive documentation explaining adapter pattern, chat protocol requirements, and workflow architecture |
| 07_MixedWorkflowAgentsAndExecutors/Program.cs | Sample implementation with custom executors, adapter executors, and AI agents demonstrating sequential chaining |
| 07_MixedWorkflowAgentsAndExecutors/07_MixedWorkflowAgentsAndExecutors.csproj | Project configuration with required dependencies |
| Workflows/README.md | Updated table of contents to include new sample |
| agent-framework-dotnet.slnx | Added project reference to solution |
...samples/GettingStarted/Workflows/_Foundational/07_MixedWorkflowAgentsAndExecutors/Program.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
…WorkflowAgentsAndExecutors/Program.cs Co-authored-by: Copilot <[email protected]>
… patte… (#1562) * Sample on Worflows mixing Agents And Executors, showcasing best patterns which are reusable. * Update dotnet/samples/GettingStarted/Workflows/README.md Co-authored-by: Copilot <[email protected]> * Update dotnet/samples/GettingStarted/Workflows/_Foundational/07_MixedWorkflowAgentsAndExecutors/Program.cs Co-authored-by: Copilot <[email protected]> * minor fix --------- Co-authored-by: Copilot <[email protected]>
|
@markwallace-microsoft, can we try to merge again? it failed due to "#1562 was automatically removed from the merge queue due to failed status checks." Wait, I see the issue : Error: /home/runner/work/agent-framework/agent-framework/dotnet/samples/GettingStarted/Workflows/_Foundational/07_MixedWorkflowAgentsAndExecutors/Program.cs(135,65): error CS0121: The call is ambiguous between the following methods or properties: 'InProcessExecution.StreamAsync(Workflow, string?, CancellationToken)' and 'InProcessExecution.StreamAsync(Workflow, TInput, string?, CancellationToken)' [/home/runner/work/agent-framework/agent-framework/dotnet/samples/GettingStarted/Workflows/_Foundational/07_MixedWorkflowAgentsAndExecutors/07_MixedWorkflowAgentsAndExecutors.csproj] This is a bit weird mesage, not? Let me see if i can improve this... |
|
Hi @alliscode & @markwallace-microsoft :) Fixed the last pending issue due to an ambiguous signature with: I guess this was added recently as when getting the last MAF bits it was not building :) - now it builds again. |
Closes #1561 1561
Motivation and Context
Why is this change required?
Developers learning the Agent Framework face a critical learning gap when trying to integrate custom executors with AI agents in workflows. While existing samples demonstrate:
• Executor-only workflows (01_ExecutorsAndEdges, 02_Streaming)
• Agent-only workflows (03_AgentsInWorkflows, 04_AgentWorkflowPatterns)
• Concurrent fan-out/fan-in patterns (Concurrent, WorkflowAsAnAgent)
No foundational sample exists that teaches the sequential chaining pattern: Executor → Agent → Executor → Agent.
What problem does it solve?
This sample addresses three fundamental knowledge gaps:
• Message accumulation via context.SendMessageAsync(chatMessage)
• Processing trigger via context.SendMessageAsync(new TurnToken())
No existing sample explains or demonstrates this protocol.
• Why adapters are necessary
• How to implement them correctly
• How to chain multiple agents through executors
What scenario does it contribute to?
This sample demonstrates a real-world content moderation pipeline that:
• ✅ Accepts user input through an executor
• ✅ Processes data with deterministic executors (text transformation)
• ✅ Converts types using adapter executor (string → ChatMessage + TurnToken)
• ✅ Leverages AI agent for security analysis (jailbreak detection)
• ✅ Processes agent output with another adapter executor
• ✅ Chains to a second AI agent for final response
• ✅ Outputs formatted results through a final executor
Real-world use cases enabled:
• Content moderation and safety screening
• Multi-stage data enrichment (fetch → analyze → format → validate)
• Compliance checking with AI-powered decision making
• Quality assurance pipelines with AI reviewers
Related Issues
This PR addresses the foundational gap identified in the workflow samples learning path, specifically the missing bridge between basic executor/agent concepts (samples 01-04) and advanced patterns.
See #1561