Building Resilient AI Agent Workflows with Microsoft Agent Framework
Introduction
The Microsoft Agent Framework (MAF) is an open-source, multi-language toolkit designed to help developers create, orchestrate, and deploy AI agents. Since its preview announcement, the framework has evolved significantly, adding a powerful workflow programming model. This model allows you to combine multiple agents and other discrete units of work into multi-step pipelines. Each step is defined as an Executor, and these executors are wired together in a directed graph using a workflow builder. The framework then handles execution, data flow between steps, and error propagation. Workflows can model sequential chains, parallel fan-out/fan-in patterns, conditional branching, human-in-the-loop approvals, and more.

The core workflow package includes a lightweight in-process runner that executes workflows entirely in memory—perfect for quick starts and local development. In this article, we’ll build a simple workflow in a .NET console app, then progressively add durability, parallel AI agents, and Azure Functions hosting.
The Workflow Programming Model
To get started, create a new console app and add the following NuGet packages:
dotnet add package Microsoft.Agents.AI
dotnet add package Microsoft.Agents.AI.Workflows
Now let’s explore the core building blocks.
Executors: The Fundamental Unit of Work
An Executor is the basic unit of work in a MAF workflow. It receives typed input, processes it, and produces output. You create one by subclassing Executor<TInput, TOutput>. For example, here’s an executor that looks up an order:
internal sealed class OrderLookup()
: Executor<OrderCancelRequest, Order>("OrderLookup")
{
public override async ValueTask<Order> HandleAsync(
OrderCancelRequest message,
IWorkflowContext context,
CancellationToken cancellationToken = default)
{
await Task.Delay(TimeSpan.FromMilliseconds(100), cancellationToken);
return new Order(
Id: message.OrderId,
OrderDate: DateTime.UtcNow.AddDays(-1),
IsCancelled: false,
CancelReason: message.Reason,
Customer: new Customer(Name: "Jerry", Email: "jerry@example.com"));
}
}
Similarly, you can define executors for canceling an order and sending an email:
internal sealed class OrderCancel()
: Executor<Order, Order>("OrderCancel")
{
public override async ValueTask<Order> HandleAsync(
Order message,
IWorkflowContext context,
CancellationToken cancellationToken = default)
{
await Task.Delay(TimeSpan.FromMilliseconds(200), cancellationToken);
return message with { IsCancelled = true };
}
}
internal sealed class SendEmail()
: Executor<Order, string>("SendEmail")
{
public override ValueTask<string> HandleAsync(
Order message,
IWorkflowContext context,
CancellationToken cancellationToken = default)
{
return ValueTask.FromResult(
$"Cancellation email sent for order {message.Id} to {message.Customer.Email}.");
}
}
Wiring Executors into a Workflow Graph
Executors are not standalone; they must be connected into a directed graph using a workflow builder. The builder defines the sequence and branches of execution. For example, a simple sequential workflow that looks up an order, cancels it, then sends an email:
var workflow = new WorkflowBuilder()
.AddStep(new OrderLookup())
.AddStep(new OrderCancel())
.AddStep(new SendEmail())
.Build();
The builder also supports parallel branches, conditional branches, and human-in-the-loop steps. The framework automatically routes data between steps based on their input/output types.
Running Workflows In-Process
To execute the workflow, use the in-process runner included in the core package:
var runner = new WorkflowRunner();
var result = await runner.RunAsync(workflow, new OrderCancelRequest { OrderId = 123 });
Console.WriteLine(result);
This runs the entire workflow synchronously in memory—ideal for testing and simple scenarios.

Adding Durability
For production, you often need durable workflows—ones that survive process restarts or failures. MAF supports durability through a persistent store (e.g., Azure Storage, SQL). You configure the runner with a durability provider:
var runner = new WorkflowRunner(new AzureStorageDurabilityProvider(connectionString));
await runner.RunAsync(workflow, input);
With durability, the framework saves the state of each executor after completion. If the process crashes, the workflow resumes from the last saved step. This is crucial for long-running workflows that involve human-in-the-loop approvals or waiting for external events.
Parallel AI Agents and Fan-Out Patterns
One of MAF’s strengths is the ability to run multiple AI agents in parallel. For example, you might have three agents analyzing different aspects of a customer query simultaneously. Using a fan-out pattern:
var workflow = new WorkflowBuilder()
.AddStep(new QueryClassifier())
.AddParallel(
new IntentAnalyzer(),
new SentimentAnalyzer(),
new EntityExtractor())
.AddStep(new ResponseAggregator())
.Build();
Here, AddParallel runs all three executors concurrently. The framework waits for all to complete before passing their outputs to the next step. This pattern significantly reduces total execution time when agents are independent.
Hosting in Azure Functions
To scale and manage workflows in the cloud, you can host them inside Azure Functions. MAF integrates seamlessly with the Azure Functions runtime. For example, an HTTP-triggered function can start a durable workflow:
[FunctionName("StartOrderCancellation")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req,
[WorkflowRunner] IWorkflowRunner runner)
{
var request = await req.ReadFromJsonAsync<OrderCancelRequest>();
var workflow = CreateOrderCancellationWorkflow();
var result = await runner.RunAsync(workflow, request);
return new OkObjectResult(result);
}
By using Azure Functions, you gain built-in scaling, monitoring, and cost efficiency. Workflows can also be triggered by timers, queues, or event hubs.
Conclusion
The Microsoft Agent Framework provides a flexible and robust workflow model for building AI agent pipelines. Starting with simple in-process executors, you can gradually add durability, parallel execution, and cloud hosting. Whether you’re prototyping locally or deploying to production, MAF’s workflow programming model helps you create resilient, maintainable agent orchestrations.
For more details, refer to the official GitHub repository and the Azure AI documentation.
Related Articles
- Akane-Banashi Anime Proves Rakugo’s Timeless Appeal, Spring’s Most Underrated Series
- 7 Critical Facts About the RAM Shortage That Will Shock You
- ASML's Lithography Technology Roadmap: From DUV to Hyper-NA and the Future of Chip Manufacturing
- Navigating the Transition from CEO to Chairman: A Sabbatical Blueprint
- Beelink EX Mate Pro: A Feature-Packed USB4 v2 Dock with Quad M.2 Storage Expandability
- Global Internet Disruptions Surge in Q1 2026: Government Shutdowns, Power Grid Failures, and Conflict Hit Connectivity
- Building Resilient Multi-Step Workflows with Microsoft Agent Framework
- Inside the Musk v. Altman Trial: A Step-by-Step Guide to the Legal Battle Over OpenAI's Mission