Skip to content

Conversation

@RbBtSn0w
Copy link

  • 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."

- 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."
@RbBtSn0w RbBtSn0w requested a review from a team as a code owner January 23, 2026 08:35
Copilot AI review requested due to automatic review settings January 23, 2026 08:35
Copy link
Contributor

Copilot AI left a 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.

RbBtSn0w and others added 5 commits January 23, 2026 16:58
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>
Copy link
Contributor

Copilot AI left a 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.

Copy link
Author

@RbBtSn0w RbBtSn0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing need update.

@friggeri
Copy link
Collaborator

@aaronpowell do you mind taking a look?

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.

2 participants