> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory • AI Agent SDK

> Memory: A single-file memory manager covering:

# Memory

> Defined in the [**memory**](../modules/memory) module.

<Badge color="blue">AI Agent</Badge>

A single-file memory manager covering:

* Short-term memory (STM) for ephemeral context
* Long-term memory (LTM) for persistent knowledge
* Entity memory (structured data about named entities)
* User memory (preferences/history for each user)
* Quality score logic for deciding which data to store in LTM
* Context building from multiple memory sources
* Graph memory support for complex relationship storage (via Mem0)

Config example:
\{
"provider": "rag" or "mem0" or "mongodb" or "none",
"use\_embedding": True,
"short\_db": "short\_term.db",
"long\_db": "long\_term.db",
"rag\_db\_path": "rag\_db",   # optional path for local embedding store
"config": \{
"api\_key": "...",       # if mem0 usage
"org\_id": "...",
"project\_id": "...",

# MongoDB configuration (if provider is "mongodb")

"connection\_string": "mongodb://localhost:27017/" or "mongodb+srv://user:[pass@cluster.mongodb.net](mailto:pass@cluster.mongodb.net)/",
"database": "praisonai",
"use\_vector\_search": True,  # Enable Atlas Vector Search
"max\_pool\_size": 50,
"min\_pool\_size": 10,
"max\_idle\_time": 30000,
"server\_selection\_timeout": 5000,

# Graph memory configuration (optional)

"graph\_store": \{
"provider": "neo4j" or "memgraph",
"config": \{
"url": "neo4j+s\://xxx" or "bolt://localhost:7687",
"username": "neo4j" or "memgraph",
"password": "xxx"
}
},

# Optional additional configurations for graph memory

"vector\_store": \{
"provider": "qdrant",
"config": \{"host": "localhost", "port": 6333}
},
"llm": \{
"provider": "openai",
"config": \{"model": "gpt-4o-mini", "api\_key": "..."}
},
"embedder": \{
"provider": "openai",
"config": \{"model": "text-embedding-3-small", "api\_key": "..."}
}
}
}

Note: Graph memory requires "mem0ai\[graph]" installation and works alongside
vector-based memory for enhanced relationship-aware retrieval.

## Constructor

<ParamField query="config" type="Dict" required={true}>
  No description available.
</ParamField>

<ParamField query="verbose" type="int" required={false} default="0">
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="compute_quality_score()" icon="function" href="../functions/Memory-compute_quality_score">
    Combine multiple sub-metrics into one final score, as an example.
  </Card>

  <Card title="store_short_term()" icon="function" href="../functions/Memory-store_short_term">
    Store in short-term memory with optional quality metrics
  </Card>

  <Card title="search_short_term()" icon="function" href="../functions/Memory-search_short_term">
    Search short-term memory with optional quality filter
  </Card>

  <Card title="reset_short_term()" icon="function" href="../functions/Memory-reset_short_term">
    Completely clears short-term memory.
  </Card>

  <Card title="store_long_term()" icon="function" href="../functions/Memory-store_long_term">
    Store in long-term memory with optional quality metrics
  </Card>

  <Card title="search_long_term()" icon="function" href="../functions/Memory-search_long_term">
    Search long-term memory with optional quality filter
  </Card>

  <Card title="reset_long_term()" icon="function" href="../functions/Memory-reset_long_term">
    Clear local LTM DB, plus Chroma, MongoDB, or mem0 if in use.
  </Card>

  <Card title="delete_short_term()" icon="function" href="../functions/Memory-delete_short_term">
    Delete a specific short-term memory by ID.
  </Card>

  <Card title="delete_long_term()" icon="function" href="../functions/Memory-delete_long_term">
    Delete a specific long-term memory by ID.
  </Card>

  <Card title="delete_memory()" icon="function" href="../functions/Memory-delete_memory">
    Delete a specific memory by ID.
  </Card>

  <Card title="delete_memories()" icon="function" href="../functions/Memory-delete_memories">
    Delete multiple memories by their IDs.
  </Card>

  <Card title="delete_memories_matching()" icon="function" href="../functions/Memory-delete_memories_matching">
    Delete memories matching a search query.
  </Card>

  <Card title="store_entity()" icon="function" href="../functions/Memory-store_entity">
    Save entity info in LTM (or mem0/rag).
  </Card>

  <Card title="search_entity()" icon="function" href="../functions/Memory-search_entity">
    Filter to items that have metadata 'category=entity'.
  </Card>

  <Card title="reset_entity_only()" icon="function" href="../functions/Memory-reset_entity_only">
    If you only want to drop entity items from LTM, you'd do a custom
  </Card>

  <Card title="store_user_memory()" icon="function" href="../functions/Memory-store_user_memory">
    If mem0 is used, do user-based addition. Otherwise store in LTM with user in metadata.
  </Card>

  <Card title="search_user_memory()" icon="function" href="../functions/Memory-search_user_memory">
    If mem0 is used, pass user\_id in. Otherwise fallback to local filter on user in metadata.
  </Card>

  <Card title="search()" icon="function" href="../functions/Memory-search">
    Generic search method that delegates to appropriate specific search methods.
  </Card>

  <Card title="reset_user_memory()" icon="function" href="../functions/Memory-reset_user_memory">
    Clear all user-based info. For simplicity, we do a full LTM reset.
  </Card>

  <Card title="finalize_task_output()" icon="function" href="../functions/Memory-finalize_task_output">
    Store task output in memory with appropriate metadata
  </Card>

  <Card title="build_context_for_task()" icon="function" href="../functions/Memory-build_context_for_task">
    Merges relevant short-term, long-term, entity, user memories
  </Card>

  <Card title="reset_all()" icon="function" href="../functions/Memory-reset_all">
    Fully wipes short-term, long-term, and any memory in mem0 or rag.
  </Card>

  <Card title="calculate_quality_metrics()" icon="function" href="../functions/Memory-calculate_quality_metrics">
    Calculate quality metrics using LLM
  </Card>

  <Card title="store_quality()" icon="function" href="../functions/Memory-store_quality">
    Store quality metrics in memory
  </Card>

  <Card title="search_with_quality()" icon="function" href="../functions/Memory-search_with_quality">
    Search with quality filter
  </Card>

  <Card title="get_all_memories()" icon="function" href="../functions/Memory-get_all_memories">
    Get all memories from both short-term and long-term storage
  </Card>

  <Card title="learn()" icon="function" href="../functions/Memory-learn">
    Get the LearnManager for continuous learning capabilities.
  </Card>

  <Card title="get_learn_context()" icon="function" href="../functions/Memory-get_learn_context">
    Get learning context suitable for injection into system prompt.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/memory/memory.py#L126">
  `praisonaiagents/memory/memory.py` at line 126
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Memory Concept" icon="brain" href="/docs/concepts/memory" />

  <Card title="Memory Overview" icon="database" href="/docs/memory/overview" />

  <Card title="Memory Configuration" icon="gear" href="/docs/configuration/memory-config" />

  <Card title="Session Resume" icon="rotate-right" href="/docs/memory/session-resume" />
</CardGroup>
