fix: use async with for learning context manager#1252
Merged
Conversation
the learning SDK's context manager needs to be used with `async with` when wrapping async code. using sync `with` creates a sync client but the async interceptor expects an async client for memory operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the slackbot example where the learning context manager from the agentic-learning SDK was being used incorrectly with synchronous with instead of asynchronous async with. Since the wrapped code uses await to run async operations, the async context manager is required for proper memory injection and capture.
Key changes:
- Changed
with learning(...)toasync with learning(...)in the slackbot's async agent run function - Ensures memory persistence works correctly across conversations by using the proper async client
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zzstoatzz
added a commit
that referenced
this pull request
Dec 10, 2025
Reverts commits: - 47da4ce fix: use async with for learning context manager (#1252) - 36da4c1 chore: consolidate slackbot memory on letta learning-sdk (#1250) - 30aed2d feat: integrate learning-sdk into slackbot for persistent memory (#1249) The learning SDK's async context manager has a bug where it tries to await pending tasks in __aexit__ after the event loop has already closed, causing "Event loop is closed" errors that crash the slackbot. This restores the original TurboPuffer-based user facts system until the upstream bug is fixed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 task
zzstoatzz
added a commit
that referenced
this pull request
Dec 10, 2025
Reverts commits: - 47da4ce fix: use async with for learning context manager (#1252) - 36da4c1 chore: consolidate slackbot memory on letta learning-sdk (#1250) - 30aed2d feat: integrate learning-sdk into slackbot for persistent memory (#1249) The learning SDK's async context manager has a bug where it tries to await pending tasks in __aexit__ after the event loop has already closed, causing "Event loop is closed" errors that crash the slackbot. This restores the original TurboPuffer-based user facts system until the upstream bug is fixed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The learning SDK's context manager needs to be used with
async withwhen wrapping async code. Using syncwithcreates a sync client, but the async interceptor expects an async client for memory operations.This was causing the learning SDK to silently fail - no memory was being injected or captured because the sync client doesn't work properly in an async context.
Change
Test plan
🤖 Generated with Claude Code