Www.casino88DocsReviews & Comparisons
Related
VSTest Drops Newtonsoft.Json: Key Questions AnsweredSUSE Unveils AI-Native Infrastructure Platform at KubeCon Europe 2026Building an AI-Ready Infrastructure with SUSE: A Step-by-Step GuideHow to Choose a New CEO: Lessons from Stack Overflow's Succession ProcessYour Step-by-Step Plan to Ease Knee Arthritis Pain with Aerobic ExerciseTransform Your Windows File Explorer: A Complete Guide to a Smarter, More Efficient SetupScaling Code Review with AI: Cloudflare's Multi-Agent OrchestrationInside Meta's High Court Battle Over UK Online Safety Fees: 8 Key Facts

Building Durable AI Agent Workflows with Microsoft Agent Framework

Last updated: 2026-05-09 01:33:26 · Reviews & Comparisons

Introduction

The Microsoft Agent Framework (MAF) is an open-source, multi-language platform designed for constructing, orchestrating, and deploying AI agents. Since its preview debut, the framework has introduced a powerful workflow programming model that enables developers to combine multiple agents and tasks into cohesive, multi-step pipelines. By defining individual executors, arranging them into a directed graph using a workflow builder, and letting the framework manage execution, data flow, and error handling, teams can model a wide variety of patterns: sequential chains, parallel fan-out/fan-in, conditional branching, human-in-the-loop approvals, and more.

Building Durable AI Agent Workflows with Microsoft Agent Framework
Source: devblogs.microsoft.com

The core workflow package includes a lightweight, in-process runner that executes workflows entirely in memory—ideal for rapid prototyping and local development. In this article, we’ll start by constructing a simple workflow in a .NET console application, then progressively enhance it with durability, parallel AI agents, and Azure Functions hosting.

The Workflow Programming Model

To begin, create a new console app project 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 of a MAF workflow.

Executors: The Building Blocks

An Executor is the fundamental unit of work. It receives typed input, processes it, and produces output. You create one by subclassing Executor<TInput, TOutput>. Below is an example of three executors that simulate an order cancellation flow:

using Microsoft.Agents.AI.Workflows;

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}.");
    }
}

Each executor is named and implements a HandleAsync method that runs the actual logic. The framework automatically manages input/output types and passes data between steps.

Building a Simple Workflow

Once executors are defined, you connect them using a workflow builder. For example, to create a sequential pipeline that looks up an order, cancels it, and sends an email:

var builder = new WorkflowBuilder<OrderCancelRequest, string>();
builder.AddStep<OrderLookup>()
       .AddStep<OrderCancel>()
       .AddStep<SendEmail>();
var workflow = builder.Build();

The workflow can then be executed with an in-process runner:

var runner = new InMemoryWorkflowRunner();
var result = await runner.RunAsync(workflow, inputMessage);
Console.WriteLine(result.Output);

This simple runner keeps everything in memory, making it perfect for testing and local development.

Building Durable AI Agent Workflows with Microsoft Agent Framework
Source: devblogs.microsoft.com

Adding Durability

For production scenarios, workflows often need to survive process restarts or maintain state across interruptions. MAF provides a durable workflow backend that persists execution state to a database. This ensures that long-running workflows—those that wait for human approvals or external events—can be resumed from the last completed step.

To add durability, swap the in-memory runner for a durable one configured with Azure Storage, SQL Server, or another supported provider. The same workflow definition remains unchanged; only the runner implementation differs.

Parallel AI Agents and Advanced Patterns

Beyond sequential flows, MAF supports parallel fan-out/fan-in patterns. You can define multiple AI agents to run concurrently—for instance, analyzing customer sentiment, generating responses, and checking compliance simultaneously. The workflow builder allows you to create branches that merge later.

Conditional branching lets the workflow choose different paths based on output from a previous executor. And human-in-the-loop patterns pause execution until a user approves or rejects a step, which pairs naturally with durable storage.

Hosting in Azure Functions

For cloud-native deployment, MAF workflows integrate seamlessly with Azure Functions. You can wrap a workflow inside an HTTP-triggered function, making it available as a RESTful API. Durable Functions can even manage long-running workflows natively, though MAF’s own durable runner offers more flexibility for agent-centric logic.

[FunctionName("CancelOrderWorkflow")]
public static async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req,
    IWorkflowRunner runner)
{
    var request = await req.ReadFromJsonAsync<OrderCancelRequest>();
    var result = await runner.RunAsync(cancelOrderWorkflow, request);
    return new OkObjectResult(result.Output);
}

This approach gives you automatic scaling, monitoring, and cost-effective execution.

Conclusion

The Microsoft Agent Framework’s workflow programming model provides a solid foundation for building robust, durable AI agent pipelines. Starting from simple executors and an in-memory runner, you can gradually introduce durability, parallelism, and cloud hosting without changing your core logic. Whether you’re automating customer support, processing orders, or orchestrating complex multi-agent tasks, MAF gives you the tools to create scalable, maintainable workflows.

For more details, refer to the Executors section and workflow building examples.