Skip to main content

Overview

The Microsoft Agent Framework integrates with Durable Functions and Durable Task Framework to enable long-running, stateful agent workflows. This integration provides checkpoint and resume capabilities, parallel execution, human-in-the-loop patterns, and reliable state management for complex agent orchestrations.

Key Features

  • Durable orchestrations: Coordinate multiple agent calls with automatic checkpointing
  • State persistence: Agent conversation state survives restarts and failures
  • Parallel execution: Run multiple agents concurrently and aggregate results
  • External events: Human-in-the-loop and external approval workflows
  • Long-running tools: Agents can invoke durable activities for extended operations
  • Reliable streaming: Resumable streaming with cursor-based resumption

Architecture Patterns

Worker-Client Architecture

DurableTask uses a distributed worker-client pattern:

Hosting Options

  1. Azure Functions: Fully managed with auto-scaling
  2. Console Apps: Self-hosted for development or on-premises
  3. ASP.NET: Embedded in web applications

Quick Start

Prerequisites

Start the Durable Task Scheduler emulator:
DTS dashboard available at http://localhost:8082.

Python Setup

1

Install Package

2

Create Worker

Create worker.py:
3

Create Client

Create client.py:
4

Run

In one terminal:
In another terminal:

C# Setup

1

Add Package

2

Create Program.cs

3

Configure Settings

Create local.settings.json:
4

Start Function

Single Agent Pattern

Host a single durable agent with persistent state:

Multi-Agent Pattern

Host multiple specialized agents:

Orchestration Patterns

Sequential Chaining

Chain agent calls with shared session:

Parallel Execution

Run multiple agents concurrently:

Conditional Routing

Route to different agents based on conditions:

Human-in-the-Loop (HITL)

Incorporate human approval in workflows:
Send approval:

Reliable Streaming

Implement resumable streaming with Redis:
Consume stream with cursor:

Configuration

Connection Settings

Task Hub Configuration

Task hubs provide isolation between environments:

Monitoring

DTS Dashboard

View orchestration status at http://localhost:8082:
  • Orchestrations: List all running/completed orchestrations
  • Instance details: View inputs, outputs, and execution history
  • Timeline: See checkpoints and state transitions

Query Orchestration Status

Best Practices

Orchestrations may replay. Ensure activities are idempotent:
Keep orchestration input/output small to reduce storage costs:
Set appropriate timeouts for external events:
Separate environments with different task hubs:
  • Development: dev
  • Staging: staging
  • Production: production

Troubleshooting

Symptoms: Client schedules tasks but worker doesn’t process themSolutions:
  • Verify worker and client use same task hub name
  • Check DTS connection strings match
  • Ensure worker called start() and is running
  • Check DTS dashboard for pending tasks
Symptoms: Orchestration shows as “Running” indefinitelySolutions:
  • Check worker logs for errors
  • Verify all activities are registered
  • Look for unhandled exceptions in orchestration code
  • Check if waiting for external event that never arrives
Symptoms: “Non-deterministic behavior detected” errorsSolutions:
  • Don’t use random numbers or current time in orchestrations
  • Don’t make non-deterministic API calls
  • Use context.current_utc_datetime instead of datetime.now()
  • Generate GUIDs with context.new_uuid()

Next Steps

Azure Functions

Deploy durable agents to Azure Functions

A2A Protocol

Integrate with A2A agents in orchestrations