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

# Sessions and context

> What a session holds, how compaction keeps it valid, and how clearing differs from compacting.

A session is one conversation. It survives the process. `--continue` opens the most recent one
and `--resume <id>` opens a specific one, both with the conversation intact.

Sessions are stored in a SQLite database, `seri.db`, in your profile root. A `sessions/`
directory of `.jsonl` files from an older release is imported into it on first use and then only
ever read, never written.

## Compaction

Past half the model's context window, seri condenses the older part of the conversation instead
of letting the next call fail.

The evicted messages become a single recap message with four fields.

| Field      | Holds                                                    |
| ---------- | -------------------------------------------------------- |
| Goal       | what the session is trying to do                         |
| Progress   | what has been done, with concrete values quoted verbatim |
| Blockers   | what is in the way                                       |
| Next steps | what comes next                                          |

The summariser is told to quote literal values rather than paraphrase them, because losing an
exact filename, string or number is a real failure while a slightly longer summary is not.

**A cut never splits a tool call from its result.** The boundary is only ever placed immediately
before a user or assistant message, never before a tool result, because a tool result is always
the second half of a pair. Evicting one half while keeping the other is a specific class of
provider error, and the boundary rule is what makes it unrepresentable.

`/compact` runs the same thing on demand.

## Compacting is not clearing

They are different resets, and the difference matters when you are choosing.

|              | `/compact`                        | `/clear`                         |
| ------------ | --------------------------------- | -------------------------------- |
| Scope        | partial                           | full                             |
| Visible      | transparent, the turn keeps going | explicit, you start again        |
| Old messages | condensed into a recap            | gone from the new session's view |
| Recoverable  | not separately                    | yes, with `--resume <id>`        |

`/clear` starts a new session rather than deleting the old one. Every `/clear` leaves the
previous session's file on disk with no retention policy, which is accepted rather than a bug.

The checkpoint store is a separate matter. It keeps the 20 most recently touched sessions per
project, so clearing repeatedly in one long-lived process can eventually retire an earlier
session's undo history even though its conversation file never goes away. See [Checkpoints and
undo](/guides/checkpoints).

## The turn budget

`--max-turns <n>` caps model turns per task, 500 by default, and `/max-turns <n>` changes it for
the rest of the session. Running out is a run that did not finish, so it exits `1`.

A subagent does not inherit that budget. It gets 25 turns, because three concurrent children on
the session's own cap would multiply tokens without a ceiling.

## What is frozen at session start

The system prompt. `AGENTS.md`, always-on rules, and your memory files are read once and never
edited mid-session, which is what lets a provider reuse its cached prefix on every turn.

Anything that arrives later arrives as a message in the conversation instead. A [rule that fires
on a glob](/guides/rules) works this way, and so does an approved [memory
write](/guides/memory), which enters the prompt the next time you start seri.

## Trajectories

seri records each run locally, on by default. A trajectory holds tool calls and their results,
checkpoints, denials with their reason, check results, edit outcomes, token usage, retries and
how the turn ended. Large values are elided with their original size recorded rather than stored
whole.

| Control                          | Does                                             |
| -------------------------------- | ------------------------------------------------ |
| `/trajectory`                    | show whether recording is on                     |
| `/trajectory on\|off`            | set it for this profile                          |
| `SERI_TRAJECTORY_ENABLED=false`  | turn it off from the environment                 |
| `SERI_TRAJECTORY_RETENTION_DAYS` | retention for legacy recordings. Defaults to 30. |

Recordings go into `seri.db` in your profile root and never leave your machine.

<Warning>
  `SERI_TRAJECTORY_RETENTION_DAYS` only prunes `.jsonl` recordings left by an older release. Rows in
  the database are not aged out by it, so recordings there accumulate for as long as recording is
  on.
</Warning>

<Note>
  The environment wins over what `/trajectory` stored, so a variable set in your shell keeps
  winning at the next start. seri says so when you set the toggle against a variable that will
  override it.
</Note>
