Skip to content

Improve targeted activity usage and add quoted replies - #612

Merged
Rodrigo Brandão (rodrigobr-msft) merged 10 commits into
mainfrom
users/robrandao/send-targeted
Oct 1, 2026
Merged

Rodrigo Brandão (rodrigobr-msft) merged 10 commits into
mainfrom
users/robrandao/send-targeted

Conversation

@rodrigobr-msft

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Added helper methods to Activity for retrieving single or multiple entities by type, improving code reuse and extensibility for entity management. (_get_entity_by_type, _get_entities_by_type)
  • Refactored get_mentions and get_product_info_entity to use these new helpers, simplifying their implementations. [1] [2]
  • Updated type annotations for text and request_id fields for clarity and correctness. [1] [2]

Support for Targeted and Quoted Message Entities:

  • Introduced new entity models: QuotedReply, QuotedReplyData, and TargetedMessageInfo, with corresponding files and module exports. [1] [2] [3]
  • Added with_recipient and with_targeted_recipient methods to Activity for setting recipients and marking activities as targeted, including proper entity management.

Teams Integration Improvements:

  • Added Teams-specific helpers in TeamsActivity:
    • is_recipient_targeted, get_targeted_message_info, get_quoted_messages, and add_quoted_reply for working with new entity types and quoted replies.
  • Refactored TeamsTurnContext to:
    • Normalize prompt previews and manage targeted activities using new helpers (_apply_prompt_preview_normalizer, _is_recipient_targeted). [1] [2]
    • Replace old targeted activity methods with a streamlined send_targeted_activity that leverages the new recipient and entity logic.
    • Ensure prompt preview normalization is applied when sending activities.

Sample and Documentation Updates:

  • Updated the sample agent and its documentation to demonstrate sending quoted replies and targeted messages using the new APIs. [1] [2] [3] [4]

Internal Utilities and Imports:

  • Added utility functions for prompt preview normalization and recipient targeting checks in Teams utilities.
  • Updated imports and module structure to support new models and helpers. [1] [2] [3]

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.

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) changed the title Improve TeamsTurnContext.send_targeted_activity robustness Improve targeted activity usage and add quoted replies Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 High severity · 1 Medium severity · 1 Low severity

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.

Comment thread test_samples/hosting_msteams/conversation-agent/README.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 High severity · 3 Medium severity · 3 Low severity

Open (7)

Comment thread test_samples/hosting_msteams/conversation-agent/src/agent.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) marked this pull request as ready for review October 1, 2026 20:17
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 3781dc5 into main Oct 1, 2026
10 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/send-targeted branch October 1, 2026 20:30
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.

3 participants