-
Notifications
You must be signed in to change notification settings - Fork 3
Memory Operations
Complete guide to using the memory tool for storing and retrieving information.
The memory tool provides 9 modes for managing persistent memory:
-
add- Store new memory -
search- Find similar memories -
profile- View user profile -
list- List recent memories -
forget- Delete specific memory -
help- Display usage guide -
capture-now- Trigger manual capture -
auto-capture-toggle- Enable/disable auto-capture -
auto-capture-stats- View capture statistics
Store new information with scope and metadata.
add is deprecated. Use the User Profile System instead, which automatically learns from your prompts.
Project-scoped (still supported):
memory({
mode: "add",
content: "This project uses React 18 with Vite",
})User-scoped (deprecated):
// ❌ No longer works in v2.2+
memory({
mode: "add",
content: "User prefers TypeScript over JavaScript",
})
// Returns error: "User-scoped memories are deprecated"memory({
mode: "add",
content: "This project uses React 18 with Vite",
,
type: "architecture"
})-
mode:"add"(required) -
content: Memory content (required) -
scope:"project"only (required) -"user"deprecated in v2.2+ -
type: Memory type (optional)
Common types (flexible string):
-
preference- User preferences -
architecture- System design decisions -
workflow- Process and workflow patterns -
bug-fix- Bug solutions and fixes -
configuration- Config settings -
pattern- Code patterns and conventions -
request- User requests and requirements -
context- General context information
Project architecture:
memory({
mode: "add",
content: "API uses REST with JWT authentication",
,
type: "architecture"
})Bug fix:
memory({
mode: "add",
content: "Fixed memory leak by clearing interval in useEffect cleanup",
,
type: "bug-fix"
})User preferences (use profile system instead):
For user preferences, the system now automatically learns from your prompts. See User Profile System for details.
Find memories using vector similarity search.
memory({
mode: "search",
query: "What are my coding preferences?",
})Search both scopes:
memory({
mode: "search",
query: "authentication implementation"
})-
mode:"search"(required) -
query: Search query (required) -
scope:"user","project", or omit for both (optional)
- Uses vector similarity (cosine distance)
- Returns most relevant memories first
- Respects
similarityThresholdfrom config - Limited by
maxMemoriesandmaxProjectMemories
Find coding style:
memory({
mode: "search",
query: "code formatting preferences",
})Find project tech stack:
memory({
mode: "search",
query: "what technologies does this project use",
})Display structured user profile with preferences, patterns, workflows, and skill assessment.
🆕 New in v2.2: Profile structure completely redesigned. See User Profile System for full details.
memory({ mode: "profile" })The profile includes:
Preferences (with confidence scores):
- Code style preferences
- Communication preferences
- Tool preferences
- Evidence-backed with example prompts
Patterns (with frequency tracking):
- Recurring topics
- Problem domains
- Technical interests
Workflows:
- Development sequences
- Habits and processes
- Learning style
Skill Level:
- Overall assessment (beginner/intermediate/advanced)
- Per-domain assessments
Metadata:
- Version number
- Last analyzed timestamp
- Total prompts analyzed
-
mode:"profile"(required)
{
"success": true,
"profile": {
"preferences": [
{
"category": "Code Style",
"description": "Prefers TypeScript over JavaScript",
"confidence": 0.9,
"evidence": ["Can we use TypeScript?", "Add TS types here"],
"lastUpdated": 1736668800000
}
],
"patterns": [
{
"category": "Technical Domain",
"description": "Frequently works on authentication",
"frequency": 15,
"lastSeen": 1736668800000
}
],
"workflows": [
{
"description": "Usually asks for tests after implementation",
"steps": ["Implement feature", "Request tests", "Review coverage"],
"frequency": 10
}
],
"skillLevel": {
"overall": "intermediate",
"domains": {
"typescript": "advanced",
"docker": "beginner"
}
},
"version": 5,
"lastAnalyzed": "2026-01-12T10:30:00Z",
"totalPromptsAnalyzed": 50
}
}Old structure (v2.1 and earlier):
{
"profile": {
"static": ["fact1", "fact2"],
"dynamic": ["fact3", "fact4"]
}
}New structure (v2.2+):
{
"profile": {
"preferences": [{...}],
"patterns": [{...}],
"workflows": [{...}],
"skillLevel": {...}
}
}See User Profile System for complete migration guide.
Retrieve recent memories by scope.
memory({
mode: "list",
,
limit: 10
})-
mode:"list"(required) -
scope:"user"or"project"(required) -
limit: Number of memories (optional, default: 10)
List recent user memories:
memory({
mode: "list",
,
limit: 5
})List all project memories:
memory({
mode: "list",
,
limit: 100
})Delete a specific memory by ID.
memory({
mode: "forget",
memoryId: "mem_abc123"
})-
mode:"forget"(required) -
memoryId: Memory ID (required)
Get memory IDs from:
- List operation results
- Search operation results
- Web interface
memory({ mode: "list", limit: 5 })Output includes IDs:
1. [mem_abc123] User prefers TypeScript
2. [mem_def456] Uses React for frontend
Delete specific memory:
memory({ mode: "forget", memoryId: "mem_abc123" })Display usage guide and available modes.
memory({ mode: "help" })Shows:
- Available modes
- Parameter descriptions
- Usage examples
- Configuration tips
Manually trigger memory capture from recent conversation.
memory({ mode: "capture-now" })- Auto-capture must be configured
- API credentials must be set
- Recent conversation history available
- Analyzes recent messages
- Extracts important information
- Stores memories with appropriate scope
- Returns capture results
Enable or disable automatic memory capture.
memory({ mode: "auto-capture-toggle" })- Toggles current state (on/off)
- Returns new state
- Persists across sessions
memory({ mode: "auto-capture-toggle" })Output:
Auto-capture is now: enabled
View statistics about automatic memory capture.
memory({ mode: "auto-capture-stats" })- Total captures performed
- Total memories created
- Average memories per capture
- Last capture timestamp
- Token counts
Auto-Capture Statistics:
- Total captures: 15
- Total memories: 127
- Average per capture: 8.5
- Last capture: 2026-01-11 10:30:00
- Total tokens processed: 150,000
Be Specific:
memory({
mode: "add",
content: "User prefers 2-space indentation for TypeScript files",
})Include Context:
memory({
mode: "add",
content: "API rate limit is 100 requests per minute, implemented using Redis",
})Avoid Redundancy:
Check existing memories before adding:
memory({ mode: "search", query: "indentation preference" })User Scope - For cross-project information:
- Personal preferences
- General knowledge
- Tool preferences
- Communication style
Project Scope - For project-specific information:
- Architecture decisions
- Technology stack
- Code conventions
- Bug fixes
- Feature implementations
Use Natural Language:
memory({
mode: "search",
query: "How should I format code in this project?"
})Be Specific:
memory({
mode: "search",
query: "React component testing strategy"
})Adjust Threshold:
If getting too few results, lower similarity threshold in config:
Regular Cleanup:
Use web interface or API to remove outdated memories.
Deduplication:
Run deduplication periodically to remove similar duplicates.
Review Profile:
Check profile regularly to ensure accurate representation:
memory({ mode: "profile" })Add multiple memories:
const memories = [
{ content: "Prefers functional components" },
{ content: "Uses React hooks exclusively" },
{ content: "Avoids class components" }
]
memories.forEach(mem => memory({ mode: "add", ...mem }))Store only if not exists:
const results = memory({
mode: "search",
query: "TypeScript preference",
})
if (results.length === 0) {
memory({
mode: "add",
content: "Prefers TypeScript over JavaScript",
})
}Move memories between scopes:
const userMems = memory({ mode: "list" })
userMems.forEach(mem => {
if (mem.content.includes("project-specific")) {
memory({
mode: "add",
content: mem.content,
})
memory({ mode: "forget", memoryId: mem.id })
}
})Missing Required Parameters:
memory({ mode: "add" })Error: content and scope are required
Invalid Scope:
memory({ mode: "add", content: "test", scope: "invalid" })Error: scope must be 'user' or 'project'
Memory Not Found:
memory({ mode: "forget", memoryId: "invalid_id" })Error: Memory not found
The tool validates:
- Required parameters
- Parameter types
- Scope values
- Memory ID format
- Web Interface - Manage memories visually
- Auto-Capture System - Automatic extraction
- Configuration Guide - Customize behavior
{ "similarityThreshold": 0.5 }