Fix ChannelServiceAdapter.create_conversation implementation#233
Fix ChannelServiceAdapter.create_conversation implementation#233rodrigobr-msft merged 12 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the conversation creation flow by making the context parameter optional in create_connector_client and adjusting the initialization order in create_conversation. The key change ensures the connector client can be created without a context when starting a new conversation.
- Made
contextparameter optional (TurnContext | None) increate_connector_clientmethod - Reordered initialization in
create_conversationto create the connector client before the turn context - Updated validation logic to handle optional context parameter
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| channel_service_client_factory_base.py | Updated interface to make context parameter optional |
| rest_channel_service_client_factory.py | Made context optional and updated validation/usage logic |
| channel_service_adapter.py | Reordered conversation creation to build connector client before turn context |
| default_test_values.py | Added service_url test constant |
| test_rest_channel_service_client_factory.py | Added comprehensive tests for the optional context parameter |
| test_channel_service_adapter.py | Added stub test file for channel service adapter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...aries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py
Outdated
Show resolved
Hide resolved
...oft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...aries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
tests/hosting_core/test_rest_channel_service_client_factory.py:57
- This comment appears to contain commented-out code.
# def activity_agentic_user(self):
# return Activity(
# type="message",
# channel_id="msteams",
# from_property=ChannelAccount(id="agentic_user", role=RoleTypes.USER),
# recipient=ChannelAccount(id="bot1", role=RoleTypes.BOT),
# service_url="https://service.url/",
# conversation={"id": "conv1"},
# id="activity_agentic1",
# text="Hello, World!",
# properties={
# "agenticRequest": True
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...aries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_service_adapter.py
Show resolved
Hide resolved
…into users/robrandao/create-conversation-bug
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request refactors how connector clients are created in the Microsoft Agents Hosting Core, making the process more robust and flexible by allowing a
Nonevalue for thecontextparameter and improving error handling. It also adds new and more comprehensive unit tests for the connector client factory logic, and updates test data to support these changes.Connector Client Creation Refactoring
create_connector_clientmethod inChannelServiceClientFactoryBaseand its implementation inRestChannelServiceClientFactorynow acceptcontext: TurnContext | Noneinstead of requiring a non-null context, allowing for greater flexibility in usage. The method also now only requiresclaims_identityto be non-null, improving error handling. [1] [2]create_connector_clientis updated to safely handle cases wherecontextmay beNone.Channel Service Adapter Refactoring
ChannelServiceAdapter.create_conversationis refactored to create the connector client before the turn context, and to properly set turn state keys for both the connector client and user token client after the context is created. [1] [2]Test Improvements
test_rest_channel_service_client_factory.pythoroughly tests different scenarios for creating a connector client, including anonymous and normal token flows, with and without scopes, and with/without context.test_channel_service_adapter.pyis introduced for future coverage of the adapter's conversation creation logic.Test Data Updates
DEFAULT_TEST_VALUESis updated to include aservice_urlfield, supporting the new and updated tests.