From 6fbbc5204e63a304d0196e3e66ddf401ddb77380 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 10:51:21 +1100 Subject: [PATCH] Fix ImportError: SessionEventType not exported from copilot public API (#1093) * Initial plan * Fix ImportError: remove SessionEventType from copilot imports, use string comparisons Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/awesome-copilot/sessions/0c514b95-5157-4aa9-8590-cbf3fd337472 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com> --- cookbook/copilot-sdk/python/accessibility-report.md | 6 +++--- cookbook/copilot-sdk/python/managing-local-files.md | 8 ++++---- cookbook/copilot-sdk/python/pr-visualization.md | 6 +++--- .../copilot-sdk/python/recipe/accessibility_report.py | 4 ++-- .../copilot-sdk/python/recipe/managing_local_files.py | 8 ++++---- cookbook/copilot-sdk/python/recipe/pr_visualization.py | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cookbook/copilot-sdk/python/accessibility-report.md b/cookbook/copilot-sdk/python/accessibility-report.md index 3d67a5fa..ad22c671 100644 --- a/cookbook/copilot-sdk/python/accessibility-report.md +++ b/cookbook/copilot-sdk/python/accessibility-report.md @@ -36,7 +36,7 @@ python accessibility_report.py import asyncio from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -80,7 +80,7 @@ async def main(): # Set up streaming event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() @@ -198,7 +198,7 @@ Unlike `send_and_wait`, this recipe uses streaming for real-time output: ```python def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/managing-local-files.md b/cookbook/copilot-sdk/python/managing-local-files.md index a9e4e35f..f1e78b02 100644 --- a/cookbook/copilot-sdk/python/managing-local-files.md +++ b/cookbook/copilot-sdk/python/managing-local-files.md @@ -20,7 +20,7 @@ import asyncio import os from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) async def main(): @@ -35,11 +35,11 @@ async def main(): # Event handler def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nCopilot: {event.data.content}") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" → Running: {event.data.tool_name}") - elif event.type == SessionEventType.TOOL_EXECUTION_COMPLETE: + elif event.type.value == "tool.execution_complete": print(f" āœ“ Completed: {event.data.tool_call_id}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/pr-visualization.md b/cookbook/copilot-sdk/python/pr-visualization.md index 0b158e4a..2e3d108b 100644 --- a/cookbook/copilot-sdk/python/pr-visualization.md +++ b/cookbook/copilot-sdk/python/pr-visualization.md @@ -45,7 +45,7 @@ import os import re from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -157,9 +157,9 @@ The current working directory is: {os.getcwd()} # Set up event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nšŸ¤– {event.data.content}\n") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" āš™ļø {event.data.tool_name}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/accessibility_report.py b/cookbook/copilot-sdk/python/recipe/accessibility_report.py index c5e0b6c9..69ca6468 100644 --- a/cookbook/copilot-sdk/python/recipe/accessibility_report.py +++ b/cookbook/copilot-sdk/python/recipe/accessibility_report.py @@ -3,7 +3,7 @@ import asyncio from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -47,7 +47,7 @@ async def main(): # Set up streaming event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: + if event.type.value == "assistant.message_delta": print(event.data.delta_content or "", end="", flush=True) elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/managing_local_files.py b/cookbook/copilot-sdk/python/recipe/managing_local_files.py index c0381170..f57bafcb 100644 --- a/cookbook/copilot-sdk/python/recipe/managing_local_files.py +++ b/cookbook/copilot-sdk/python/recipe/managing_local_files.py @@ -4,7 +4,7 @@ import asyncio import os from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) async def main(): @@ -19,11 +19,11 @@ async def main(): # Event handler def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nCopilot: {event.data.content}") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" → Running: {event.data.tool_name}") - elif event.type == SessionEventType.TOOL_EXECUTION_COMPLETE: + elif event.type.value == "tool.execution_complete": print(f" āœ“ Completed: {event.data.tool_call_id}") elif event.type.value == "session.idle": done.set() diff --git a/cookbook/copilot-sdk/python/recipe/pr_visualization.py b/cookbook/copilot-sdk/python/recipe/pr_visualization.py index 9ece3f93..ace1a8a1 100644 --- a/cookbook/copilot-sdk/python/recipe/pr_visualization.py +++ b/cookbook/copilot-sdk/python/recipe/pr_visualization.py @@ -7,7 +7,7 @@ import os import re from copilot import ( CopilotClient, SessionConfig, MessageOptions, - SessionEvent, SessionEventType, + SessionEvent, ) # ============================================================================ @@ -119,9 +119,9 @@ The current working directory is: {os.getcwd()} # Set up event handling def handle_event(event: SessionEvent): - if event.type == SessionEventType.ASSISTANT_MESSAGE: + if event.type.value == "assistant.message": print(f"\nšŸ¤– {event.data.content}\n") - elif event.type == SessionEventType.TOOL_EXECUTION_START: + elif event.type.value == "tool.execution_start": print(f" āš™ļø {event.data.tool_name}") elif event.type.value == "session.idle": done.set()