> For the complete documentation index, see [llms.txt](https://docs.karini.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.karini.ai/memories.md).

# Memories

The Memory feature enables your AI agents to store and retrieve conversational context, creating persistent knowledge that spans multiple interactions. This capability allows agents to maintain continuity across conversations, recall user preferences, and access historical information when making decisions or generating responses.

Memory is powered by **AWS Bedrock AgentCore**, a managed service that provides sophisticated memory storage, retrieval, and indexing capabilities for conversational AI systems.

### Key Concept

#### Types of Memory

AgentCore Memory supports two primary memory types:

* Short-term Memory
* Long-term Memory.

These memory types serve different purposes, allowing AI agents to manage immediate conversational context and preserve meaningful historical information for future interactions.

#### 1. Short-term Memory

Short-term memory temporarily stores recent conversation exchanges. Its primary purpose is to maintain conversational continuity by preserving the immediate context of ongoing interactions. It enables agents to reference previous messages within a session without requiring semantic search queries.

Key Characteristics:

* Stores recent conversation exchanges temporarily.
* Maintains immediate conversational context across multiple interactions.
* Supports session-based retrieval of conversation history.
* Retrieves conversation records chronologically without requiring semantic search queries.
* Uses a configurable Time-to-Live (TTL) to manage data retention.
* Ideal for multi-turn conversations, follow-up questions, and context-aware responses.

#### 2. Long-term Memory

Long-term memory enables AI agents to retain and retrieve meaningful information extracted from historical conversations over extended periods. It uses AgentCore's asynchronous extraction and processing mechanisms to transform conversational data into reusable memory records. These records can be retrieved through search queries, allowing agents to access historical context across multiple conversation sessions.

Key Characteristics:

* Stores relevant information extracted from historical conversations.
* Supports persistent knowledge retention across multiple sessions.
* Uses asynchronous extraction and memory processing mechanisms.
* Supports multiple memory strategies, including Summary, Semantic, and User Preference.
* Enables search-based retrieval of relevant historical information.
* Helps agents recall past interactions, previously discussed information, and user preferences.
* Ideal for historical context retrieval, knowledge retention, and personalized AI interactions.

### Memory Strategies

Long-term memory supports multiple retrieval strategies, with a maximum of 3 strategies per memory resource. Each strategy provides a different approach to extracting and retrieving information:

**Summary Strategy**

The Summary Strategy generates and maintains condensed representations of conversations, capturing important topics, decisions, and contextual information discussed during a session.

* Creates and maintains summaries of conversation history.
* Enables high-level semantic retrieval of conversation context.
* Supports Conversation scope for long-term retrieval.

**Semantic Memory Strategy**

The Semantic Memory Strategy extracts factual information and meaningful knowledge from conversations and stores it as searchable memory records.

* Extracts and stores semantic facts and relationships from conversations.
* Enables similarity-based search across conversation content.
* Retrieves information based on semantic meaning rather than exact matches

**User Preference Memory Strategy**

The User Preference Memory Strategy identifies and retains user-specific preferences, choices, and behavioral patterns expressed during conversations.

* Learns and remembers user preferences, settings, and behaviors.
* Tracks user-specific patterns and choices over time.
* Enables personalized responses based on accumulated user preferences.

### Memory Scope

**Memory Scope** defines the level at which stored memories can be accessed and retrieved. It determines whether the retrieval operation is restricted to a specific conversation, an individual user, or all users within an organization.

**1. Conversation**

* Retrieves memories associated only with the **current conversation thread**.
* Maintains conversation-specific context without including information from other conversations.
* Supported for **Short-Term Memory** and **Long-Term Memory** when using the **Summary** strategy.

**2. Current User**

* Retrieves memories associated with the **currently logged-in user** across their conversations.
* Enables continuity and personalized responses by accessing information from previous interactions.
* Excludes memories belonging to other users.

**3. All Users**

* Retrieves memories associated with **all users within the organization**.
* Enables organization-wide knowledge retrieval and information sharing across different users.
* Supports collaborative workflows by making stored information available beyond individual user boundaries.

### Creating a New Memory

Creating a memory resource involves configuring storage and retrieval settings through AWS Bedrock AgentCore. Memory resources must be provisioned and reach ACTIVE status before they can be used in recipes or agents.

#### Step 1: Access Memory Creation

1. Navigate to **Memories in left panel menu.**
2. Click the **+ Add** button in the upper right.
3. The memory creation form will open.

#### Step 2: Configure Memory Settings

1. **Name** : Enter a descriptive name that indicates the memory's purpose.
2. **Description :** Enter a description outlining the memory's purpose and intended usage..Memory Provider: Bedrock AgentCore is visible by default.
3. **Short-term Memory TTL (Time-to-Live)**
   1. Enable this option to define the retention period for short-term conversation events, after which the events are automatically deleted.
   2. When enabled, the following parameter can be configured:
      1. **Short-term Memory TTL (days):** Specifies the number of days conversation events are retained before automatic expiration.
      2. **Default Value:** 30 days.
      3. **Valid Range:** 7–365 days.
4. **Enable Long-term Memory**

   * Enable this option to activate long-term memory capabilities for persistent storage and retrieval of information across conversation sessions.
   * When enabled, the **Memory Strategies** and **Long-term Memory TTL** configuration options become available.

   **Memory Strategies**

   * Select which built-in AgentCore long-term memory strategies to enable, with a maximum of **three strategies per memory resource**.
   * Available strategies include:
     * **Summary Strategy**
     * **Semantic Memory Strategy**
     * **User Preference Memory Strategy**
   * At least one strategy must be selected when long-term memory is enabled.
   * Multiple strategies can be enabled based on the application's memory extraction and retrieval requirements.

   **Long-term Memory TTL (Time-to-Live)**

   * Enable this option to define the retention period for long-term memory records, after which the records automatically expire.
   * When disabled, long-term memory records are retained without an automatic expiration period.
   * When enabled, the following parameter can be configured:
     * **Long-term Memory TTL (days):** Specifies the number of days long-term memory records are retained before automatic expiration.
5. **Overwrite Credentials:** By default, the AWS credentials configured in [Organization](https://karini-ai.gitbook.io/karini-ai-documentation/organization) settings will be used to access AWS resources. If needed, provide alternate AWS credentials for this memory resource.

#### Step 3: Save and Provision

1. Review all configuration settings to ensure they match your requirements.
2. Click **Save** to create the memory resource.
3. The system initiates provisioning through AWS Bedrock AgentCore.
4. Memory status will display as **CREATING** during the provisioning process.
5. Use the **Refresh** button to check provisioning progress.
6. Status will change to **ACTIVE** when the memory is ready for use.

**Provisioning Timeline and Notes:**

* Initial provisioning typically takes several minutes.
* AgentCore must allocate and configure the underlying memory infrastructure.
* The memory cannot be used in recipes or agents until status changes to **ACTIVE.**
* If status shows **FAILED**, review the configuration settings, verify AWS credentials, and contact support if issues persist.
* You cannot modify certain settings (such as the provider) after initial creation.

Upon successful memory creation, the Memory page displays the configured settings and management options, as shown below.

<figure><img src="https://415930246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7ZrVuiAUMyuYVvrK5KaB%2Fuploads%2FysQwUlrfO3J7A9DGpS1s%2Fimage.png?alt=media&amp;token=9cf1787d-7c75-4923-8b51-bbf08cf35b5f" alt=""><figcaption></figcaption></figure>

### Memory Tools Panel

The Memory Tools panel provides a testing interface for writing to and reading from memory resources. This panel is available on the right side of the memory detail page when the memory status is **ACTIVE**.

#### Panel Controls

The panel provides controls for managing visibility and navigating between functional tabs. Users can collapse or expand the panel without losing their existing work and switch between tabs to perform specific operations.

**Toggle Visibility**

* Click the **arrow button** on the right edge of the panel to expand or collapse it.
* The panel retains its existing content and state when collapsed.

**Tab Navigation**

* **Write Tab:** Stores conversation exchanges for future reference.
* **Read Tab:** Retrieves and displays previously stored information.

#### Write Tab

The **Write Tab** enables users to store conversation exchanges in the memory resource by capturing both user inputs and assistant responses. Each exchange is stored in a structured format to maintain the correct conversational context and message sequence.

**Input Fields**

* **User Message:** Enter the user's query or message.
* **Assistant Answer:** Enter the corresponding assistant response.

**Functionality**

* Both input fields are mandatory to create a complete conversation exchange.
* Click **Write to memory** to save the conversation pair to the memory resource.
* The system stores messages in the predefined sequence (**USER → ASSISTANT**) to preserve conversational order and context.

#### Read Tab

The **Read Tab** enables users to search and retrieve stored conversation data from the memory resource. It supports both short-term and long-term memory retrieval, with configurable search parameters, retrieval strategies, and memory scopes to control the relevance and accessibility of results.

**Configuration Options**

**1. Search Query (Long-Term Memory Only)**

* Enter keywords, phrases, or natural language queries to retrieve relevant stored memories.
* This field is available only for **Long-Term Memory**, as short-term memory retrieves recent conversation exchanges based on recency.

**2. Memory Type**

Determines the type of memory used for retrieving stored information.

* **Short-Term Memory:** Retrieves recent conversation exchanges from the current session, maintaining immediate conversational context.
* **Long-Term Memory:** Retrieves persistent memory records based on the specified search query and selected retrieval strategies. This option is available only when long-term memory is enabled for the configured memory resource.

**3. Memory Strategies (Long-Term Memory Only)**

Memory strategies define how stored information is searched and retrieved. These options appear when **Long-Term Memory** is selected.

* **Summary:** Retrieves summarized conversation history to provide condensed contextual information.
* **Semantic Memory:** Retrieves relevant information based on semantic similarity between the search query and stored content.
* **User Preference Memory:** Retrieves stored user-specific preferences to support personalized interactions.

**Strategy Selection Behavior:**

* Only strategies enabled during memory creation are available for selection.
* Unavailable strategies appear disabled with explanatory tooltips.
* Multiple strategies can be selected to expand retrieval coverage across different memory representations.

**4. Memory Scope**

The **Memory Scope** determines which stored memories are accessible during retrieval.

* **Conversation Scope:** Restricts retrieval to the current conversation thread. It is always available for short-term memory and supported for long-term memory only when the **Summary** strategy is selected.
* **Current User Scope:** Retrieves memories associated with the currently authenticated user across their conversations.
* **All Users Scope:** Retrieves memories across all users within the organization, enabling organization-wide knowledge access.

**Dynamic Scope Behavior:**

* For short-term memory, Conversation Scope is always available.
* For long-term memory, Conversation Scope is available only when the Summary strategy is selected.
* The interface automatically updates available scope options when memory strategies are selected or deselected.

**5. Max Results**

Controls the maximum number of memory records returned by a retrieval request.

* **Default Value:** 5 results.
* **Supported Range:** 1–100 results.
* Increasing the limit allows broader retrieval coverage but may increase response time.

**Memory Retrieval Process**

To retrieve stored memory information:

1. Select the required **Memory Type**.
2. Enter a **Search Query** and choose the appropriate **Memory Strategies**, if using long-term memory.
3. Configure the **Memory Scope** and **Max Results**.
4. Click **Read from memory** to execute the retrieval request.
5. Review the retrieved records displayed within the panel.
