Building Durable AI Agent Pipelines with Microsoft’s Agent Framework

Introduction

The Microsoft Agent Framework (MAF) is an open-source, multi-language toolset for creating, orchestrating, and deploying AI agents. Since its preview release, the framework has introduced a robust workflow programming model that allows developers to chain multiple agents and tasks into multi-step pipelines. These workflows support sequential steps, parallel execution, conditional branching, human-in-the-loop approvals, and more. A lightweight in-process runner makes it easy to get started locally. In this article, we’ll explore the core components of MAF workflows and build a simple example step by step. We’ll also touch on adding durability and hosting the workflow in Azure Functions.

Building Durable AI Agent Pipelines with Microsoft’s Agent Framework
Source: devblogs.microsoft.com

Understanding the Workflow Programming Model

At its heart, a MAF workflow is a directed graph of individual units of work called executors. Each executor receives typed input, processes it, and produces typed output. A workflow builder wires these executors together, defining the data flow between steps and handling error propagation automatically. The runtime executes the graph efficiently, supporting patterns like fan-out/fan-in and conditional logic.

Core Building Blocks: Executors

An executor is the fundamental unit of work in a MAF workflow. To create one, you subclass Executor<TInput, TOutput> and implement the HandleAsync method. Each executor has a unique name that identifies it in the workflow. Here’s an example of three executors for an order cancellation pipeline:

internal sealed class OrderLookup : Executor<OrderCancelRequest, Order>("OrderLookup")
{
    public override async ValueTask<Order> HandleAsync(
        OrderCancelRequest message,
        IWorkflowContext context,
        CancellationToken cancellationToken = default)
    {
        await Task.Delay(100, cancellationToken);
        return new Order(
            Id: message.OrderId,
            OrderDate: DateTime.UtcNow.AddDays(-1),
            IsCancelled: false,
            CancelReason: message.Reason,
            Customer: new Customer("Jerry", "jerry@example.com"));
    }
}

internal sealed class OrderCancel : Executor<Order, Order>("OrderCancel")
{
    public override async ValueTask<Order> HandleAsync(
        Order message,
        IWorkflowContext context,
        CancellationToken cancellationToken = default)
    {
        await Task.Delay(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}.");
    }
}

These executors are simple, but they illustrate the pattern. You can inject dependencies, call external services, or invoke AI models inside HandleAsync.

Building a Simple Workflow

To compose executors into a workflow, you use a workflow builder. The builder allows you to define the execution graph—connecting outputs to inputs. For a linear chain like our order cancellation, you would add each executor in sequence. The built workflow can then be run with the in-process runner, which executes everything in memory.

  1. Create a new .NET console app.
  2. Add NuGet packages: Microsoft.Agents.AI and Microsoft.Agents.AI.Workflows.
  3. Define the executors as shown above.
  4. Use the builder to wire them together.
  5. Run the workflow and observe the output.

Here’s a minimal code snippet to get started:

Building Durable AI Agent Pipelines with Microsoft’s Agent Framework
Source: devblogs.microsoft.com
var builder = new WorkflowBuilder();
builder.AddExecutor(new OrderLookup());
builder.AddExecutor(new OrderCancel());
builder.AddExecutor(new SendEmail());
builder.Connect("OrderLookup", "OrderCancel");
builder.Connect("OrderCancel", "SendEmail");

var workflow = builder.Build();
var result = await workflow.RunAsync(new OrderCancelRequest("ORD-123", "Customer request"));
Console.WriteLine(result);

This simple example runs entirely in memory, perfect for development and testing.

Adding Durability to Workflows

The in-process runner is ephemeral—if the application restarts, the workflow state is lost. For production scenarios, durability is essential. MAF supports durable workflows by persisting the state of executors and the workflow graph to a backing store (e.g., Azure Storage, SQL Server). When you enable durability, the framework saves progress after each step, allowing workflows to survive crashes and continue from the last completed step.

To add durability, you typically configure a state store and replace the in-process runner with a durable runner. The core programming model remains the same—executors still define the logic—but the runtime handles checkpointing and recovery automatically.

Hosting Workflows in Azure Functions

MAF workflows can be hosted in various environments, including Azure Functions. By wrapping the workflow runner inside an Azure Function trigger (e.g., HTTP trigger, queue trigger), you can scale execution on demand. The framework integrates with the Azure Functions runtime, providing easy configuration for durable storage and scaling. This is ideal for event-driven AI agent pipelines that need to process work items as they arrive.

To host a workflow in Azure Functions, you add the MAF NuGet packages to a Functions project, define the workflow and executors, and then call the runner from the function handler. The same durability features work seamlessly in this environment.

Conclusion

The Microsoft Agent Framework’s workflow programming model gives developers a powerful, extensible way to build multi-step AI agent pipelines. With simple executors as building blocks, you can create complex graphs that handle sequential, parallel, and conditional logic. Starting with the in-process runner makes development fast, and adding durability later ensures reliability in production. By hosting in Azure Functions, you get automatic scaling and a fully managed environment. Whether you’re orchestrating simple order cancellations or sophisticated multi-agent AI tasks, MAF workflows provide the structure you need.

Tags:

Recommended

Discover More

Fedora 44 Arrives: Enhanced Desktops, Better Gaming, and New Developer ToolsBorder Device Searches: 8 Critical Facts You Must Know About Warrantless Phone InspectionsGrafana Launches Adaptive Logs Drop Rules to Cut Noise and Costs in Public PreviewSmartwatch Heart Rate Data Could Revolutionize Depression Diagnosis, Experts SayHuman Expertise: The Real Driver of AI Success in 2025