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

# Long-Term Memory

> The agent remembers who you are and how your infrastructure works — durable facts persist across sessions as plain local files you control.

## Commands at a glance

| Command                 | What it does                               |
| ----------------------- | ------------------------------------------ |
| `/memory`               | List everything the agent remembers        |
| `/memory show <name>`   | Print one memory in full                   |
| `/memory forget <name>` | Delete one memory                          |
| `/memory path`          | Print the folder where memories are stored |

***

## What the agent remembers

OpenSRE keeps durable knowledge across sessions so you never repeat yourself:

* **Who you are** — your name, role, and how you like to work
* **Your infrastructure** — cluster names, naming conventions, known-flaky services
* **Your repositories** — owner/name, purpose, default branch, and repo-specific conventions
* **Your preferences** — report formats, notification choices, defaults
* **Operational learnings** — causes and lessons worth keeping

The memory index is shown to the agent at the start of every conversation, so
facts saved last week ground answers today.

### Multiple repositories

OpenSRE keeps one active repository per GitHub or GitLab context while retaining
facts for many repositories. Naming a different repository makes it active for
unqualified follow-up requests in that session; it does not delete or overwrite
the repositories used earlier. Durable details are stored as separate
`repository` memories, one per repository, and remain available in later
sessions. A new session defaults the active target to the current workspace
checkout, while the other repository memories stay available for recall.

## Saving memories

Talk normally — no special phrasing:

```
our prod cluster is eks-prod-eu-1
```

```
Tracer-Cloud/opensre is our SRE assistant repo; its default branch is main
```

```
acme/payments owns the checkout API and deploys from release
```

```
my name is Vaibhav, I'm on the platform team
```

When the agent judges a fact useful for future sessions, it stores it (and
updates an existing entry instead of duplicating). After **every chat turn**, a
background pass also scans for durable facts so knowledge lands even if the
agent did not call a memory tool mid-turn. On shell exit that pass runs to
completion so nothing is dropped mid-quit.

## Viewing and deleting memories

```
/memory
```

```
  Long-term memory

   name                      type            description                          updated
   ─────────────────────────────────────────────────────────────────────────────────────────
   prod-cluster-conventions  infrastructure  Prod EKS clusters: eks-prod-<region>  2026-07-09
   user-profile              user            Vaibhav, platform team                2026-07-09
```

Delete one with `/memory forget prod-cluster-conventions`, or ask the agent:
"forget what you know about the prod cluster".

## Where memories live

On a laptop, memories are plain markdown files under `~/.opensre/memory/` — one
file per memory plus a generated `MEMORY.md` index. OpenSRE creates that folder
(and an empty index) the first time memory is used in a chat or via `/memory`.
They are stored **locally and unencrypted**.

Override the directory with `OPENSRE_MEMORY_DIR` when you need a custom path.

On a Slack or Discord silo, each member gets a private memory folder inside the
organization's mounted context volume
(`<org root>/users/<user_id>/memory/`), not a shared host folder. Telegram
turns are unbound and stay **host-global** under the flat `~/.opensre/memory/`
layout.

Every chat and action turn includes the stored facts (summaries plus bodies,
within a size budget) in prompts sent to your configured LLM provider. You can
open, edit, or delete the files directly at any time; the index rebuilds on the
next write.

## Turning memory off

| Environment variable                    | Effect                                                        |
| --------------------------------------- | ------------------------------------------------------------- |
| `OPENSRE_MEMORY_DISABLED=1`             | Disable long-term memory entirely                             |
| `OPENSRE_MEMORY_AUTOEXTRACT_DISABLED=1` | Keep memory, but skip the automatic per-turn extraction       |
| `OPENSRE_MEMORY_GATEWAY_ENABLED=1`      | Opt in on Slack/Telegram gateway (off by default — see below) |
| `OPENSRE_MEMORY_DIR`                    | Override the memory storage directory                         |

The per-turn extraction makes one lightweight LLM call when durable facts may
have appeared (coalesced across rapid turns) and saves at most five memories
per pass. On shell exit that pass runs to completion after resources are
released so durable facts are not dropped. Never share secrets or credentials
expecting them to be remembered — the memory ingestion path blocks obvious
tokens, passwords, private keys, and credential-shaped values, and redacts
matching spans before the extraction LLM call.

## Gateway (Slack / Telegram / Discord / Buzz)

On Slack, Discord, and Buzz, when org scope is bound, memory is **per-user
scoped** — each member's facts live under their own `users/<id>/memory/` folder
inside the org volume, so one user's memories cannot appear in another's
prompts or channel replies. Telegram turns are unbound and stay **host-global**.

Because Telegram is host-global (and to keep memory off by default on shared
hosts), the **Slack and Telegram** gateway path is **off by default**; opt in
with `OPENSRE_MEMORY_GATEWAY_ENABLED=1`. Discord and Buzz use the same
actor-scoped storage layout when scoped; they are not gated by that opt-in flag
today — use `OPENSRE_MEMORY_DISABLED=1` if you need memory off there.
