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

> How Fleet RLM stores Sessions, Turns, workspace files, and memory, and how each Session's runtime, lease, and sandbox work.

A Session is a private conversation with its own workspace, memory, settings, and sandbox. Fleet RLM persists Session state in PostgreSQL and workspace files on a Daytona Volume.

## Domain model

| Term | Meaning |
| - | - |
| Session | A conversation identified by a Session ID you choose. Fleet creates it on first use. |
| Turn | One task and its committed answer. Each Turn has a `turn_id` and an optional idempotency key. |
| Workspace | The Session's files on the Daytona Volume. Attachments land in `files/`, and outputs in `artifacts/`. |
| Memory | Session-scoped notes with a `kind`, `sources`, and a `reviewed` flag. |
| Context | One workspace file selected as the Session's dataset. |

## Persistence

Fleet stores Sessions, Turns, memory, and Session settings in PostgreSQL. See [Deploy with PostgreSQL](https://docs.qredence.ai/fleet-rlm/guides/deploy-with-postgres.md).

* A Turn's intent is recorded before it runs, with status `running`. It ends as `completed`, `failed`, or `cancelled`.
* A completed Turn commits its record, its learned note, and its outcome in one transaction. A dropped stream can't undo a committed Turn.
* Each Session keeps up to 200 Turns of history. Fleet passes the latest 8 Turns, capped at 16,000 characters, to the model as conversation history.
* Mode, model, and context selections persist and survive a server restart.

History and Turn status are durable reads. `GET /sessions/{session_id}/history` and `GET /sessions/{session_id}/turns/{turn_id}` read PostgreSQL directly. They work during a Turn, from any server process, and without starting the Session's sandbox.

## Session runtime

The first request that needs a Session's sandbox builds a runtime for it in the server process. The runtime holds the Session's Daytona sandbox, Skill manager, and DSPy engine.

* The server holds at most `runtime.max_active_sessions` runtimes. Requests for a new Session beyond that limit return `503`.
* `DELETE /sessions/{session_id}` stops the sandbox, releases the lease, and drops the runtime. History is kept, and the next request rebuilds the runtime.
* Before each Turn, Fleet refreshes the sandbox state from Daytona. If Daytona stopped the sandbox while it was idle, Fleet restarts it and emits `sandbox_resuming`.

## Session lease

Fleet holds a PostgreSQL advisory lock for each Session runtime. Only one server process can own a Session at a time. A second process that tries to build a runtime for it gets `503`.

Fleet checks the lease connection in the background. If the connection drops, Fleet takes the lock again on a fresh connection. If another process took the Session in the meantime, Fleet marks the lease as lost and cancels any running Turn. The next request evicts the stale runtime and rebuilds it once the draining Turn finishes.

## Session lock

Each Session runs one Turn at a time. Turns, workspace writes, context, mode, model, memory changes, and Skill syncs share one lock. When a Turn holds it, those routes return `409` after 2 seconds. See [HTTP API](https://docs.qredence.ai/fleet-rlm/reference/http-api.md#session-lock).

## The workspace Volume

One Daytona Volume holds every Session's workspace.

| Sandbox | Mount | Holds |
| - | - | - |
| Root Session sandbox | `sessions/<session_id>` at `/workspace` | The Session's files, attachments, artifacts, and Skills. |
| Child agent sandbox | `agents/<session_id>/<agent_id>` at `/workspace` | The child's private copy of its input files. Results return to the parent workspace. |

Root sandboxes can also mount shared learned notes at `/learned`. See [Configuration](https://docs.qredence.ai/fleet-rlm/reference/configuration.md).

Upload files with `POST /sessions/{session_id}/attach` or `/attach` in the terminal. Fleet stores them under `files/` and reports their sandbox path, for example `/workspace/files/report.csv`.

## Memory

Memory is scoped to a Session. You write and review it with the memory routes, and each committed Turn can add a learned note.

Before each Turn, Fleet searches the Session's memory for the task and passes only reviewed matches to the model. Set `reviewed: true` on a memory to make it Turn evidence.

## Cancellation

Close the Turn stream to cancel it. Fleet requests remote cancellation, stops child sandboxes, and records the Turn as `cancelled`. The Session stays locked until the sandbox work has drained.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.