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
- Azure Functions: Fully managed with auto-scaling
- Console Apps: Self-hosted for development or on-premises
- ASP.NET: Embedded in web applications
Quick Start
Prerequisites
Start the Durable Task Scheduler emulator:http://localhost:8082.
Python Setup
C# Setup
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:Reliable Streaming
Implement resumable streaming with Redis:Configuration
Connection Settings
Task Hub Configuration
Task hubs provide isolation between environments:Monitoring
DTS Dashboard
View orchestration status athttp://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
Design for Idempotency
Design for Idempotency
Orchestrations may replay. Ensure activities are idempotent:
Minimize Orchestration State
Minimize Orchestration State
Keep orchestration input/output small to reduce storage costs:
Handle Timeouts Gracefully
Handle Timeouts Gracefully
Set appropriate timeouts for external events:
Use Task Hubs for Isolation
Use Task Hubs for Isolation
Separate environments with different task hubs:
- Development:
dev - Staging:
staging - Production:
production
Troubleshooting
Worker Not Receiving Tasks
Worker Not Receiving Tasks
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
Orchestration Stuck
Orchestration Stuck
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
State Corruption
State Corruption
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_datetimeinstead ofdatetime.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