@@ -350,6 +350,48 @@ def test_should_remove_at_mention_with_regex_characters(self):
350350 assert text == " test activity"
351351 assert activity .text == " test activity"
352352
353+ def test_should_remove_custom_mention_from_activity (self ):
354+ activity = Activity (
355+ text = "Hallo" ,
356+ text_format = "plain" ,
357+ type = "message" ,
358+ timestamp = "2025-03-11T14:16:47.0093935Z" ,
359+ id = "1741702606984" ,
360+ channel_id = "msteams" ,
361+ service_url = "https://smba.trafficmanager.net/emea/REDACTED/" ,
362+ from_property = ChannelAccount (
363+ id = "29:1J-K4xVh-sLpdwQ-R5GkOZ_TB0W3ec_37p710aH8qe8bITA0zxdgIGc9l-MdDdkdE_jasSfNOeWXyyL1nsrHtBQ" ,
364+ name = "" ,
365+ aad_object_id = "REDACTED" ,
366+ ),
367+ conversation = ConversationAccount (
368+ is_group = True ,
369+ conversation_type = "groupChat" ,
370+ tenant_id = "REDACTED" ,
371+ 372+ ),
373+ recipient = ChannelAccount (
374+ id = "28:c5d5fb56-a1a4-4467-a7a3-1b37905498a0" , name = "Azure AI Agent"
375+ ),
376+ entities = [
377+ Entity ().deserialize (
378+ Mention (
379+ type = "mention" ,
380+ mentioned = ChannelAccount (
381+ id = "28:c5d5fb56-a1a4-4467-a7a3-1b37905498a0" ,
382+ name = "Custom Agent" ,
383+ ),
384+ ).serialize ()
385+ )
386+ ],
387+ channel_data = {"tenant" : {"id" : "REDACTED" }, "productContext" : "COPILOT" },
388+ )
389+
390+ text = TurnContext .remove_mention_text (activity , activity .recipient .id )
391+
392+ assert text == "Hallo"
393+ assert activity .text == "Hallo"
394+
353395 async def test_should_send_a_trace_activity (self ):
354396 context = TurnContext (SimpleAdapter (), ACTIVITY )
355397 called = False
0 commit comments