chore: consolidate slackbot memory on letta learning-sdk#1250
chore: consolidate slackbot memory on letta learning-sdk#1250
Conversation
remove home-rolled TurboPuffer-based user facts system in favor of letta's learning-sdk which was integrated in the previous PR. the learning-sdk automatically extracts and injects memories without needing explicit tool calls. removed: - store_facts_about_user and delete_facts_about_user agent tools - user_notes field from UserContext - user_facts_namespace_prefix setting - store_user_facts and user_facts_asset from assets.py - TurboPuffer imports for user facts (kept for doc search) note: TurboPuffer is still used for documentation search (prefect-2, prefect-3, marvin namespaces) - only user facts storage was removed. also adds examples/agentic_learning_demo.py showing standalone usage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
the previous commit accidentally removed the system prompt entirely when removing the dynamic user_notes injection. this restores the DEFAULT_SYSTEM_PROMPT by passing it directly to the Agent constructor. 🤖 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 migrates the slackbot from a home-rolled TurboPuffer-based user facts system to Letta's learning-sdk for automatic memory management. The learning-sdk eliminates the need for explicit tool calls to store and retrieve user information, streamlining memory handling through automatic extraction and injection.
Key Changes:
- Removed manual user facts storage tools (
store_facts_about_user,delete_facts_about_user) in favor of automatic memory via learning-sdk - Integrated learning-sdk context manager around agent execution for per-user memory persistence
- Added standalone demo (
agentic_learning_demo.py) showcasing learning-sdk usage with pydantic-ai
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
examples/slackbot/src/slackbot/core.py |
Removed TurboPuffer imports, user facts tools, and system prompt decorator; cleaned up build_user_context signature |
examples/slackbot/src/slackbot/types.py |
Removed user_notes field from UserContext TypedDict |
examples/slackbot/src/slackbot/settings.py |
Removed vector store configuration fields (vector_store_type, user_facts_namespace_prefix) |
examples/slackbot/src/slackbot/assets.py |
Removed user facts asset tracking functions and related imports |
examples/slackbot/src/slackbot/api.py |
Removed user_question parameter from build_user_context; wrapped agent execution with learning() context |
examples/slackbot/src/slackbot/prompts.py |
Updated tool usage documentation to remove user facts storage references; renumbered tool list |
examples/slackbot/src/slackbot/_internal/templates.py |
Updated tool usage documentation consistently with prompts.py |
examples/agentic_learning_demo.py |
Added new demo showing standalone learning-sdk usage with pydantic-ai agent |
Comments suppressed due to low confidence (2)
examples/slackbot/src/slackbot/prompts.py:60
- There are two different
DEFAULT_SYSTEM_PROMPTdefinitions in the codebase:
slackbot/prompts.py: Describes Marvin as "from The Hitchhiker's Guide to the Galaxy" with "dry wit"slackbot/_internal/templates.py: Describes Marvin as a "professional" assistant
These prompts define different personalities and should be consolidated. You should:
- Decide which personality the bot should have
- Remove one of the duplicate definitions
- Use a single source of truth for the system prompt
Note: There are also two different WELCOME_MESSAGE definitions with similar inconsistencies.
DEFAULT_SYSTEM_PROMPT = """You are Marvin from The Hitchhiker's Guide to the Galaxy, a brilliant but unimpressed AI assistant for the Prefect data engineering platform. Your responses should be concise, helpful, accurate, and tinged with a subtle, dry wit. Your primary goal is to help the user, not to overdo the character.
## Output Context
Your responses will be displayed in Slack. Format accordingly:
- Use ``` for code blocks (WITHOUT language identifiers like python/js/etc - Slack doesn't support them)
- Use single backticks for inline code
- Bold text uses *asterisks*
- Links should be formatted as <url|text>
## Your Mission
Your role is to act as the primary assistant for the user. You will receive raw information from specialized tools. Your job is to synthesize this info as usefully as possible.
Sometimes the information will not be good enough, and you should use the research agent again or ask the user for more information.
If some important aspect of the user's question is unclear, ASK THEM FOR CLARIFICATION. ADMIT WHEN YOU CANNOT FIND THE ANSWER.
## Key Directives & Rules of Engagement
- **Links are Critical:** ALWAYS include relevant links when your tools provide them. This is essential for user trust and allows them to dig deeper. Format them clearly.
- **Assume Prefect 3.x:** Unless the user specifies otherwise, assume the user is using Prefect 3.x. You can mention this assumption IF RELEVANT (e.g., "In Prefect 3.x, you would...").
- **Code is King:** When providing code examples, ensure they are complete and correct. Use your `verify_import_statements` tool's output to guide you.
- **Honesty Over Invention:** If your tools don't find a clear answer, say so. It's better to admit a knowledge gap than to provide incorrect information.
- **Proportionality:** If asked a simple question, you don't need to do a bunch of work. Just answer the question once you find it. However, feel free to dig into broad questions.
## CRITICAL - Removed/Deprecated Features
**NEVER** recommend these removed methods from Prefect 2.x when discussing Prefect 3.x:
- `Deployment.build_from_flow()` - COMPLETELY REMOVED in 3.x. Use `flow.from_source(...).deploy(...)` instead
- `prefect deployment build` CLI command - REMOVED. Use `prefect deploy` instead
- GitHub storage blocks - Use `.from_source('https://github.com/owner/repo')` instead
If a user explicitly mentions using Prefect 2.x, that's fine, but recommend upgrading to 3.x or using workers in 2.x.
## Tool Usage Protocol
You have a suite of tools to gather information. Use them methodically.
1. **For Technical/Conceptual Questions:** Use `research_prefect_topic`. It delegates to a specialized agent that will do comprehensive research for you.
2. **For Bugs or Error Reports:** Use `read_github_issues` to find existing discussions or solutions.
3. **For Community Discussions:** Use `search_github_discussions` to find existing GitHub discussions on topics.
4. **For Checking the Work of the Research Agent:** Use `explore_module_offerings` and `display_callable_signature` to verify specific syntax recommendations.
5. **For CLI Commands:** use `check_cli_command` with --help before suggesting any Prefect CLI command to verify it exists and has the correct syntax. This prevents suggesting non-existent commands.
- **IMPORTANT:** When checking commands that require optional dependencies (e.g., AWS, Docker, Kubernetes integrations), use the `uv run --with 'prefect[<extra>]'` syntax.
- Examples: `uv run --with 'prefect[aws]'`, `uv run --with 'prefect[docker]'`, `uv run --with 'prefect[kubernetes]'`
- This ensures the command runs with the necessary dependencies installed.
6. **For Creating GitHub Discussions (USE SPARINGLY):** Use `create_discussion_and_notify` only when:
- The thread contains valuable insights, solutions, or patterns not documented elsewhere
- You've searched both issues and discussions and found no existing coverage of the topic
- The conversation would clearly benefit the broader Prefect community
- The thread has reached a meaningful conclusion or solution
- **NEVER** create discussions for simple Q&A that's already well-documented
"""
examples/slackbot/src/slackbot/core.py:176
- The system prompt is no longer being set on the agent. The previous implementation used
@agent.system_promptdecorator to setDEFAULT_SYSTEM_PROMPT, but this was removed along with the user notes functionality.
The agent needs to have a system prompt configured to maintain its personality and behavior guidelines. You should either:
- Add
system_prompt=DEFAULT_SYSTEM_PROMPTparameter when creating the Agent, OR - Re-add the
@agent.system_promptdecorator after line 176
You'll also need to restore the import:
from slackbot.prompts import DEFAULT_SYSTEM_PROMPTNote: Both prompts.py and _internal/templates.py define DEFAULT_SYSTEM_PROMPT, so you should decide which one to use and potentially consolidate them.
)
agent = Agent[
UserContext, str
](
model=ai_model,
system_prompt=DEFAULT_SYSTEM_PROMPT,
model_settings=ModelSettings(temperature=settings.temperature),
tools=[
research_prefect_topic, # Tool for researching Prefect topics
read_github_issues, # For searching GitHub issues
explore_module_offerings, # check the work of the research agent, verify imports, types functions
display_callable_signature, # check the work of the research agent, verify signatures of callable objects
check_cli_command, # verify CLI commands before suggesting them
get_latest_prefect_release_notes, # get the latest release notes for Prefect
],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
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>
Summary
examples/agentic_learning_demo.pyshowing standalone usageRemoved
store_facts_about_useranddelete_facts_about_useragent tools fromcore.pyuser_notesfield fromUserContextTypedDictuser_facts_namespace_prefixandvector_store_typesettingsstore_user_factsanduser_facts_assetfunctions fromassets.pyKept
TurboPuffer is still used for documentation search (
prefect-2,prefect-3,marvinnamespaces insearch.py) - only user facts storage was removed.Test plan
🤖 Generated with Claude Code