From a7423de84e0753ac4f39830343874083a5919f7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Estevan Date: Thu, 17 Jul 2025 15:25:18 +0200 Subject: [PATCH 1/2] Deserializing some CopSt responses provide an empty string causing parsing error. May require further investigation. --- .../agents/copilotstudio/client/copilot_client.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py index 392af90d..745cdd7f 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py @@ -41,12 +41,13 @@ async def post_request( event_type = line[6:].decode("utf-8").strip() if line.startswith(b"data:") and event_type == "activity": activity_data = line[5:].decode("utf-8").strip() - activity = Activity.model_validate_json(activity_data) - - if activity.type == ActivityTypes.message: - self._current_conversation_id = activity.conversation.id - - yield activity + try: + activity = Activity.model_validate_json(activity_data) + if activity.type == ActivityTypes.message: + self._current_conversation_id = activity.conversation.id + yield activity + except Exception as e: + print(f"Error parsing activity: {e} - {activity_data}") async def start_conversation( self, emit_start_conversation_event: bool = True From 53c65ae91e72db56e85a0c125c00b779d3b0ff29 Mon Sep 17 00:00:00 2001 From: Jose Antonio Estevan Date: Thu, 17 Jul 2025 17:10:32 +0200 Subject: [PATCH 2/2] Format correction from black --- .../microsoft/agents/copilotstudio/client/copilot_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py index 745cdd7f..f9c22230 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/copilot_client.py @@ -47,7 +47,7 @@ async def post_request( self._current_conversation_id = activity.conversation.id yield activity except Exception as e: - print(f"Error parsing activity: {e} - {activity_data}") + print(f"Error parsing activity: {e} - {activity_data}") async def start_conversation( self, emit_start_conversation_event: bool = True