-
Notifications
You must be signed in to change notification settings - Fork 505
docs: Update Python cookbook examples #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Convert all 5 recipe examples to async/await patterns matching current SDK interface * error_handling.py: Async/await conversion with proper event handling * managing_local_files.py: Async conversion with non-blocking user input * multiple_sessions.py: Full async/await conversion with proper cleanup * persisting_sessions.py: Async/await conversion with session management updates * pr_visualization.py: Async conversion with async subprocess handling Root cause: SDK interface changed from synchronous to asynchronous (async/await) API. All examples now use correct async patterns with proper error handling and cleanup."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts five Python cookbook recipe examples from synchronous to asynchronous patterns to align with the current SDK's async/await API. The SDK interface has migrated from synchronous methods to async methods, requiring all client operations, session management, and message sending to use async/await patterns.
Changes:
- Converted all SDK method calls to async/await (client.start(), create_session(), send_and_wait(), destroy(), stop())
- Updated event handling from dictionary access to dataclass attribute access (event.type, event.data)
- Added proper async cleanup patterns with try/finally blocks
- Implemented non-blocking user input using asyncio.get_event_loop().run_in_executor()
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| cookbook/python/recipe/pr_visualization.py | Converted PR analysis tool to async with event loop-based user input, async session management, and proper cleanup |
| cookbook/python/recipe/persisting_sessions.py | Converted session persistence example to async, documenting unavailable list_sessions/delete_session methods |
| cookbook/python/recipe/multiple_sessions.py | Converted multi-session example to async with sequential session creation and proper cleanup |
| cookbook/python/recipe/managing_local_files.py | Converted file management example to async with non-blocking user input loop |
| cookbook/python/recipe/error_handling.py | Converted error handling example to async with proper exception handling and cleanup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…g and managing local files
There was a problem hiding this comment.
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 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RbBtSn0w
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing need update.
|
@aaronpowell do you mind taking a look? |
Root cause: SDK interface changed from synchronous to asynchronous (async/await) API. All examples now use correct async patterns with proper error handling and cleanup."