Skip to content

Users/axsuarez/teams updates#385

Merged
axelsrz merged 15 commits into
mainfrom
users/axsuarez/teams-updates
May 13, 2026
Merged

Users/axsuarez/teams updates#385
axelsrz merged 15 commits into
mainfrom
users/axsuarez/teams-updates

Conversation

@axelsrz
Copy link
Copy Markdown
Member

@axelsrz axelsrz commented May 11, 2026

This pull request adds comprehensive Python sample agents and documentation for using the new TeamsAgentExtension with 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:

  • Added three runnable sample agents in 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 new MeetingDetails model, plus participant join/leave and read receipts (legacy models retained where no SDK equivalent exists).
  • Added detailed documentation:
    • 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.teams package now re-exports TeamsAgentExtension and related types in its __all__, making them available for import from the package root.
  • Updated setup.py to require microsoft-teams-api version 2.x for Teams SDK Pydantic models.
  • Added shared/start_server.py utility for consistent sample startup.

Summary of Most Important Changes:

1. New Teams Extension Sample Agents and Documentation

  • Added 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

  • Exposed TeamsAgentExtension and related types at the package root for easier imports.
  • Declared dependency on microsoft-teams-api>=2.0.0,<3 in setup.py to ensure correct model usage.
  • Added a shared start server utility for sample consistency.

Copilot AI review requested due to automatic review settings May 11, 2026 17:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TeamsAgentExtension route 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.

Comment thread tests/hosting_teams/test_teams_agent_extension.py Outdated
Comment thread test_samples/teams_extension/shared/start_server.py Outdated
Copilot AI review requested due to automatic review settings May 12, 2026 23:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Comment thread tests/hosting_teams/test_teams_agent_extension.py Outdated
Comment thread test_samples/teams_extension/shared/start_server.py Outdated
Comment thread test_samples/teams_extension/TESTING_SEARCH_QUERY.md Outdated
axelsrz and others added 2 commits May 12, 2026 16:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 12, 2026 23:52
axelsrz and others added 2 commits May 12, 2026 16:52
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment thread tests/hosting_teams/test_teams_agent_extension.py
Comment thread test_samples/teams_extension/shared/start_server.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 12, 2026 23:59
@axelsrz
Copy link
Copy Markdown
Member Author

axelsrz commented May 12, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

@copilot apply changes based on the comments in this thread

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 HOST from the environment (default localhost) while keeping PORT as an int. No UI changes in this update.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_edit selector has the same .get(...) assumption as on_submit_action. If context.activity.value is not a dict, route selection will raise at runtime; also consider supporting both commandId and command_id here (and in on_agent_message_preview_send) for consistency with on_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_task selector uses (context.activity.value or {}).get("commandId"), which will raise if activity.value is a non-dict object. For consistency with on_query (and to avoid selector-time exceptions), consider extracting the command id via dict/attribute access and supporting command_id as 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>
Copilot AI review requested due to automatic review settings May 13, 2026 00:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_send selector uses value = context.activity.value or {} and then value.get(...), which will raise if activity.value is a non-dict object. For consistency with on_submit_action, resolve botMessagePreviewAction / commandId from either dict keys or object attributes, and consider accepting command_id as 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_task selector calls (context.activity.value or {}).get("commandId"), which will throw if activity.value is not a dict (and will also ignore command_id). Other selectors already support dict vs object and both key styles. Consider extracting commandId safely (dict key / attribute) before _match_selector so 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"),
                )
            )

@axelsrz axelsrz marked this pull request as ready for review May 13, 2026 00:22
@axelsrz axelsrz requested a review from a team as a code owner May 13, 2026 00:22
@axelsrz axelsrz merged commit 7b95cb8 into main May 13, 2026
15 checks passed
@axelsrz axelsrz deleted the users/axsuarez/teams-updates branch May 13, 2026 00:28
@MattB-msft MattB-msft linked an issue May 14, 2026 that may be closed by this pull request
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.

Teams Extension python with Teams SDK models and clients

4 participants