memory management
1
总安装量
0
周安装量
#47610
全站排名
安装命令
npx skills add https://github.com/lauraflorentin/skills-marketplace --skill Memory Management
Skill 文档
Memory Management
Memory management provides agents with a “brain” that persists beyond the current context window. It involves storing user preferences, conversation history, and factual knowledge in a database (like a Vector DB or SQL) and retrieving relevant information when needed. Without memory, an agent is amnesic, resetting after every session.
When to Use
- Personalization: Remembering user names, preferences, and past choices.
- Long-Running Tasks: Tracking progress on a project that spans days or weeks.
- Context Awareness: Understanding references to previous conversations (“As I mentioned earlier…”).
- Learning: Improving performance by recalling past mistakes or feedback.
Use Cases
- Chatbots: Maintaining conversation history for context (Short-term memory).
- User Profiles: Storing “User is a vegetarian” in a profile database (Long-term memory).
- Knowledge Base: Accumulating facts learned from searching the web (Episodic memory).
Implementation Pattern
class Memory:
def add(self, content):
# Store in Vector DB or SQL
pass
def retrieve(self, query):
# Search for relevant memories
pass
def memory_augmented_agent(user_input, user_id):
# Step 1: Recall
# Retrieve relevant history and user facts
context = memory.retrieve(query=user_input, tags=[user_id])
# Step 2: Augment Prompt
prompt = f"""
Context from memory: {context}
User Input: {user_input}
Answer the user, taking into account their history.
"""
# Step 3: Generate
response = llm.generate(prompt)
# Step 4: Memorize
# Store the new interaction
memory.add(f"User: {user_input} | Agent: {response}")
return response