Users/axsuarez/teams updates#385
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces Python Teams extension samples and adds a new TeamsAgentExtension API (plus docs/tests) built around the Teams SDK Pydantic models (microsoft_teams.api.models).
Changes:
- Added
TeamsAgentExtensionroute decorators for message extensions, task modules, meeting events, plus top-level Teams event hooks. - Added runnable sample agents and supporting docs/env template for message extensions, task modules, and meeting events.
- Added unit tests for selectors/handlers and updated hosting-teams packaging to depend on
microsoft-teams-api>=2,<3.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/hosting_teams/test_teams_agent_extension.py | Adds unit tests validating route selectors and handler behavior for TeamsAgentExtension. |
| test_samples/teams_extension/task_modules_agent.py | Adds runnable task module sample demonstrating task/fetch + task/submit flows. |
| test_samples/teams_extension/shared/start_server.py | Adds shared aiohttp startup helper for samples. |
| test_samples/teams_extension/shared/init.py | Exposes start_server for sample imports. |
| test_samples/teams_extension/message_extensions_agent.py | Adds runnable message extension sample covering main composeExtension/* routes. |
| test_samples/teams_extension/meeting_events_agent.py | Adds runnable meeting lifecycle sample using MeetingDetails + legacy participants/read-receipt models. |
| test_samples/teams_extension/env.TEMPLATE | Adds environment template for local sample configuration. |
| test_samples/teams_extension/TESTING_SEARCH_QUERY.md | Adds detailed manual testing guide for message extension search queries. |
| test_samples/teams_extension/README.md | Documents the new samples, setup, and Teams SDK model swap notes. |
| libraries/microsoft-agents-hosting-teams/setup.py | Adds microsoft-teams-api>=2.0.0,<3 dependency for SDK models. |
| libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/teams_agent_extension.py | Introduces TeamsAgentExtension implementation with Teams-specific route decorators. |
| libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/init.py | Re-exports TeamsAgentExtension and related helper classes from package root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/Agents-for-python/sessions/2086e66b-13ec-46ee-ae6d-0bd5f033ed3c Co-authored-by: axelsrz <5943395+axelsrz@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/microsoft/Agents-for-python/sessions/8266331d-c38d-4535-99c8-9d268cd4b16f Co-authored-by: axelsrz <5943395+axelsrz@users.noreply.github.com>
Applied in 9bbeca4. The remaining thread feedback is now covered: the Teams query selector/test were already fixed earlier, and the sample server now reads |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/teams_agent_extension.py:220
on_agent_message_preview_editselector has the same.get(...)assumption ason_submit_action. Ifcontext.activity.valueis not a dict, route selection will raise at runtime; also consider supporting bothcommandIdandcommand_idhere (and inon_agent_message_preview_send) for consistency withon_query.
value = context.activity.value or {}
if value.get("botMessagePreviewAction") != "edit":
return False
return _match_selector(command_id, value.get("commandId"))
libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/teams_agent_extension.py:298
on_fetch_taskselector uses(context.activity.value or {}).get("commandId"), which will raise ifactivity.valueis a non-dict object. For consistency withon_query(and to avoid selector-time exceptions), consider extracting the command id via dict/attribute access and supportingcommand_idas well.
and _match_selector(
command_id,
(context.activity.value or {}).get("commandId"),
)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/teams_agent_extension.py:270
on_agent_message_preview_sendselector usesvalue = context.activity.value or {}and thenvalue.get(...), which will raise ifactivity.valueis a non-dict object. For consistency withon_submit_action, resolvebotMessagePreviewAction/commandIdfrom either dict keys or object attributes, and consider acceptingcommand_idas well.
def __selector(context: TurnContext) -> bool:
if (
context.activity.type != ActivityTypes.invoke
or context.activity.name != "composeExtension/submitAction"
):
return False
value = context.activity.value or {}
if value.get("botMessagePreviewAction") != "send":
return False
return _match_selector(command_id, value.get("commandId"))
libraries/microsoft-agents-hosting-teams/microsoft_agents/hosting/teams/teams_agent_extension.py:309
on_fetch_taskselector calls(context.activity.value or {}).get("commandId"), which will throw ifactivity.valueis not a dict (and will also ignorecommand_id). Other selectors already support dict vs object and both key styles. Consider extractingcommandIdsafely (dict key / attribute) before_match_selectorso routing can’t fail during selection.
def __selector(context: TurnContext) -> bool:
return (
context.activity.type == ActivityTypes.invoke
and context.activity.name == "composeExtension/fetchTask"
and _match_selector(
command_id,
(context.activity.value or {}).get("commandId"),
)
)
This pull request adds comprehensive Python sample agents and documentation for using the new
TeamsAgentExtensionwith the Teams SDK Pydantic models, along with necessary package updates and environment setup. The changes provide end-to-end, runnable samples for message extensions, task modules, and meeting events, closely mirroring the .NET samples and demonstrating how to use the new Teams SDK model layer in Python.New Teams Extension Samples and Documentation:
test_samples/teams_extension/:message_extensions_agent.py: Demonstrates all message extension invoke routes (search query, select item, submit action, query link, settings, fetch task) using Teams SDK models.task_modules_agent.py: (Not shown in this diff, but referenced in README) for task module flows.meeting_events_agent.py: Demonstrates meeting lifecycle events using the newMeetingDetailsmodel, plus participant join/leave and read receipts (legacy models retained where no SDK equivalent exists).README.md: Explains the samples, setup, and notes on Teams SDK model changes.TESTING_SEARCH_QUERY.md: Step-by-step guide to manually test message extension search queries in both the Agents Playground and real Teams with manifest/tunnel.env.TEMPLATE: Example environment file for configuring credentials and base URLs.Library and Packaging Updates:
microsoft_agents.hosting.teamspackage now re-exportsTeamsAgentExtensionand related types in its__all__, making them available for import from the package root.setup.pyto requiremicrosoft-teams-apiversion 2.x for Teams SDK Pydantic models.shared/start_server.pyutility for consistent sample startup.Summary of Most Important Changes:
1. New Teams Extension Sample Agents and Documentation
message_extensions_agent.py,meeting_events_agent.py, and supporting documentation to demonstrate and test TeamsAgentExtension with the Teams SDK model layer, including end-to-end and manual testing instructions. [1] [2] [3] [4] [5]2. Library and Packaging Updates
TeamsAgentExtensionand related types at the package root for easier imports.microsoft-teams-api>=2.0.0,<3insetup.pyto ensure correct model usage.