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

# Sessions and branching

> Save, resume, fork, and search your Fleet Prime Agent sessions.

Every conversation is a session with a transcript on disk and a persistent Python kernel. This guide covers the commands you'll use day-to-day. For the theory see [Sessions](/fleet-prime-agent/concepts/sessions).

## Save and resume

Sessions save automatically. To pick up where you left off:

```bash theme={null}
prime-agent --resume <session-id>
```

List recent sessions:

```bash theme={null}
prime-agent ps
```

## Fork a session

To try a different direction from a specific point without losing the original:

```bash theme={null}
prime-agent --fork <session-id>
```

You get a new session that shares history up to the branch point and diverges after. Fork depth is tracked with `rlmDepth` on the session header.

## Branch inside a session

The agent creates its own branches when it needs to explore alternatives. Each branch gets a summary (`createBranchSummaryMessage`) so switching between branches doesn't blow the context window.

## Compaction

Long sessions get compacted when they approach the model's context limit. The compaction pipeline (`compact`, `calculateContextTokens`, `prepareBranchEntries`) trims low-value entries and keeps decisions, plans, and results. Every compaction is recorded in the transcript so you can see what was dropped and why.

## Where transcripts live

`~/.prime/agent/sessions/`. Each session is a single append-only file with entries of type `message`, `custom_message`, `compaction`, `branch_summary`, or `git_state`.

## Search

The web UI has a session list with full-text search. From the CLI:

```bash theme={null}
prime-agent ps --search "kubernetes"
```

Search is capped at `SESSION_LIST_SEARCH_TEXT_MAX_CHARS` (64 KB) per entry so large transcripts stay fast.
