Skip to main content

Memory Operations

Master storing, recalling, and managing memories with MEMANTO.

Memory Fundamentals

What is a Memory?

A memory in MEMANTO contains:
  • Content - The actual information (required)
  • Type - Semantic category (fact, preference, decision, etc.)
  • Title - Short descriptor (optional)
  • Confidence - How sure we are (0-1, default 1.0)
  • Metadata - Custom tags or attributes (optional)

Memory Lifecycle

Store → Index (instant) → Recall by Query → Update/Validate → Archive

Storing Memories (Remember)

Single Memory - CLI

Store a simple fact:
memanto remember "Paris is the capital of France" --type fact
Output:
✓ Memory stored successfully
Memory ID: mem_abc123xyz
Type: fact
Status: queued

With Title and Metadata

memanto remember \
  "Alice prefers dark mode" \
  --type preference \
  --title "UI Preference"

All Memory Types

# Fact - objective information
memanto remember "Python 3.11 is installed" --type fact

# Preference - likes/dislikes
memanto remember "Prefers JSON over XML" --type preference

# Decision - choices made
memanto remember "Chose PostgreSQL for DB" --type decision

# Commitment - promises made
memanto remember "Will deliver API docs by Friday" --type commitment

# Goal - objectives
memanto remember "Reach 10K users" --type goal

# Event - something that happened
memanto remember "Team meeting completed successfully" --type event

# Instruction - rules to follow
memanto remember "Always validate user input" --type instruction

# Relationship - connections
memanto remember "Alice manages Bob" --type relationship

# Context - contextual info
memanto remember "We're in Q1 planning" --type context

# Learning - lessons learned
memanto remember "Users need better onboarding" --type learning

# Observation - what you noticed
memanto remember "Traffic peaks on Fridays" --type observation

# Error - mistakes to avoid
memanto remember "Avoid using deprecated API" --type error

# Artifact - important documents
memanto remember "Q3 budget spreadsheet" --type artifact

Batch Store - CLI

Store multiple memories from JSON file: Create memories.json:
[
  {"content": "Alice Johnson", "type": "fact"},
  {"content": "Works in Finance", "type": "fact"},
  {"content": "Prefers email", "type": "preference"},
  {"content": "PST timezone", "type": "fact"}
]
Store:
memanto remember --batch memories.json
Output:
✓ Batch stored successfully
Stored 4 memories
Memory IDs: mem_1, mem_2, mem_3, mem_4

Via REST API

Single memory:
response = httpx.post(
    "http://localhost:8000/api/v2/agents/{agent_id}/remember",
    params={
        "memory_type": "fact",
        "title": "Geography",
        "content": "Paris is the capital of France",
        "confidence": 1.0
    },
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
memory = response.json()
print(f"Stored: {memory['memory_id']}")
Batch memories:
memories = [
    {"content": "Alice Johnson", "type": "fact"},
    {"content": "Prefers email", "type": "preference"},
    {"content": "PST timezone", "type": "fact"}
]

response = httpx.post(
    "http://localhost:8000/api/v2/agents/{agent_id}/batch-remember",
    json={"memories": memories},
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
data = response.json()
print(f"Stored {len(data['memory_ids'])} memories")

Recalling Memories (Recall)

Semantic Search - CLI

Recall memories using natural language queries:
memanto recall "What do I know about the user's preferences?"
Output:
Found 2 memories:

1. Prefers email communication
   Type: preference
   Confidence: 0.98
   Created: 2025-03-30 16:30:00 UTC

2. Wants concise responses
   Type: preference
   Confidence: 0.95
   Created: 2025-03-30 16:31:00 UTC

Filter by Memory Type

memanto recall "How to contact user" --type preference
Only returns preference-type memories.

Limit Results

memanto recall "What about the customer" --limit 10
Default is 5, max is 100.

Via REST API

response = httpx.get(
    f"http://localhost:8000/api/v2/agents/{agent_id}/recall",
    params={
        "query": "How to contact the user?",
        "limit": 5
    },
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
data = response.json()
for memory in data['memories']:
    print(f"- {memory['content']} ({memory['type']})")

Temporal Queries

Query memories from specific time periods.

Recall as of Specific Time - CLI

memanto recall "user preferences" --as-of "2025-03-28T14:00:00Z"
Shows state of memories as they were at that time.

Changed Since - CLI

memanto recall "customer info" --changed-since "2025-03-28"
Returns only memories created or modified since that date.

Current Only - CLI

memanto recall "commitments" --current-only
Returns only currently valid memories (not superseded).

Via REST API

As of specific time:
response = httpx.get(
    f"http://localhost:8000/api/v2/agents/{agent_id}/recall/as-of",
    params={
        "query": "user preferences",
        "as_of": "2025-03-28T14:00:00Z"
    },
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
Changed since:
response = httpx.get(
    f"http://localhost:8000/api/v2/agents/{agent_id}/recall/changed-since",
    params={
        "query": "customer info",
        "changed_since": "2025-03-28"
    },
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
Current only:
response = httpx.get(
    f"http://localhost:8000/api/v2/agents/{agent_id}/recall/current",
    params={"query": "commitments"},
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)

Grounded QA (Answer)

Get AI-powered answers grounded in memories.

CLI Method

memanto answer "Based on what I remember, how should we communicate with the user?"
Output:
Based on your memories:

The user prefers email communication and is in the PST timezone.
You should send email during business hours PST (8am-5pm PST).
The user appreciates concise responses, so keep communications brief.

Via REST API

response = httpx.post(
    f"http://localhost:8000/api/v2/agents/{agent_id}/answer",
    params={"question": "How should we communicate with the user?"},
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)
answer = response.json()["answer"]
print(answer)

Contradiction Detection

Find Contradictions - CLI

memanto conflicts
Output:
Potential Conflicts Detected

Conflict 1:
Memory A: "Alice works in Finance" (created 2025-03-20)
Memory B: "Alice works in Marketing" (created 2025-03-28)
Confidence: 0.92 (likely conflict)

Recommendation: Update or delete one memory

Resolve Conflicts Interactively

memanto conflicts
When conflicts are found:
Choose action:
[1] Mark Memory A as outdated
[2] Mark Memory B as outdated
[3] Keep both (different interpretations)
[4] Type custom resolution

Choose: 1
✓ Memory A marked as outdated

Via REST API

response = httpx.post(
    f"http://localhost:8000/api/v2/agents/{agent_id}/contradict/{memory_id}",
    json={"resolution": "Mark as outdated"},
    headers={
        "Authorization": f"Bearer {api_key}",
        "X-Session-Token": session_token
    }
)

Exporting Memories

Export to Markdown

memanto memory export
Creates a file with all memories in markdown format at ~/.memanto/exports/agent_memory.md:
# Agent: customer-support

## Facts
- Paris is the capital of France (2025-03-30 16:30:00)
- Alice works in Finance (2025-03-25 10:15:00)

## Preferences
- Prefers email communication (2025-03-26 09:00:00)
- Wants concise responses (2025-03-27 14:22:00)

## Commitments
- Will deliver report by Friday (2025-03-29 10:00:00)

Export to Custom Output Path

memanto memory export --output /path/to/memory.md
Creates a file with all memories in markdown format at the specified output path.

Sync to MEMORY.md

Import memories into a project’s MEMORY.md file:
memanto memory sync
This syncs memories into MEMORY.md for integration with Claude Code and other tools.

Performance Tips

1. Use Specific Memory Types

Instead of storing everything as “fact”, use specific types:
# Good - specific type
memanto remember "Alice prefers email" --type preference

# Less specific - generic type
memanto remember "Alice prefers email" --type fact

2. Batch Store When Possible

Storing 100 memories at once is faster than 100 individual calls:
memanto remember --batch large_batch.json

3. Query with Appropriate Limits

Don’t retrieve more than you need:
# Good - specific limit
memanto recall "customer info" --limit 5

# Wasteful - too many results
memanto recall "customer info" --limit 100

4. Use Confidence Scoring

Store confidence levels to filter by reliability:
response = httpx.post(
    "http://localhost:8000/api/v2/agents/{agent_id}/remember",
    params={
        "content": "Alice's favorite color is blue",
        "type": "preference",
        "confidence": 0.85  # Somewhat confident
    },
    headers={...}
)
Then query only high-confidence memories:
memanto recall "preferences" --min-confidence 0.9

Best Practices

DO

  • Use specific memory types for better organization
  • Store metadata for context
  • Regularly validate important memories
  • Archive superseded memories
  • Monitor for conflicts periodically

DON’T

  • Store duplicate memories
  • Use generic memory types when specific ones exist
  • Store with low confidence without reason
  • Keep outdated memories without marking them
  • Ignore detected conflicts

Next Steps


Memory operations are the core of MEMANTO. Master them to build intelligent, context-aware agents!