When using the Microsoft Agents SDK to build workflows, registering a workflow as a singleton in the DI container causes a System.InvalidOperationException when concurrent requests try to take exclusive ownership of the same instance. The fix is to register workflows as transient (or use a factory pattern) so each run gets its own instance. For durable/persisted workflows, ownership leases across process boundaries must also be managed carefully to avoid stale locks.
Table of contents
What's actually happeningWhy singletons cause thisThree ways to fix itQuick checklistMore informationSort: