Memories are markdown files Ellipsis keeps for your agents, so a [session](/docs/sessions) can start with what earlier sessions learned.

## When to use

Use memories for knowledge the model should update as it works.

## Giving an agent memory

Ellipsis copies the memories selected by path or pattern in `memories` into the session's [environment](/docs/environments) at `/ellipsis/memories/` before the session starts. Ellipsis injects instructions that tell the model where its memories are and, when the session has Ellipsis API access, how to change them, so your prompt only needs to say what to do with them. The model can read these copies without memory API [permissions](/docs/permissions#granting-ellipsis-api-access).

For example, sessions of this nightly test [agent](/docs/agents) use past diagnoses to investigate failures and save new findings for later runs.

```python
from ellipsis import ClaudeCodeConfig, Ellipsis, EllipsisGrant, PermissionsConfig

client = Ellipsis()
session = client.sessions.run(
    claude_code=ClaudeCodeConfig(
        model="claude-opus-5-5",
        prompt="Run the tests in api-repo. Consult previous diagnoses and save new findings in nightly-tests/diagnoses.md.",
    ),
    environment="api-environment",
    memories=[
        "team/conventions.md",
        "nightly-tests/*",
    ],
    permissions=PermissionsConfig(
        ellipsis=[
            EllipsisGrant(
                allow=[
                    "memories.list",
                    "memories.get",
                    "memories.update",
                ],
                path="nightly-tests/*",
            ),
        ],
    ),
)
print(session.id)
```

```typescript
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis();
const session = await client.sessions.run({
  claude_code: {
    model: 'claude-opus-5-5',
    prompt: 'Run the tests in api-repo. Consult previous diagnoses and save new findings in nightly-tests/diagnoses.md.',
  },
  environment: 'api-environment',
  memories: [
    'team/conventions.md',
    'nightly-tests/*',
  ],
  permissions: {
    ellipsis: [
      {
        allow: [
          'memories.list',
          'memories.get',
          'memories.update',
        ],
        path: 'nightly-tests/*',
      },
    ],
  },
});
console.log(session.id);
```

```yaml title=".ellipsis/agents/nightly-tests.yaml"
ellipsis:
  kind: agent
  name: nightly-tests

trigger:
  type: cron
  schedule: '0 2 * * *'

session:
  claude_code:
    model: claude-opus-5-5
    prompt: Run the tests in api-repo. Consult previous diagnoses and save new findings in nightly-tests/diagnoses.md.
  environment: api-environment
  memories: [team/conventions.md, 'nightly-tests/*']
  permissions:
    ellipsis:
      - allow: [memories.list, memories.get, memories.update]
        path: 'nightly-tests/*'
```

The memory `nightly-tests/diagnoses.md` records a cause and a way to reproduce the failure.

```text title="diagnoses.md"
The daily summary test fails when midnight falls between two Date.now() calls.
Reproduce by advancing the test clock across midnight.
```

The next session can try this reproduction before investigating other causes.

## Updating a memory

Editing a local copy does not update the saved memory, and copies do not refresh automatically. A session needs [permissions](/docs/permissions#granting-ellipsis-api-access) for `memories.list` and `memories.update` on the memory's path to save an edit. Creating a memory needs `memories.create`. An update replaces the full content. Ellipsis records every change as a [version](/docs/api/memories/get-memories-id-versions), kept for 30 days by default. For [GitHub-backed memories](/docs/memory#syncing-memories-to-github), Ellipsis collects edits in one pull request per repository and applies them when it merges.

**Keep versions longer than 30 days**

Set `data_retention.memory_versions_days` in your [account settings](/docs/api/account/patch-account-settings) to keep them for 1 to 365 days.

**Two writers change the same memory**

Pass the `sha256` you read as `if_sha256` when you update or delete through the API. A memory whose content or metadata changed since you read it returns 409. Read it again and retry.

## Deleting a memory

A session needs [permissions](/docs/permissions#granting-ellipsis-api-access) for `memories.list` and `memories.delete` on a memory's path to delete it. Its versions stay readable until they expire. Delete a [GitHub-backed memory](/docs/memory#syncing-memories-to-github) through its source file.

**Move a memory to a new path**

To change a memory's path, delete it and create it at the new path.

## Labeling memories

Labels and annotations let you and your agents find memories without knowing their paths. They are the frontmatter of the memory's file under `metadata`, in a session's copy and in a file synced from GitHub. A file with no frontmatter has no metadata.

```markdown title="diagnoses.md"
---
metadata:
  labels: [flaky-test]
  annotations:
    owner: platform
---
The daily summary test fails when midnight falls between two Date.now() calls.
Reproduce by advancing the test clock across midnight.
```

For example, this lists the platform team's memories about flaky tests. A memory must have every label and annotation you pass.

```python
from ellipsis import Ellipsis

client = Ellipsis()
for memory in client.memories.list(
    label=["flaky-test"],
    annotation=["owner:platform"],
):
    print(memory.path)
```

```typescript
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis();
const memories = await client.memories.list({
  label: ['flaky-test'],
  annotation: ['owner:platform'],
});
for await (const memory of memories) {
  console.log(memory.path);
}
```

```bash title="CLI"
el memory list --label flaky-test -m owner=platform
```

An update that sends `metadata` replaces the labels and sets each annotation it names, and an annotation set to `null` is removed. `el memory edit` reads the frontmatter of the file it saves, and a file without frontmatter keeps the memory's metadata.

## Syncing memories to GitHub

Ellipsis syncs `.md` files under `.ellipsis/memory/` on a repository's default branch. A push creates, updates, or deletes memories to match the changed files. Memory paths include the repository name, except in the shared [`.ellipsis` repository](/docs/organization#shared-configuration).

For example, the same file name in two repositories is two memories.

| File | Memory path |
| --- | --- |
| `.ellipsis/memory/testing.md` in `api-repo` | `api-repo/testing.md` |
| `.ellipsis/memory/testing.md` in `web-repo` | `web-repo/testing.md` |
| `memory/team/conventions.md` in the `.ellipsis` repository | `team/conventions.md` |

**A file doesn't become a memory**

A file doesn't sync when its path is invalid or already another memory's, when its frontmatter holds anything but `metadata`, or when it exceeds the account's size or memory count limit. The defaults are 100 KiB per memory and 10,000 memories per account. A memory that already exists keeps the last content that synced and names the reason in `last_sync_error`.

## Managing memories from your code

Each memory has a unique path in your account ending in `.md`.

| Action | SDK | API |
| --- | --- | --- |
| Create | `client.memories.create` | [`POST /v1/memories`](/docs/api/memories/post-memories) |
| List | `client.memories.list` | [`GET /v1/memories`](/docs/api/memories/get-memories) |
| Read | `client.memories.get` | [`GET /v1/memories/{id}`](/docs/api/memories/get-memories-id) |
| Update | `client.memories.update` | [`PATCH /v1/memories/{id}`](/docs/api/memories/patch-memories-id) |
| Delete | `client.memories.delete` | [`DELETE /v1/memories/{id}`](/docs/api/memories/delete-memories-id) |
| List versions | `client.memories.versions.list` | [`GET /v1/memories/{id}/versions`](/docs/api/memories/get-memories-id-versions) |

For example, this creates a memory from a local `diagnoses.md` file.

```python
from pathlib import Path
from ellipsis import Ellipsis

client = Ellipsis()
response = client.memories.create(
    path="nightly-tests/diagnoses.md",
    content=Path("diagnoses.md").read_text(),
)
print(response.memory.id)
```

```typescript
import { readFile } from 'node:fs/promises';
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis();
const { memory } = await client.memories.create({
  path: 'nightly-tests/diagnoses.md',
  content: await readFile('diagnoses.md', 'utf8'),
});
console.log(memory.id);
```

```bash title="CLI"
el memory create nightly-tests/diagnoses.md -f diagnoses.md
```
