revert: remove letta learning-sdk integration#1253
Conversation
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>
There was a problem hiding this comment.
Pull request overview
This PR reverts the Letta learning-sdk integration that was causing production crashes due to an async context manager bug. The revert restores the original TurboPuffer-based user facts system for persistent memory management.
Key changes:
- Removed agentic-learning dependency and its async context manager wrapper
- Re-implemented TurboPuffer-based user facts storage with
store_facts_about_useranddelete_facts_about_usertools - Updated system prompts to include user notes retrieval in context
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Removed uv prerelease configuration that was needed for learning-sdk |
| examples/slackbot/pyproject.toml | Removed agentic-learning dependency |
| examples/slackbot/src/slackbot/types.py | Added user_notes field to UserContext |
| examples/slackbot/src/slackbot/settings.py | Replaced Letta API configuration with TurboPuffer vector store settings |
| examples/slackbot/src/slackbot/core.py | Re-added TurboPuffer-based fact storage/deletion tools and system prompt customization |
| examples/slackbot/src/slackbot/assets.py | Implemented user_facts_asset and store_user_facts function for TurboPuffer integration |
| examples/slackbot/src/slackbot/api.py | Removed learning context manager wrapper and updated build_user_context call |
| examples/slackbot/src/slackbot/prompts.py | Updated tool usage documentation to reference new fact storage tools |
| examples/slackbot/src/slackbot/_internal/templates.py | Updated tool usage documentation (duplicate of prompts.py) |
| examples/agentic_learning_demo.py | Deleted demo file for the now-removed learning-sdk |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ctx.deps["user_notes"] | ||
| else "" | ||
| ) | ||
| print(f"System prompt: {system_prompt}") |
There was a problem hiding this comment.
This debug print statement should be removed or replaced with proper logging using the run logger that's already available in the function scope.
| print(f"System prompt: {system_prompt}") | |
| logger.info(f"System prompt: {system_prompt}") |
| print(f"Storing {len(facts)} facts about user {ctx.deps['user_id']}") | ||
| # This creates an asset dependency: USER_FACTS depends on SLACK_MESSAGES |
There was a problem hiding this comment.
These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.
| @agent.tool | ||
| def delete_facts_about_user(ctx: RunContext[UserContext], related_to: str) -> str: | ||
| """Delete facts about the user related to a specific topic.""" | ||
| print(f"forgetting stuff about {ctx.deps['user_id']} related to {related_to}") |
There was a problem hiding this comment.
These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.
| print(f"forgetting stuff about {ctx.deps['user_id']} related to {related_to}") | |
| get_run_logger().info(f"forgetting stuff about {ctx.deps['user_id']} related to {related_to}") |
| ids = [str(v.id) for v in vector_result.rows or []] | ||
| tpuf.delete(ids) | ||
| message = f"Deleted {len(ids)} facts about user {user_id}" | ||
| print(message) |
There was a problem hiding this comment.
These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.
Summary
Reverts the Letta learning-sdk integration due to a bug causing production crashes.
Reverted commits:
Root cause
The learning SDK's async context manager has a bug in
__aexit__where it tries toawait asyncio.wait(pending_tasks, timeout=5.0)after the event loop has already closed, causingRuntimeError: Event loop is closederrors that crash the slackbot.Resolution
This restores the original TurboPuffer-based user facts system until the upstream bug in the learning-sdk is fixed.
Test plan
🤖 Generated with Claude Code