> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Gentleman-Programming/engram/llms.txt
> Use this file to discover all available pages before exploring further.

# mem_update

> Update an existing observation by ID

## Overview

Update an existing observation by ID. Only the fields you provide are changed — all other fields remain unchanged. Use this when you have the exact observation ID and need to correct or refine it.

<Note>
  This tool is part of the **agent** profile and uses deferred loading to optimize performance.
</Note>

## When to Use

* **Corrections** — fix typos, inaccuracies, or missing details in an existing observation
* **Refinements** — add more context or clarification to a previously saved memory
* **Reclassification** — change the type or scope of an observation
* **Topic key updates** — assign or change the topic key for upsert behavior

<Warning>
  Only use `mem_update` when you have the **exact observation ID**. If you're updating evolving knowledge (like architecture decisions), use [`mem_save`](/mcp/mem-save) with a `topic_key` instead.
</Warning>

## Parameters

<ParamField path="id" type="number" required>
  Observation ID to update

  Get the ID from:

  * [`mem_search`](/mcp/mem-search) results
  * [`mem_get_observation`](/mcp/mem-get-observation) response
  * [`mem_timeline`](/mcp/mem-timeline) results
  * TUI observation view

  **Example:** `42`
</ParamField>

<ParamField path="title" type="string">
  New title for the observation

  **Example:** `"Fixed FTS5 syntax error on special chars [updated]"`
</ParamField>

<ParamField path="content" type="string">
  New content for the observation

  Use the same **What/Why/Where/Learned** format as [`mem_save`](/mcp/mem-save):

  ```
  **What**: [updated description]
  **Why**: [updated reasoning]
  **Where**: [updated file paths]
  **Learned**: [updated insights]
  ```
</ParamField>

<ParamField path="type" type="string">
  New observation type/category

  **Recognized types:**

  * `decision`
  * `architecture`
  * `bugfix`
  * `pattern`
  * `config`
  * `discovery`
  * `learning`
  * `manual`
</ParamField>

<ParamField path="project" type="string">
  New project name

  Change which project this observation is associated with.
</ParamField>

<ParamField path="scope" type="string">
  New visibility scope

  **Options:**

  * `project` — project-scoped
  * `personal` — cross-project personal knowledge
</ParamField>

<ParamField path="topic_key" type="string">
  New topic key (normalized internally)

  Assign or change the topic key for upsert behavior. Format: `family/segment`

  **Example:** `architecture/database-schema-design`
</ParamField>

## Response

<ResponseField name="result" type="string">
  Confirmation message with updated observation details
</ResponseField>

**Example:**

```
Memory updated: #42 "Fixed FTS5 syntax error on special chars [updated]" (bugfix, scope=project)
```

## Usage Examples

### Update Title

```json theme={null}
{
  "id": 42,
  "title": "Fixed FTS5 query sanitization [refined]"
}
```

Updates only the title. All other fields remain unchanged.

### Update Content

```json theme={null}
{
  "id": 42,
  "content": "**What**: Wrapped each search term in quotes AND escaped internal quotes\n**Why**: Users typing queries with apostrophes like \"user's profile\" would crash\n**Where**: internal/store/store.go — sanitizeFTS() function\n**Learned**: FTS5 requires both quoting AND escaping. Nested quotes need special handling."
}
```

Replaces the content with updated details. Title, type, and other fields stay the same.

### Change Type and Scope

```json theme={null}
{
  "id": 12,
  "type": "pattern",
  "scope": "personal"
}
```

Reclassifies observation #12 as a personal pattern (cross-project knowledge).

### Assign Topic Key

```json theme={null}
{
  "id": 87,
  "topic_key": "architecture/auth-model"
}
```

Assigns a topic key to enable future upserts via [`mem_save`](/mcp/mem-save).

### Update Multiple Fields

```json theme={null}
{
  "id": 42,
  "title": "FTS5 query sanitization [comprehensive fix]",
  "type": "bugfix",
  "content": "**What**: Added quote wrapping, escaping, and operator detection\n**Why**: Multiple edge cases caused crashes — apostrophes, quotes, boolean operators\n**Where**: internal/store/store.go — sanitizeFTS() function, added comprehensive test suite\n**Learned**: FTS5 has complex quoting rules. Regex-based sanitization is safer than manual escaping."
}
```

Updates title, type, and content. Project and scope remain unchanged.

## Partial Updates

Only the fields you provide are updated. All other fields remain unchanged:

| Field Provided      | Result                                              |
| ------------------- | --------------------------------------------------- |
| `title`             | Title updated, content/type/project/scope unchanged |
| `content`           | Content updated, title/type/project/scope unchanged |
| `type`              | Type updated, all other fields unchanged            |
| `title` + `content` | Both updated, type/project/scope unchanged          |

<Tip>
  You can update one field or many — it's a partial update, not a full replacement.
</Tip>

## Validation

<AccordionGroup>
  <Accordion title="ID must exist">
    If the observation ID doesn't exist, you'll get an error:

    ```
    Failed to update memory: observation not found
    ```

    Use [`mem_search`](/mcp/mem-search) to find the correct ID.
  </Accordion>

  <Accordion title="At least one field required">
    You must provide at least one field to update:

    ```json theme={null}
    {
      "id": 42
    }
    ```

    **Error:**

    ```
    provide at least one field to update
    ```
  </Accordion>

  <Accordion title="Topic keys are normalized">
    If you provide `topic_key`, it's normalized internally:

    * Lowercased
    * Spaces replaced with hyphens
    * Special characters removed

    **Input:** `"Architecture / Database Schema Design"`

    **Stored:** `"architecture/database-schema-design"`
  </Accordion>
</AccordionGroup>

## Difference from `mem_save` with `topic_key`

| Feature         | `mem_update`                             | `mem_save` with `topic_key`             |
| --------------- | ---------------------------------------- | --------------------------------------- |
| **Requires ID** | Yes — you must know the exact ID         | No — finds observation by topic\_key    |
| **Use case**    | Correct a specific observation           | Update evolving knowledge               |
| **Scope**       | Updates by ID (ignores topic\_key match) | Updates by topic\_key + project + scope |
| **Best for**    | Typo fixes, refinements, corrections     | Architecture decisions, living docs     |

<Info>
  Use `mem_update` when you have an exact ID. Use `mem_save` with `topic_key` for evolving topics.
</Info>

## What Changes

When you update an observation:

* ✅ **Specified fields** are replaced with new values
* ✅ **Updated timestamp** (`updated_at`) is refreshed
* ❌ **Revision count** does NOT increment (only topic\_key upserts increment revisions)
* ❌ **Duplicate count** is NOT affected
* ❌ **Created timestamp** remains unchanged

## Related Tools

* [`mem_save`](/mcp/mem-save) - Save new observations or upsert with topic\_key
* [`mem_get_observation`](/mcp/mem-get-observation) - Get full observation details before updating
* [`mem_search`](/mcp/mem-search) - Find observations to update
* [`mem_delete`](/mcp/mem-delete) - Delete observations by ID
