Use Temporal to coordinate durable work in a .NET AI application, and put every LLM request, tool call, database operation, and other external I/O in an Activity. Keep Workflow code deterministic so Temporal can replay its recorded history after a worker restart without calling the model again. Microsoft.Extensions.AI can provide a common .NET abstraction for chat and embedding clients; it does not provide durable execution.
What each part of the system is responsible for
Think of the design as three separate concerns: calling AI services, coordinating work over time, and defining agent behavior. Keeping those concerns distinct makes it easier to change a model provider, recover an orchestration after interruption, or revise a multi-step process without implying that any one component guarantees the others.
As an Amazon Associate I earn from qualifying purchases.
| Technology | Use it for | What it does not replace |
|---|---|---|
Microsoft.Extensions.AI |
Common .NET abstractions for chat and embedding clients, with provider integrations behind them. | Durable workflow execution or agent orchestration. Microsoft recommends starting with it for most app-level AI features. Microsoft’s .NET AI ecosystem guide and Microsoft.Extensions.AI libraries |
| Microsoft Agent Framework | Multi-step agent behavior, routing, and handoffs. | A provider-neutral chat abstraction or, by itself, the same orchestration model as Temporal. The ecosystem guidance distinguishes its agent role from the client abstractions. Microsoft’s .NET AI ecosystem guide |
| Temporal | Durable, long-running application orchestration using Workflows, Activities, and Workers. | Correct AI answers or exactly-once effects in external systems. Workflows replay deterministically; nondeterministic external operations belong in Activities. Temporal’s .NET SDK developer guide and .NET SDK repository |
| Azure Durable Task | Durable workflow and agent programming in Azure’s ecosystem. | It is not simply another name for an agent framework. For a deployment decision, assess language and framework integration, hosting, state management, operations, and portability. Microsoft’s Durable Task guidance for AI agents |
These choices are not necessarily mutually exclusive. Microsoft describes providers supported through Microsoft.Extensions.AI as usable with Agent Framework, and Temporal workflows can coordinate direct LLM calls or agent frameworks. Compatibility depends on the specific SDKs and versions you select; verify that combination before committing to an architecture. Microsoft’s .NET AI ecosystem guide Microsoft’s Durable Task guidance
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Why model and tool calls belong in Activities
A Temporal Workflow is the durable coordinator, not the place to make fresh external requests. Workflow code should derive decisions from workflow inputs, deterministic logic, messages, timers, and recorded Activity results. It must avoid external I/O, mutable external state, system-clock access, and random or otherwise nondeterministic calls. On replay, Temporal reconstructs workflow progress from history; the recorded Activity result is used rather than asking the model for a new response. Temporal’s .NET SDK developer guide Temporal’s .NET Workflow versioning guidance
#1 Best Overall
That separation also makes failure policy explicit. An Activity can call a configured IChatClient, invoke a search or other tool, or write to a database. The Workflow can then schedule the next step based on the result, wait for approval, or respond to cancellation. Keeping external effects in Activities gives you a place to apply timeouts, retries, auditing, and operation-specific safeguards.
Keep replay-safe coordination in the Workflow
- Accept stable, typed inputs and keep only the state needed to continue the business process.
- Schedule Activities, coordinate their recorded outcomes, and wait on Temporal timers or Workflow messages.
- Keep large documents or binary data in external storage and pass references when appropriate; this is an application design choice, not a prescribed API rule.
- Do not put provider credentials or fresh provider-specific decisions in Workflow logic.
Temporal’s .NET SDK documentation also cautions against ordinary thread-pool and delay patterns such as Task.Run and Task.Delay in Workflow code. Follow the guidance for the specific SDK version you deploy rather than assuming normal application-code behavior is safe during replay. Temporal .NET SDK repository
Rank #2
Put nondeterministic work in Activities
Register the chosen AI client through your application’s dependency-injection configuration, then let an Activity use it. An AI Activity might receive a bounded prompt or request plus references to needed data and return a structured result. Put consequential tool effects—such as changing a record or initiating an external action—in separate Activities when that makes retries, auditing, and failure handling clearer. Exact client registration and method calls vary with provider and package versions, so there is no single provider-independent code snippet that can be assumed to compile unchanged.
Plan for retries and external side effects
Activity retries are useful when a transient failure interrupts work, but a retry can mean the downstream system receives the operation again. Durable orchestration preserves workflow progress; it does not make a provider call or external write exactly once. The application and downstream service must define how duplicate effects are avoided or detected. Temporal’s .NET SDK developer guide Temporal .NET SDK repository
Rank #3
- Make writes idempotent where possible. Use an idempotency key or downstream deduplication mechanism appropriate to the target system. The correct design depends on that system.
- Choose timeouts and retry behavior per operation. A read, a model request, and a payment-like or state-changing action do not necessarily have the same safe retry policy.
- Use heartbeats for suitable long-running Activities. Heartbeats can report progress through Temporal’s mechanisms; design resumption behavior for the operation rather than assuming a heartbeat makes arbitrary work resumable.
- Handle ambiguous outcomes. If a connection fails after a downstream service may have accepted a write, determine whether to query, deduplicate, or reconcile before repeating it.
The Temporal .NET guide covers Activity execution, timeouts, asynchronous completion, and error handling. Use those mechanisms together with the downstream system’s own guarantees; no orchestration setting can substitute for an idempotency plan. Temporal’s .NET SDK developer guide
Use Queries, Signals, and Updates for different interactions
Long-running AI workflows often need to expose progress or wait for user input. Temporal’s message types have distinct semantics, so pick one according to whether the caller is reading state, sending a message, or asking the workflow to apply a change and acknowledge it. Temporal’s guide to Workflow message passing
Rank #4
| Message type | What it does | Useful example |
|---|---|---|
| Query | Reads current Workflow state without changing it or blocking for a result. Temporal Documentation describes Queries as read requests that cannot block. | Show the current stage or status in a progress view. |
| Signal | Asynchronously changes Workflow state without waiting for a result from the Workflow. | Deliver user-provided context, or notify the workflow of a cancellation request. |
| Update | Tracks a write so the caller can wait for completion or an error. | Submit an approval or configuration decision when the caller needs an acknowledged outcome. |
Validate incoming values before applying them to workflow state. Decide how late messages, repeated submissions, and cancellation arriving during an Activity should behave; those are business rules the workflow must implement, not guarantees implied by choosing a message type.
A practical build sequence
- Define durable boundaries. Give each step stable, typed inputs and outputs. Keep only continuation-critical state in the workflow and use references for large external data where suitable.
- Choose and register the AI client. Configure
IChatClientor a supported provider integration using application dependency injection. Keep credentials and provider policy in configuration and service boundaries, not workflow code. Microsoft.Extensions.AI libraries - Write the deterministic coordinator. Have the Workflow schedule Activities, wait on timers or messages, and decide from durable inputs and recorded results. Avoid direct model, HTTP, database, clock, and random calls in the Workflow. Temporal’s .NET SDK developer guide
- Implement model and tool Activities. Bound requests, return structured results, and separate side-effecting tool operations where separate retry and audit boundaries help. Match implementation details to the selected provider and SDK versions.
- Set failure behavior deliberately. Define timeouts and retries around the operation’s characteristics, deduplicate writes, and use heartbeats for work that supports progress reporting or resumption. Temporal’s .NET SDK developer guide
- Expose the right workflow messages. Use Queries for status reads, Signals for asynchronous input, and Updates when the caller needs a tracked write result. Validate all received input. Temporal’s guide to Workflow message passing
- Test interruption and evolution paths. Exercise worker termination, Activity retry, duplicate requests, cancellation, late input, and replay of histories created by earlier Workflow code. Temporal’s .NET guide includes testing and versioning resources. Temporal’s .NET SDK developer guide
- Evaluate AI quality separately. Build evaluations around representative prompts and outputs so regressions from changing prompts, models, or tools can be detected. Track operational signals such as latency, errors, token or cost data when available, tool outcomes, and retry behavior. Microsoft’s .NET AI guidance treats evaluation as a quality and regression layer. Microsoft’s .NET AI ecosystem guide Develop .NET apps with AI features
Handle Workflow code changes while executions are open
Long-running executions may outlive a deployment. Because Temporal replays Workflow history, an orchestration change that alters the sequence of commands can make old histories incompatible with new code. Use Temporal’s .NET versioning approach when a change would make replay nondeterministic, and keep external calls inside Activities. Plan deployment and replay testing around the histories that may still be active, not only around newly started workflows. Temporal’s .NET Workflow versioning guidance
For executions that accumulate substantial history or run for a long time, the .NET guide includes Continue-As-New. Use it where appropriate to begin a new run while carrying forward the business state needed to continue; history and payload choices depend on the application. Temporal’s .NET SDK developer guide
What Temporal does—and does not—make reliable
Temporal can durably coordinate steps and recover orchestration progress after worker interruptions. It cannot make an external AI provider available, ensure a model response is correct, guarantee that a fresh model call would return the same answer, or turn external writes into exactly-once operations. Put model calls behind Activities so replay uses their recorded result, then design retries and duplicate protection around each downstream operation.
For .NET 10 specifically, verify the current stable Temporal .NET SDK and AI-provider package versions, their target-framework support, and any preview labels before implementation. The architecture guidance establishes how the components fit together; it is not a tested end-to-end sample or a guarantee that every current package combination supports a given target framework.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




