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

# Agent model

> How fleet-rlm runs one fresh native dspy.RLM per Turn, composes bounded Signatures, and selects the cheapest-sufficient step on the Root delegation ladder.

fleet-rlm has no persistent Agent object. One Turn runs one fresh native `dspy.RLM`, driven by `RLMRunner` at `src/fleet_rlm/rlm/runner.py`. Every Turn starts clean, sees a bounded slice of context, and decides its next step against a fixed delegation ladder.

## One Turn, one native RLM

`RLMRunner` constructs a fresh `dspy.RLM` for the Turn. There is no long-lived Agent, no ReAct wrapper, and no ambient AgentRuntime state. Turn state lives on the coordinator, and RLM state exists only for the length of that Turn.

The runner composes three inputs before it calls `dspy.RLM.acall()`:

1. A Signature describing the Turn's input and output contract.
2. A default instruction fragment set assembled from `src/fleet_rlm/rlm/instructions.py`.
3. A fixed core Tool inventory plus `load_skill` and `read_skill_resource`.

Custom Skill Signatures keep their existing JSON-compatible common input annotations. The default Signature uses strict local Pydantic DTOs, and conversion plus JSON serialization happen once immediately before the native call.

## Bounded Signature

Every Signature receives the user request text, a bounded `session_context`, bounded `skill_cards`, and bounded Attachment metadata. Full committed history stays host-side and is reached through the `read_session_history` Tool.

```python theme={null}
from pydantic import BaseModel, Field
import dspy


class SessionContext(BaseModel):
    workspace_id: str
    recent_turn_digest: str = Field(max_length=4000)
    memory_digest: str = Field(max_length=2000)


class SkillCard(BaseModel):
    id: str
    version: str
    summary: str = Field(max_length=400)


class AttachmentRef(BaseModel):
    attachment_id: str
    kind: str
    byte_size: int


class RootTurnSignature(dspy.Signature):
    """Fleet Root default Signature (illustrative)."""

    request: str = dspy.InputField()
    session_context: SessionContext = dspy.InputField()
    skill_cards: list[SkillCard] = dspy.InputField()
    attachments: list[AttachmentRef] = dspy.InputField()
    answer: str = dspy.OutputField()
```

## Instruction composition

`src/fleet_rlm/rlm/instructions.py` owns the default Fleet Root instruction fragments. The runner composes:

* The base Root fragment.
* REPL guidance for Python execution.
* Tool inventory guidance for the fixed core Tools.
* Optional recursion guidance when the profile enables `rlm_query` and `rlm_query_batched`.
* Verification guidance for evidence review before `SUBMIT`.
* Bounded-context guidance for `session_context`, `skill_cards`, and Attachments.

Disabling recursion drops the recursion fragment from composition. It no longer requires deleting text from a monolithic Signature docstring.

## Root delegation ladder

The Root selects the cheapest sufficient step for each subproblem. Higher rungs cost more and see more.

| Rung | Step                               | When to use                                                                      |
| ---- | ---------------------------------- | -------------------------------------------------------------------------------- |
| 1    | Python in the interpreter          | Deterministic work: parsing, slicing, arithmetic, file walks.                    |
| 2    | `llm_query` or `llm_query_batched` | Semantic work that fits current context. No new RLM.                             |
| 3    | `rlm_query`                        | One iterative isolated subproblem in a native child harness.                     |
| 4    | `rlm_query_batched` (Root-only)    | Ordered, bounded sibling fan-out. Root verifies and synthesizes before `SUBMIT`. |

The Root always verifies and synthesizes evidence from rung 4 before it emits `SUBMIT`.

## Skills and progressive disclosure

The bundled Skill catalog is `dspy-rlm`, `long-context`, `workspace-files`, `data-analysis`, and `report-builder`. Only bounded Skill Cards appear at startup. A full `SKILL.md` loads only when the RLM invokes `load_skill` or when the card is exactly preselected. Declared resources load only after the Skill body.

Without explicit selections the RLM sees the full bundled catalog and may load up to four advertised Skills during the Turn. Explicit `skill_selections` accept up to four unique entries of `{id, expected_version}`. Selections advertise, preload, and restrict the Turn to authorized cards. Selections fold into the Turn idempotency fingerprint.

Only `data-analysis` supplies a custom validated DSPy Signature. `report-builder` and `dspy-rlm` are instruction-only. At most one selected Skill may provide a validated DSPy Signature.

Skill Markdown and resources cannot register host Tools. Runtime composition owns the fixed core Tools plus exactly `load_skill` and `read_skill_resource`.

## Recursive children

`RLM_NATIVE_CHILD_DEPTH = 1` is a fixed product invariant. It is not an editable policy value. Recursion is one native level deep.

The `daytona-recursive` profile enables recursion. The default `daytona` profile keeps recursion disabled. When enabled, each child receives:

* A fresh Daytona Sandbox with ordinary Daytona egress.
* The same Volume ID mounted at `recursive/<workspace-id>/<run-id>/<call-index>`.
* No access to the Root `workspaces/<workspace-id>` mount.
* No Fleet Tools and no host credentials.

Strict cleanup purges child scope and deletes the child Sandbox before the Root success can commit. Sibling concurrency is bounded by `recursion_max_parallel_children`, which defaults to `2`.

See [Recursive RLM](/fleet-rlm/concepts/recursive-rlm) for the full child lifecycle.

## Autonomous memory (opt-in)

`rlm.autonomous_memory_categories = []` is the default. When the allowlist is empty the runtime omits `propose_memory` from the Root Tool inventory entirely.

A non-empty allowlist enables a Root-only, Run-scoped candidate collector. Promotion runs post-commit on a best-effort basis. Promotion is never exactly-once, and callers should treat it as advisory.

## Configuration

Model, provider, token, and recursion policy all live in `config/fleet.toml` under the selected profile. Models come from provider-service references, not from environment variables like `DSPY_LM_MODEL`.

| Setting                            | Location                       | Notes                                                            |
| ---------------------------------- | ------------------------------ | ---------------------------------------------------------------- |
| Root and Sub model                 | Profile in `config/fleet.toml` | All committed profiles use `deepseek-v4-flash`.                  |
| Provider credentials (interactive) | OpenCode Go                    | `FLEET_OPENCODE_GO_API_KEY`, `FLEET_OPENCODE_GO_BASE_URL`.       |
| Provider credentials (managed)     | Databricks AI Gateway          | Configured on the profile.                                       |
| Recursion policy                   | Profile                        | `daytona-recursive` enables `rlm_query` and `rlm_query_batched`. |
| Sibling parallelism                | Profile                        | `recursion_max_parallel_children`, default `2`.                  |
| Autonomous memory allowlist        | Profile                        | `rlm.autonomous_memory_categories`.                              |

See [Configuration](/fleet-rlm/reference/configuration) for the full profile schema.

## See also

<CardGroup cols={2}>
  <Card title="Recursive RLM" href="/fleet-rlm/concepts/recursive-rlm">
    Child harness lifecycle, sibling fan-out, and evidence synthesis.
  </Card>

  <Card title="Daytona runtime" href="/fleet-rlm/concepts/daytona-runtime">
    Sandbox lifecycle, Volume Scope, and workspace mounts.
  </Card>

  <Card title="HTTP API" href="/fleet-rlm/reference/http-api">
    Turn endpoints, SSE stream, and Attachment upload.
  </Card>

  <Card title="Configuration" href="/fleet-rlm/reference/configuration">
    Profiles, providers, recursion, and memory policy.
  </Card>
</CardGroup>
