fix: prevent duplicate middleware registration in ChannelCloudAdapterWithErrorHandlerBase - #191
Merged
lmarcos000 merged 1 commit intoJun 1, 2026
Conversation
Updated `ChannelCloudAdapterWithErrorHandlerBase` to remove automatic middleware registration by the base constructor. Subclasses must now explicitly call `InitializeDefaultMiddlewares` or `InitializeMiddlewares` to register middlewares in a controlled order. Updated the constructor to pass an empty middleware array. Incremented version to `10.0.5` in `Directory.Build.props` and updated the changelog to reflect these changes.
MarioEncamina
approved these changes
May 27, 2026
dianadiazbisbe
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Microsoft Agents SDK now registers middlewares internally during the
CloudAdapterbase constructor call. SinceChannelCloudAdapterWithErrorHandlerBasewas passingadapterOptions.Middlewares.ToArray()to the base constructor and subclasses were also callingInitializeMiddlewares, middlewares were being registered twice.Motivation and Context
Upgrading the Microsoft Agents SDK introduced a breaking change in how
CloudAdapterhandles middlewares internally. Passing the middleware collection to the base constructor caused duplicates whenInitializeMiddlewaresorInitializeDefaultMiddlewareswas subsequently called by subclasses.The fix passes an empty array to the base constructor instead, preventing the SDK from auto-registering middlewares. Subclasses are now responsible for explicitly calling
InitializeDefaultMiddlewaresorInitializeMiddlewaresin their own constructor to register middlewares in a controlled order.Type of change
Checklist