Improve targeted activity usage and add quoted replies - #612
Conversation
TeamsTurnContext.send_targeted_activity robustnessThere was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Target recipients are overwritten during sending, and the public targeted-activity API introduces undocumented breaking changes.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Adds Teams targeted messaging, prompt previews, and quoted replies across activity models, hosting APIs, connector transport, samples, and tests.
Changes:
- Adds recipient targeting and entity lookup helpers.
- Adds quoted-reply and targeted-message models.
- Updates Teams sending behavior, samples, and coverage.
| File | Description |
|---|---|
tests/hosting_msteams/test_teams_turn_context.py |
Tests targeted sending and prompt previews. |
tests/hosting_msteams/test_teams_activity.py |
Tests new Teams activity helpers. |
tests/hosting_core/connector/test_connector_client.py |
Tests targeted query parameters. |
tests/activity/test_activity_builders.py |
Tests recipient builders. |
test_samples/hosting_msteams/conversation-agent/src/agent.py |
Demonstrates quoted and targeted messages. |
test_samples/hosting_msteams/conversation-agent/README.md |
Updates sample documentation. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/teams_turn_context.py |
Adds preview and targeted-send behavior. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/teams_activity.py |
Adds quoted-reply helpers. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/models/targeted_message_info.py |
Defines targeted-message metadata. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/models/quoted_reply.py |
Defines quoted-reply models. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/models/__init__.py |
Exports new models. |
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_utils.py |
Normalizes prompt previews. |
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/connector/client/connector_client.py |
Adds targeted Teams query parameters. |
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/_oauth/_oauth_flow.py |
Handles absent activity text. |
libraries/microsoft-agents-activity/microsoft_agents/activity/activity.py |
Adds targeting and entity helpers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Targeted delivery misses Teams subchannels, recipient preservation is inconsistent, and removing the batch API breaks existing callers.
Review effort: Balanced
Findings: 1
Open (7)
Explicit recipient is overwritten before sending Preserve targeted recipients in conversation reference application · New Normalize Teams subchannels before targeting comparison · New Public targeted-send API change breaks existing applications Fix routing explanation typo and plural mismatch · New Format sample code and remove trailing whitespace · New Quoted-reply command missing from documentation and welcome card
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Targeted inbound replies may become public, and a documented bulk API is removed without compatibility handling.
Review effort: Balanced
Findings: 1
Resolved since last review (7)
Explicit recipient is overwritten before sending Normalize Teams subchannels before targeting comparison Preserve targeted recipients in conversation reference application Public targeted-send API change breaks existing applications Format sample code and remove trailing whitespace Fix routing explanation typo and plural mismatch Quoted-reply command missing from documentation and welcome card



This pull request introduces significant enhancements to the Microsoft Agents SDK for Teams, focusing on improved support for targeted and quoted message handling in activities. It adds new models for quoted replies and targeted message metadata, refactors activity entity handling for extensibility, and updates Teams integration points to leverage these capabilities. Sample code and documentation are also updated to demonstrate and explain these new features.
Enhancements to Activity Entity Handling:
Activityfor retrieving single or multiple entities by type, improving code reuse and extensibility for entity management. (_get_entity_by_type,_get_entities_by_type)get_mentionsandget_product_info_entityto use these new helpers, simplifying their implementations. [1] [2]textandrequest_idfields for clarity and correctness. [1] [2]Support for Targeted and Quoted Message Entities:
QuotedReply,QuotedReplyData, andTargetedMessageInfo, with corresponding files and module exports. [1] [2] [3]with_recipientandwith_targeted_recipientmethods toActivityfor setting recipients and marking activities as targeted, including proper entity management.Teams Integration Improvements:
TeamsActivity:is_recipient_targeted,get_targeted_message_info,get_quoted_messages, andadd_quoted_replyfor working with new entity types and quoted replies.TeamsTurnContextto:_apply_prompt_preview_normalizer,_is_recipient_targeted). [1] [2]send_targeted_activitythat leverages the new recipient and entity logic.Sample and Documentation Updates:
Internal Utilities and Imports:
These changes collectively make it easier to work with advanced Teams messaging features, such as quoted replies and targeted/private messages, and provide a more robust foundation for future extensibility.