Skip to content

Flow bot request context through BotBuilder compat clients#594

Merged
heyitsaamir merged 4 commits into
mainfrom
heyitsaamir-compat-user-token-context
Jul 9, 2026
Merged

Flow bot request context through BotBuilder compat clients#594
heyitsaamir merged 4 commits into
mainfrom
heyitsaamir-compat-user-token-context

Conversation

@heyitsaamir

Copy link
Copy Markdown
Collaborator

Summary

  • Pass BotRequestContext through CompatUserTokenClient to all core user token calls.
  • Set shared request context for reactive and proactive BotBuilder compat turns.
  • Pass request context through remaining compat conversation/update and adapter send paths.
  • Add unit coverage for user token, conversation, and adapter request-context plumbing.

Validation

  • dotnet test core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/Microsoft.Teams.Apps.BotBuilder.UnitTests.csproj --no-restore

Ensure BotBuilder compat conversation and user token calls pass BotRequestContext through to core clients for both reactive and proactive turns.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 22:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR threads BotRequestContext through the BotBuilder compatibility layer so downstream core HTTP clients (conversation + user token) can authenticate/act using per-request bot identity (and agentic identity when present), for both reactive (inbound activity) and proactive (ContinueConversationAsync) turns.

Changes:

  • Plumbs BotRequestContext into CompatUserTokenClient and CompatConversations calls, and sets shared request context in TeamsBotFrameworkHttpAdapter.
  • Updates TeamsBotAdapter send path to pass request context into ConversationClient.SendActivityAsync.
  • Adds/updates unit tests covering request-context propagation for user token, conversation update, and adapter send/continue flows.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatUserTokenClientTests.cs Adds unit coverage verifying CompatUserTokenClient forwards BotRequestContext to core UserTokenClient.
core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatConversationsTests.cs Adds test ensuring CompatConversations.UpdateActivityWithHttpMessagesAsync passes RequestContext.
core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatBotAdapterTests.cs Tightens assertion to validate BotRequestContext content is passed on send.
core/test/Microsoft.Teams.Apps.BotBuilder.UnitTests/CompatAdapterTests.cs Adds proactive-turn coverage ensuring turn-state UserTokenClient uses the proactive BotRequestContext.
core/src/Microsoft.Teams.Apps.BotBuilder/TeamsBotFrameworkHttpAdapter.cs Creates one inbound/proactive BotRequestContext and shares it across compat clients per turn.
core/src/Microsoft.Teams.Apps.BotBuilder/TeamsBotAdapter.cs Passes request context through the adapter send path into ConversationClient.
core/src/Microsoft.Teams.Apps.BotBuilder/CompatUserTokenClient.cs Adds RequestContext property and forwards it into all core user-token calls.
core/src/Microsoft.Teams.Apps.BotBuilder/CompatConversations.cs Forwards RequestContext into update-activity call to core conversation client.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/Microsoft.Teams.Apps.BotBuilder/TeamsBotAdapter.cs
heyitsaamir and others added 2 commits July 8, 2026 15:26
Pass full BotRequestContext through BotBuilder TeamsApiClient calls so bot app id is preserved alongside agentic identity.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MehakBindra

Copy link
Copy Markdown
Member

Looks good ! Related to the previous PR - #591 can we remove the non BotRequestContext overloads, since it is an optional param anyway

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@heyitsaamir

Copy link
Copy Markdown
Collaborator Author

@MehakBindra addressed this in 402f3ad. I removed the redundant non-BotRequestContext overloads from UserTokenClient and made the requestContext parameters optional on the remaining methods. I also updated the internal wrappers/tests to use named cancellationToken arguments where positional calls would otherwise bind to requestContext.

@heyitsaamir heyitsaamir added this pull request to the merge queue Jul 9, 2026
Merged via the queue into main with commit 8b867a7 Jul 9, 2026
6 checks passed
@heyitsaamir heyitsaamir deleted the heyitsaamir-compat-user-token-context branch July 9, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants