Handling empty invoke response bodies in testing tool - #436
Closed
Rodrigo Brandão (rodrigobr-msft) wants to merge 49 commits into
Closed
Handling empty invoke response bodies in testing tool#436Rodrigo Brandão (rodrigobr-msft) wants to merge 49 commits into
Rodrigo Brandão (rodrigobr-msft) wants to merge 49 commits into
Conversation
…into users/robrandao/teams-turn-context
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…t/Agents-for-python into users/robrandao/msteams
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 2, 2026 15:10
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new Microsoft Teams hosting extension package (microsoft-agents-hosting-msteams), expands the Activity entity model to support targeted delivery metadata, and improves the testing transcript exchange path to gracefully handle empty invoke response bodies. It also adds extensive Teams hosting tests and new Teams sample apps, and updates CI to install the renamed Teams hosting wheel on Python 3.11+.
Changes:
- Add
microsoft_agents.hosting.msteamspackage (Teams route namespaces, TeamsTurnContext/TeamsActivity, Teams API client + Graph client integration). - Add
ActivityTreatment/ActivityTreatmentTypesentity model support for targeted activities. - Harden transcript testing transport (
Exchange.from_request) for empty invoke response bodies + add tests; update CI scripts and add Teams samples/tests.
Reviewed changes
Copilot reviewed 99 out of 103 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/hosting_msteams/init.py | Initializes Teams-hosting test package. |
| tests/hosting_msteams/helpers.py | Shared mocks/helpers for Teams-hosting unit tests. |
| tests/hosting_msteams/test_channels.py | Unit tests for Teams channel/membership routing selectors/handlers. |
| tests/hosting_msteams/test_config.py | Unit tests for Teams config invoke routes. |
| tests/hosting_msteams/test_file_consent.py | Unit tests for Teams file consent invoke routes. |
| tests/hosting_msteams/test_internal.py | Tests Teams API client accessor + error resources. |
| tests/hosting_msteams/test_message_extensions.py | Unit tests for composeExtension (message extensions) routing. |
| tests/hosting_msteams/test_messages.py | Unit tests for Teams message update + actionable message routes. |
| tests/hosting_msteams/test_meetings.py | Unit tests for Teams meeting lifecycle routes. |
| tests/hosting_msteams/test_routing_integration.py | End-to-end integration tests driving real AgentApplication routing with Teams extension. |
| tests/hosting_msteams/test_task_modules.py | Unit tests for task/fetch and task/submit routing + invoke responses. |
| tests/hosting_msteams/test_team_lifecycle.py | Unit tests for Teams team lifecycle conversation update routes. |
| tests/hosting_msteams/test_teams_activity.py | Tests TeamsActivity channel_data parsing/mutation helpers. |
| tests/hosting_msteams/test_teams_agent_extension.py | Tests TeamsAgentExtension properties and before_turn behavior. |
| tests/hosting_msteams/test_teams_turn_context.py | Tests TeamsTurnContext helpers like targeted activity treatments. |
| tests/hosting_msteams/test_utils.py | Tests internal Teams hosting utility helpers (_utils). |
| test_samples/hosting_msteams/task-modules/README.md | Documentation for task-modules Teams sample. |
| test_samples/hosting_msteams/task-modules/env.TEMPLATE | Env template for task-modules sample. |
| test_samples/hosting_msteams/task-modules/pyproject.toml | Packaging metadata/deps for task-modules sample. |
| test_samples/hosting_msteams/task-modules/src/init.py | Package init for task-modules sample. |
| test_samples/hosting_msteams/task-modules/src/agent.py | Task modules sample agent implementation using TeamsAgentExtension. |
| test_samples/hosting_msteams/task-modules/src/card_loader.py | Resource loader helper for Adaptive Card JSON/text resources. |
| test_samples/hosting_msteams/task-modules/src/main.py | Entry point for task-modules sample. |
| test_samples/hosting_msteams/task-modules/src/resources/dialog-form.html | Webpage dialog HTML for task module sample. |
| test_samples/hosting_msteams/task-modules/src/resources/launcher-card.json | Launcher Adaptive Card for task module sample. |
| test_samples/hosting_msteams/task-modules/src/resources/multi-step-email-card.json | Multi-step form Adaptive Card (email step). |
| test_samples/hosting_msteams/task-modules/src/resources/multi-step-name-card.json | Multi-step form Adaptive Card (name step). |
| test_samples/hosting_msteams/task-modules/src/resources/simple-form-card.json | Simple form Adaptive Card. |
| test_samples/hosting_msteams/task-modules/src/start_server.py | aiohttp server bootstrap for task-modules sample. |
| test_samples/hosting_msteams/message-extensions/README.md | Documentation for message-extensions Teams sample. |
| test_samples/hosting_msteams/message-extensions/env.TEMPLATE | Env template for message-extensions sample. |
| test_samples/hosting_msteams/message-extensions/pyproject.toml | Packaging metadata/deps for message-extensions sample. |
| test_samples/hosting_msteams/message-extensions/static/settings.html | Settings page UI for message extension sample. |
| test_samples/hosting_msteams/message-extensions/src/init.py | Package init for message-extensions sample. |
| test_samples/hosting_msteams/message-extensions/src/agent.py | Message extensions sample agent implementation. |
| test_samples/hosting_msteams/message-extensions/src/main.py | Entry point for message-extensions sample. |
| test_samples/hosting_msteams/message-extensions/src/start_server.py | aiohttp server bootstrap for message-extensions sample. |
| test_samples/hosting_msteams/conversation-agent/README.md | Documentation for conversation-agent Teams sample. |
| test_samples/hosting_msteams/conversation-agent/env.TEMPLATE | Env template for conversation-agent sample. |
| test_samples/hosting_msteams/conversation-agent/pyproject.toml | Packaging metadata/deps for conversation-agent sample. |
| test_samples/hosting_msteams/conversation-agent/src/init.py | Package init for conversation-agent sample. |
| test_samples/hosting_msteams/conversation-agent/src/main.py | Entry point for conversation-agent sample. |
| test_samples/hosting_msteams/conversation-agent/src/start_server.py | aiohttp server bootstrap for conversation-agent sample. |
| libraries/microsoft-agents-hosting-teams/readme.md | Removes legacy hosting-teams package readme. |
| libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/init.py | Removes legacy hosting-teams export surface. |
| libraries/microsoft-agents-hosting-msteams/LICENSE | Adds MIT license file for new package. |
| libraries/microsoft-agents-hosting-msteams/MANIFEST.in | Ensures VERSION.txt included in sdist. |
| libraries/microsoft-agents-hosting-msteams/pyproject.toml | Renames package to microsoft-agents-hosting-msteams and lowers python requirement to 3.11+. |
| libraries/microsoft-agents-hosting-msteams/setup.py | Adds msgraph dependency to Teams hosting distribution. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/init.py | Public exports for Teams hosting extension. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_graph.py | GraphServiceClient creation via SDK-backed auth provider. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_teams_api_client.py | Per-turn Teams ApiClient construction + caching in turn_state. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_utils.py | Shared Teams hosting utilities (selectors, channel data parsing, invoke responses). |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/proactive_service_endpoints.py | Defines well-known Teams serviceUrl endpoints for proactive scenarios. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/route_handlers.py | Protocols + wrappers for Teams-aware route/handoff handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/teams_activity.py | Teams-aware Activity subclass with channel_data helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/teams_agent_extension.py | Main TeamsAgentExtension wiring before_turn hook, route wrappers, API/Graph helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/teams_turn_context.py | TeamsTurnContext wrapper; targeted activity helper APIs. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/type_defs.py | Shared type aliases/protocols for route selectors/decorators. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/channel/init.py | Channel route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/channel/route_handlers.py | Protocol for channel update handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/config/init.py | Config route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/config/config.py | Config invoke route registration helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/config/route_handlers.py | Protocol for config handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/errors/init.py | Exports Teams error resources singleton. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/errors/error_resources.py | Defines Teams error codes/resources. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/file_consent/init.py | File consent route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/file_consent/file_consent.py | File consent invoke route registration helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/file_consent/route_handlers.py | Protocol for file consent handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/meeting/init.py | Meeting route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/meeting/meeting.py | Meeting lifecycle route registration helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/meeting/route_handlers.py | Protocols for meeting event handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/message/init.py | Message route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/message/message.py | Message update + actionable message routing helpers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/message/route_handlers.py | Protocols for message handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/message_extension/init.py | Message extension route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/message_extension/route_handlers.py | Protocols for composeExtension handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/task_module/init.py | Task module route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/task_module/task_module.py | Task module invoke routing + verb matching + invoke response send. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/task_module/route_handlers.py | Protocols for task module handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/team/init.py | Team route helper exports. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/team/route_handlers.py | Protocol for team update handlers. |
| libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/team/team.py | Team lifecycle routing helpers using channel eventType selectors. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/turn_context.py | Clarifies _activity usage and ensures send_activity always returns a ResourceResponse. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/_type_defs.py | Adds HandoffHandler protocol. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py | Refactors handoff typing to use HandoffHandler and makes auth non-optional. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/app_options.py | Imports Connections for app options typing. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/entity/activity_treatment.py | Adds ActivityTreatment entity model + treatment enum. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/entity/entity_types.py | Adds ACTIVITY_TREATMENT entity type constant. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/entity/init.py | Exports ActivityTreatment types from entity package. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/init.py | Exposes ActivityTreatment types at top-level activity package. |
| dev/testing/microsoft-agents-testing/microsoft_agents/testing/core/transport/transcript/exchange.py | Treats empty invoke response bodies as {} instead of failing JSON parse. |
| dev/testing/microsoft-agents-testing/tests/core/transport/transcript/test_exchange.py | Adds tests covering empty invoke response body parsing. |
| .github/workflows/python-package.yml | Updates CI wheel install step for hosting_msteams and Python 3.11+. |
| .azdo/ci-pr.yaml | Updates AzDO CI wheel install step for hosting_msteams and Python 3.11+. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET= | ||
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID= | ||
|
|
||
| SETTINGS_URL No newline at end of file |
| PUBLIC_GLOBAL = "https://smba.trafficmanager.net/teams/" | ||
|
|
||
| # Service endpoint for the GCC (Government Community Cloud) Teams environment. | ||
| GCC = "https://smba.infra.gcc.teams.microsoft.com/teams" |
Comment on lines
+19
to
+22
| GCC_HIGH = "https://smba.infra.gov.teams.microsoft.us/teams" | ||
|
|
||
| # Service endpoint for the DoD (Department of Defense) Teams environment. | ||
| DOD = "https://smba.infra.dod.teams.microsoft.us/teams" |
|
|
||
| import re | ||
| import pytest | ||
| from unittest.mock import AsyncMock, MagicMock |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
|
|
||
| pytestmark = pytest.mark.skipif( | ||
| not is_supported_version, | ||
| reason="microsoft-agents-hosting-teams tests require Python 3.11+", |
Rodrigo Brandão (rodrigobr-msft)
deleted the
users/robrandao/testing-tweaks
branch
July 2, 2026 15:16
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.
This pull request introduces several new features and improvements across the codebase, with a focus on adding Teams-specific hosting support, enhancing activity entity types, and improving extensibility and robustness. The most important changes are summarized below.
Teams Hosting Extension and Microsoft Graph Integration
microsoft_agents_hosting_msteamspackage, which provides Teams-specific hosting functionality via theTeamsAgentExtensionand related helpers, enabling Teams event routing and context handling. (microsoft_agents/hosting/msteams/__init__.py, libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/init.pyR1-R39)microsoft_agents/hosting/msteams/_graph.py, libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_graph.pyR1-R86)Activity Entity Model Enhancements
ActivityTreatmentandActivityTreatmentTypesas new entity types, updated exports and enums to support them, and registered them in the activity entity model. (microsoft_agents/activity/entity/activity_treatment.py, [1];microsoft_agents/activity/entity/entity_types.py, [2];microsoft_agents/activity/entity/__init__.py, [3] [4];microsoft_agents/activity/__init__.py, [5] [6]Hosting Core Improvements
handoffroute registration inAgentApplicationto use a newHandoffHandlerprotocol, improving type safety and clarity for handoff handlers. (microsoft_agents/hosting/core/app/_type_defs.py, [1];microsoft_agents/hosting/core/app/agent_application.py, [2] [3] [4] [5] [6] [7]TurnContext, such as clarifying the internal_activityattribute and ensuringsend_activityalways returns aResourceResponse. (microsoft_agents/hosting/core/turn_context.py, [1] [2] [3] [4] [5] [6]Testing and Robustness
microsoft_agents/testing/core/transport/transcript/exchange.py, [1];tests/core/transport/transcript/test_exchange.py, [2]Build and CI Adjustments
microsoft_agents_hosting_msteamspackage instead of the old Teams package, and lowered the required Python version for installation from 3.12+ to 3.11+. (.github/workflows/python-package.yml, [1];.azdo/ci-pr.yaml, [2]These changes collectively enhance the SDK's extensibility, enable Microsoft Teams hosting, and improve reliability and test coverage.