Temporal .NET SDK integrations for building durable AI applications. Two packages, two levels of abstraction:
| Package | Description |
|---|---|
Temporalio.Extensions.AI |
Make any IChatClient durable — no Agent Framework required |
Temporalio.Extensions.Agents |
Durable agent sessions built on Microsoft Agent Framework (Microsoft.Agents.AI) |
Both packages give AI workloads durability by default — conversation history, LLM calls, and tool invocations are persisted in Temporal's event history and replayed deterministically after crashes or restarts.
A lightweight middleware layer for Microsoft.Extensions.AI (MEAI). Wraps any IChatClient with Temporal durability via a DelegatingChatClient middleware. No agent framework, no heavy abstractions — just MEAI pipelines made crash-resilient.
Start here if: you are already using MEAI's IChatClient directly and want Temporal durability without adopting the full Agent Framework.
dotnet add package Temporalio.Extensions.AIA Temporal integration for Microsoft Agent Framework (Microsoft.Agents.AI). Each AIAgent session maps to a long-lived Temporal workflow with full session management: history, StateBag persistence, HITL approval gates, LLM-powered routing, and parallel agent fan-out.
Start here if: you are building with the Microsoft Agent Framework and want durable, stateful, multi-agent sessions.
dotnet add package Temporalio.Extensions.AgentsBoth packages share the same core pattern: LLM calls run inside Temporal activities (never directly in workflows), and conversation turns are delivered via Temporal Updates — a durable, acknowledged request/response primitive that eliminates polling.
External Caller
│
│ WorkflowUpdate (chat turn / agent message)
▼
Temporal Workflow ←── persists history, serializes turns, handles ContinueAsNew
│
│ ExecuteActivityAsync
▼
Activity ←── calls real IChatClient / AIAgent — retried automatically on failure
- .NET 10 SDK or later
- A running Temporal server:
temporal server start-dev - An LLM provider (e.g., Azure OpenAI, OpenAI, Ollama)
| Sample | Package | Description |
|---|---|---|
| DurableChat | Extensions.AI |
Multi-turn durable chat with DurableChatSessionClient and tool functions |
| DurableTools | Extensions.AI |
Per-tool activity dispatch with AsDurable() and AddDurableTools |
| OpenTelemetry | Extensions.AI |
OTel tracing — span hierarchy, ActivitySource names, and token attributes |
| HumanInTheLoop | Extensions.AI |
HITL approval gates via RequestApprovalAsync and SubmitApprovalAsync |
| DurableEmbeddings | Extensions.AI |
IEmbeddingGenerator wrapped for durable per-chunk activity dispatch |
| BasicAgent | Extensions.Agents |
External caller pattern — send messages to an agent from a console app |
| SplitWorkerClient | Extensions.Agents |
Worker and client in separate processes |
| WorkflowOrchestration | Extensions.Agents |
Sub-agent orchestration inside a Temporal workflow |
| EvaluatorOptimizer | Extensions.Agents |
Generator + evaluator loop pattern |
| MultiAgentRouting | Extensions.Agents |
LLM-powered routing, parallel execution, and OpenTelemetry |
| HumanInTheLoop | Extensions.Agents |
HITL approval gates via [WorkflowUpdate] |
API keys are managed with dotnet user-secrets — stored outside the repo in ~/.microsoft/usersecrets/ and loaded automatically by Host.CreateApplicationBuilder() in the Development environment.
Set OPENAI_API_KEY for each sample project you want to run:
dotnet user-secrets set "OPENAI_API_KEY" "sk-..." --project samples/MEAI/DurableChatNon-sensitive settings (OPENAI_API_BASE_URL, OPENAI_MODEL, TEMPORAL_ADDRESS) have working defaults in each project's committed appsettings.json and do not need to be set via user-secrets unless you want to override them.
Alternatively, set OPENAI_API_KEY as an environment variable — the samples pick it up automatically via IConfiguration.
# Start Temporal (separate terminal)
temporal server start-dev --namespace default
# Run a sample
dotnet run --project samples/MEAI/DurableChat
dotnet run --project samples/MAF/BasicAgentjust build # Restore + Release build
just test-unit # Unit tests (no server required)
just test # Unit + integration tests (requires temporal server start-dev)
just pack # Build NuGet packages → artifacts/packages/
just ci # Full pipeline: clean → build → test-unit → pack