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

# How Fleet RLM works

> Follow a Fleet RLM Turn from the HTTP request through claim, preparation, DSPy execution in Daytona, settlement, and commit.

Fleet RLM is a Session-first FastAPI application. DSPy owns the reasoning loop, Daytona runs generated Python, and the terminal client consumes the public HTTP and SSE contract.

## Components

| Component | Responsibility |
| - | - |
| `fleet` CLI | Starts the backend, the terminal client, or diagnostics. |
| FastAPI app | Validates requests, composes runtime services at startup, and projects Runtime Events into SSE. |
| `TurnRuntime` | Runs each Turn through claim, preparation, execution, settlement, and cleanup. |
| DSPy RLM | Runs the reasoning loop with a Root model and a Sub model. |
| Daytona runtime | Owns Sandboxes, the Workspace Volume, host I/O, and cleanup. |
| Persistence | Stores Sessions, Runs, and committed Turns in SQLite or PostgreSQL through Alembic-managed schemas. |
| Terminal client | Renders live and committed Turns. It doesn't run models or own backend lifecycle. |

## The life of a Turn

A **Turn** is one user request. A **Run** is one attempt to execute it.

1. **Request.** Your client sends `POST /api/sessions/{session_id}/turns` with an `Idempotency-Key` header. The SSE stream opens immediately and emits `turn_status` heartbeats while Fleet prepares.
2. **Claim.** `TurnRuntime` claims the Run for the Session. Only one Turn runs per Session at a time.
3. **Prepare.** Fleet resolves authorized context, Attachments, selected Skills, and tools, and acquires a Daytona Sandbox.
4. **Execute.** DSPy runs the RLM loop. Generated Python runs in the Sandbox and calls back to Fleet through an authenticated broker for host tools and semantic calls.
5. **Settle.** Fleet validates the result and any candidate Artifacts.
6. **Commit.** The answer and Artifacts become durable only through a successful Turn Commit. Late work can't change a settled Turn.
7. **Clean up.** Fleet releases or retires the Sandbox.

## Where state lives

* **Committed Turns** are the conversation history. Fleet projects them into a native `dspy.History` for the next invocation.
* **The task checkpoint** keeps a bounded goal and progress record for the Session. Read it with `/task` or `GET /api/sessions/{session_id}/task`.
* **The Workspace** holds files, memory, Skills, Attachments, and Artifacts on a Daytona Volume.
* **Python variables** in the Sandbox are not durable state. A healthy Sandbox can be reused across sequential Turns, but each invocation starts with fresh bindings, tools, budget, and DSPy history.

See [Sessions and workspaces](/fleet-rlm/concepts/sessions-and-workspaces) for details.

## Runtime policy

Non-secret policy lives in `config/fleet.toml`. The file names the environment variables that hold secrets. Fleet reads it once at startup, so changes take effect after a restart. See the [configuration reference](/fleet-rlm/reference/configuration).

## Related pages

* [Reasoning and recursion](/fleet-rlm/concepts/reasoning-and-recursion)
* [Sandbox execution](/fleet-rlm/concepts/sandbox-execution)
* [Stream events](/fleet-rlm/reference/stream-events)


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