Skip to main content

Overview

Workflows in the Microsoft Agent Framework .NET SDK enable you to build sophisticated multi-step agentic applications. Workflows orchestrate multiple processing units (executors) connected by edges, supporting patterns like sequential processing, parallel execution, conditional routing, and loops.

Core Concepts

Executors

Executors are the processing units in a workflow. Each executor:
  • Accepts strongly-typed input
  • Performs processing (calls an agent, transforms data, etc.)
  • Returns strongly-typed output
  • Can be stateful or stateless

Edges

Edges define the data flow between executors. They determine:
  • Which executors are connected
  • The order of execution
  • Conditional routing logic

WorkflowBuilder

WorkflowBuilder is the fluent API for constructing workflows:

Creating Executors

Custom Executor Class

From Lambda Functions

Use BindAsExecutor() to create executors from lambda functions:

From Async Functions

Building Workflows

Simple Sequential Workflow

Workflow with Agents

Integrate AI agents into workflows:

Streaming Workflow Events

Stream workflow events as they occur:

Parallel Execution (Fan-Out/Fan-In)

Execute multiple executors in parallel:

Conditional Edges

Route based on executor output:

Loops

Create iterative workflows:

Writer-Critic Pattern

Iterative refinement with quality gates:

Checkpointing

Save and restore workflow state:

Human-in-the-Loop

Pause workflow for human input:

Shared State

Share state between executors:

Sub-Workflows

Compose workflows hierarchically:

Workflow Visualization

Generate workflow diagrams:

Best Practices

Each executor should have a single, well-defined responsibility. Break complex logic into multiple executors.
Leverage .NET’s type system with Executor<TIn, TOut> to catch errors at compile time:
Implement error handling in executors:
Use checkpointing for workflows that take significant time or process critical data.
Subscribe to workflow events for observability:
Prefer conditional edges over complex executor logic for routing decisions.
Always include iteration limits in loops to prevent infinite execution:

Next Steps

Declarative Workflows

Define workflows using YAML

Durable Workflows

Build reliable, resumable workflows

Multi-Agent Patterns

Common agentic workflow patterns

Observability

Monitor and debug workflows