Skip to content

revert: remove letta learning-sdk integration#1253

Merged
zzstoatzz merged 1 commit intomainfrom
revert/letta-integration
Dec 10, 2025
Merged

revert: remove letta learning-sdk integration#1253
zzstoatzz merged 1 commit intomainfrom
revert/letta-integration

Conversation

@zzstoatzz
Copy link
Copy Markdown
Collaborator

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 to await asyncio.wait(pending_tasks, timeout=5.0) after the event loop has already closed, causing RuntimeError: Event loop is closed errors that crash the slackbot.

File "/app/.venv/lib/python3.13/site-packages/agentic_learning/core.py", line 131, in __aexit__
    await asyncio.wait(pending_tasks, timeout=5.0)
...
RuntimeError: Event loop is closed

Resolution

This restores the original TurboPuffer-based user facts system until the upstream bug in the learning-sdk is fixed.

Test plan

  • Deploy and verify slackbot responds without crashing

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings December 10, 2025 05:18
@zzstoatzz zzstoatzz merged commit a593d2b into main Dec 10, 2025
8 checks passed
@zzstoatzz zzstoatzz deleted the revert/letta-integration branch December 10, 2025 05:20
Copy link
Copy Markdown
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 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_user and delete_facts_about_user tools
  • 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}")
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

This debug print statement should be removed or replaced with proper logging using the run logger that's already available in the function scope.

Suggested change
print(f"System prompt: {system_prompt}")
logger.info(f"System prompt: {system_prompt}")

Copilot uses AI. Check for mistakes.
Comment on lines +207 to +208
print(f"Storing {len(facts)} facts about user {ctx.deps['user_id']}")
# This creates an asset dependency: USER_FACTS depends on SLACK_MESSAGES
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
@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}")
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.

Suggested change
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}")

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

These debug print statements should be replaced with proper logging using get_run_logger() for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants