> ## 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.

# Session History

> Pick up any past conversation exactly where you left off — browse recent sessions, restore context, and start fresh.

## Commands at a glance

| Command                | What it does                                                                  |
| ---------------------- | ----------------------------------------------------------------------------- |
| `/sessions`            | List your recent REPL sessions with name, duration, and turn counts           |
| `/resume <id>`         | Restore a past session's conversation so you can keep asking questions        |
| `/resume <id>:<entry>` | Restore a specific branch point by entry ID prefix                            |
| `/compact`             | Summarize older context into a replayable compaction entry                    |
| `/new`                 | Start a fresh session while carrying forward the current conversation context |

***

## Browsing past sessions — `/sessions`

Run `/sessions` inside the interactive shell to see your recent history:

```
/sessions
```

```
  Recent sessions

   #  Session ID  Name                           Started            Duration  Turns
   ─────────────────────────────────────────────────────────────────────────────────
   1  3f8a1c2d    (current)                      2024-01-15 10:00   42m       8
   2  9b2e4f7a    why is CPU spiking on prod-api  2024-01-14 14:30   1h 5m    15
   3  c1d3e8f2    investigate OOM killer          2024-01-13 09:10   12m       3
```

Up to 20 sessions are shown, newest first. The current session updates its elapsed time live.

***

## Resuming a past session — `/resume`

When you want to continue a past investigation or conversation, use `/resume` with the first few characters of the session ID shown in `/sessions`:

```
/resume 9b2e4f7a
```

From outside the REPL, pass the same ID or name substring to the CLI launcher (for example `opensre --resume 9b2e4f7a` or `o --resume OOM` when `o` is your shell alias):

```bash theme={null}
opensre --resume <uuid>
```

In a TTY, bare `/resume` opens an interactive picker of recent sessions. New turns after a resume append to that same session file — `/resume` does not create a duplicate entry in `/sessions`.

To resume a specific branch point, append an entry ID prefix after the session ID:

```
/resume 9b2e4f7a:abc123
```

When the branch contains a compaction entry, replay inserts the saved summary before the kept messages so the assistant has the compacted context.

OpenSRE restores the conversation so the assistant remembers what you were working on. It displays the past exchanges so you can see where you left off, then lets you continue typing:

```
resumed session 9b2e4f7a · why is CPU spiking on prod-api (14 messages)
─── conversation history ────────────────────────────────────
❯ why is CPU spiking on prod-api?
● assistant
The root cause is a connection pool leak in the orders service...
─────────────────────────────────────────────────────────────
```

**What gets restored:**

|                                                                     | Restored by `/resume`                    |
| ------------------------------------------------------------------- | ---------------------------------------- |
| Full conversation context (what you asked, what the assistant said) | ✅ Yes                                    |
| Infra context (service name, cluster, region learned mid-session)   | ✅ Yes                                    |
| Trust mode, reasoning effort                                        | ❌ No — these are per-session preferences |

You can also search by name instead of ID:

```
/resume redis        # resumes the session whose name contains "redis"
/resume cpu spike    # matches by name substring
```

If the prefix is ambiguous (matches more than one session), OpenSRE will ask you to be more specific.

***

## When you exit

When you leave the REPL, OpenSRE prints your session ID so you can resume later:

| Exit path                         | Behavior                                                                                                      |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `/exit` or `/quit`                | Prints `Resume this session with:`, `/resume <session-id>`, and `opensre --resume <session-id>`, then goodbye |
| **Ctrl+C** twice within 2 seconds | Same resume hint, then exits                                                                                  |
| **Ctrl+D** (EOF)                  | Same resume hint when no dispatch is running                                                                  |

Example:

```
Resume this session with:
/resume 3f8a1c2d-…
opensre --resume 3f8a1c2d-…
Goodbye!
```

Copy the `/resume …` or `opensre --resume …` line from the terminal, or find the session later with `/sessions`.

***

## Starting fresh with context — `/new`

`/new` closes the current session and opens a new one, but carries the conversation forward so you don't lose context:

```
/new
```

```
new session started — conversation context carried forward.
  14 messages in context · type to continue
```

Use `/new` after a long session to keep things tidy in `/sessions` without losing your place in the conversation.

***

## Compacting long sessions — `/compact`

`/compact` summarizes older conversation context, keeps the recent turns, and writes a durable compaction entry into the session file:

```
/compact
```

OpenSRE also compacts automatically before a shell turn when the replayed branch context grows past the runtime threshold. The compaction entry stores the summary, the first kept entry ID, and before/after size estimates so future `/resume` calls can replay the compacted branch.

**`/new` vs `/clear`:**

| Command  | What it does                                                    |
| -------- | --------------------------------------------------------------- |
| `/clear` | Clears the terminal screen only — session and context unchanged |
| `/new`   | Opens a new session file; conversation context carried forward  |

***

## What OpenSRE saves

Each session records:

* When it started and ended, and how long it ran
* Every message you sent and every response from the assistant
* Tool calls, tool updates, tool results, model/tool changes, labels, custom messages, and compaction summaries
* Infra context discovered during investigations (service names, cluster names, regions)
* Turn counts for investigations and chats

Sessions are stored as files under `~/.opensre/sessions/`. Each file is plain text and human-readable.

***

## Privacy and what is NOT saved

* **Secrets or credentials** — known token shapes are redacted from the prompt log by default (set `OPENSRE_PROMPT_LOG_REDACT=0` to store raw text instead)
* **Full investigation results** — stored separately under `~/.opensre/investigations/`
* **Token usage** — tracked in `~/.opensre/prompt_log.jsonl` when prompt logging is enabled

See [Interactive Shell Privacy](/interactive-shell-privacy) for redaction controls.

***

## Related

* [Interactive Shell Privacy](/interactive-shell-privacy) — command history, prompt/response logging, and redaction settings
* [Prompt Logging](/configuration/environment-variables) — full prompt/response logging configuration
