Skip to main content

What are Workflows?

Workflows in Microsoft Agent Framework enable you to build complex, graph-based orchestrations of agents and executors. Unlike simple sequential chains, workflows provide:
  • Graph-based execution: Define nodes (executors) and edges to create flexible, non-linear execution flows
  • Type-safe message passing: Executors communicate via strongly-typed messages
  • Built-in orchestration: Support for sequential, concurrent, fan-out/fan-in, and conditional routing patterns
  • State management: Maintain workflow state across executions
  • Checkpointing: Save and restore workflow state for long-running processes
  • Human-in-the-loop: Pause execution to collect input and resume seamlessly

Core Concepts

Executors

Executors are the building blocks of workflows. Each executor represents a unit of work that processes input and produces output.

Edges

Edges connect executors, defining how data flows through the workflow. Edges can be:
  • Simple: Direct connections between two executors
  • Conditional: Route based on message content
  • Fan-out: Send to multiple targets in parallel
  • Fan-in: Aggregate from multiple sources
  • Switch-case: Route to one of many targets based on conditions

WorkflowBuilder

The WorkflowBuilder provides a fluent API for constructing workflows:

Workflow Execution Model

Workflows execute in super steps:
  1. Super step: A stage where one or more executors run in parallel
  2. Message passing: Executors send messages to downstream executors
  3. Next super step: All messages from the previous step trigger the next set of executors
  4. Completion: Workflow completes when idle (no pending work)
Workflow execution model showing super steps

Function-based Executors

For simple operations, you can define executors as functions:

Type System

Workflows use a rich type system for message passing:
  • Input types: Types an executor can handle (from @handler parameter)
  • Output types: Types an executor can send via ctx.send_message()
  • Workflow output types: Types an executor can yield via ctx.yield_output()

Agents in Workflows

Agents can be used directly as executors in workflows:

Next Steps

Building Workflows

Learn how to construct workflows with the WorkflowBuilder API

Orchestration Patterns

Explore sequential, concurrent, and conditional execution patterns

Checkpoints

Save and restore workflow state for long-running processes

Human-in-the-Loop

Integrate human decision points into your workflows

Common Patterns

Sequential Pipeline

Feedback Loop

Parallel Processing

Workflows execute until idle - when no executors have pending work. Use ctx.yield_output() to produce final results.