Skip to content

Using pick_model in conversation_reference.py - #529

Merged
Rodrigo Brandão (rodrigobr-msft) merged 2 commits into
mainfrom
users/robrandao/get-continuation-activity
Aug 7, 2026
Merged

Using pick_model in conversation_reference.py#529
Rodrigo Brandão (rodrigobr-msft) merged 2 commits into
mainfrom
users/robrandao/get-continuation-activity

Conversation

@rodrigobr-msft

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors the way continuation activities are generated from a ConversationReference, making the process more robust and flexible. The main changes involve using a utility function to construct the activity model, updating how the sender is handled, and adjusting the corresponding tests.

Refactoring and Model Construction:

  • Updated ConversationReference.get_continuation_activity to use the pick_model utility for constructing the Activity object, which improves maintainability and handles optional fields more gracefully.
  • Introduced imports for pick_model and SkipNone to support the new construction logic.

Handling of Optional Sender (user):

  • Changed the handling of the sender (from_property) so that if user is missing, the field is omitted from the resulting activity instead of raising a validation error.

Testing Adjustments:

  • Updated the test to verify that when user is missing, the sender field is omitted rather than causing an exception, reflecting the new behavior.
  • Removed unnecessary imports from the test file.

Type Checking Improvements:

  • Added TYPE_CHECKING import and conditional import of Activity for improved type hinting without causing circular imports. [1] [2]

Copilot AI lite review requested due to automatic review settings August 6, 2026 17:19

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.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Updates ConversationReference.get_continuation_activity() to use pick_model/SkipNone so the from/from_property field is omitted (unset) when user is missing, and adjusts tests accordingly.

Changes:

  • Use pick_model(Activity, ...) instead of direct Activity(...) construction.
  • Wrap from_property with SkipNone(self.user) to omit the field when user is None.
  • Update the corresponding unit test to assert omission rather than expecting a validation error.

Reviewed changes

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

File Description
tests/activity/test_conversation_reference.py Updates behavior expectations: from should be omitted when the user is missing.
libraries/microsoft-agents-activity/microsoft_agents/activity/conversation_reference.py Switches to pick_model and uses SkipNone to avoid setting from_property when user is None.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/activity/test_conversation_reference.py
Comment thread tests/activity/test_conversation_reference.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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

tests/activity/test_conversation_reference.py:51

  • _create_conversation_reference(user=None) does not actually create a reference with user=None (the helper substitutes a default ChannelAccount when user is None). This makes the test setup misleading; you can call the helper without the argument and then explicitly null out conversation_reference.user for the scenario under test.
    conversation_reference = _create_conversation_reference(user=None)

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 37c5e77 into main Aug 7, 2026
10 of 11 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/get-continuation-activity branch August 7, 2026 19:24
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