dspy.RLM runtime with a FastAPI SSE transport in front of it. The backend is a thin coordination shell. One Run drives one fresh native dspy.RLM inside one interpreter context, and every observable behavior traces back to that pairing.
The client surface is the pi-tui terminal client at
tools/fleet-tui/, launched by fleet cli. There is no WebSocket execution surface, no SPA, and no /api/v1 prefix in the current codebase.Layers at a glance
The Run coordination lane is the live center. Transport, persistence, and Skills all attach to it, and none of them replace it.Runtime flow of one turn
- The client posts to
POST /api/sessions/{session_id}/turnswith anIdempotency-Keyheader. - The transport resolves a deterministic local scope and validates the Turn input.
- Attachment ownership and exact Skill selection are validated before any Run work begins.
TurnCoordinator.open()begins the SSE stream, coordinates heartbeat, terminal ordering, and cleanup.RunLifecycle.begin()performs an atomic Run claim or a replay of an already-settled Run.DefaultRunPreparer.prepare()assembles context, tools, and environment resources for the Run.RLMRunnerruns one fresh nativedspy.RLMinside one interpreter context.- Runtime Events stream from the native trajectory, the interpreter, and the host-tool boundaries.
RunLifecycle.finish()validates the typed result and the private snapshot, promotes Artifact Candidate bytes on Daytona only, and commits Turn, Run, Checkpoint, and Artifact atomically or settles the failure.- The Run emits any
artifact.created*events and then exactly onerun.completedterminal event. TurnCoordinatorruns cleanup and the Interpreter Lease is released.
Root delegation ladder
Delegation inside one Run is a fixed four-step ladder:- Python — deterministic work inside the interpreter context.
- Native
llm_query/llm_query_batched— semantic work at the native boundary. rlm_query— one iterative isolated subproblem.- Root-only
rlm_query_batched— ordered independent child RLMs.
RLM_NATIVE_CHILD_DEPTH = 1 is a fixed product invariant, not a tunable policy value. Fleet reserves the shared recursive budget atomically and controls sibling concurrency through recursion_max_parallel_children. See Recursive RLM for the child scheduling contract.
Layers in detail
FastAPI transport — src/fleet_rlm/api/
app.create_app() builds the FastAPI app and eagerly constructs the immutable bundled Skill catalog. The lifespan validates settings and installs exactly one complete Daytona runtime inventory. The transport does not contain business logic.
Turn coordination — src/fleet_rlm/chat/
The chat package owns the per-Turn lifecycle. TurnCoordinator sequences the SSE stream. RunLifecycle owns the Run claim, the private result snapshot, Artifact publication, atomic Turn Commit, and post-commit Memory promotion. Memory promotion is bounded and settled before the Run lease is released.
Native RLM runner — src/fleet_rlm/rlm/
RLMRunner runs one fresh native dspy.RLM per Run. Within one Run, interpreter calls reuse one context so Python state persists across RLM iterations. Every later Run receives a fresh context.
Daytona substrate — src/fleet_rlm/daytona/
Daytona owns provisioning, lifecycle, filesystem, and Workspace operations through one process-owned AsyncDaytona. WorkspaceVolumeGateway.open_workspace() scopes each grouped I/O to one ephemeral Sandbox that is deleted before the context exits.
See Daytona runtime for the substrate deep cut.
Composition — src/fleet_rlm/composition/
Composition modules assemble runtime inventories for tests and specialized entry points. The lifespan never installs these directly, and tests import them explicitly.
Persistence — src/fleet_rlm/persistence/
Schema is Alembic-managed. The Turn repository is the durable seam between coordination and storage.
Sessions and assistant parts — src/fleet_rlm/sessions/
sessions/assistant_parts.py owns the closed Pydantic AssistantPart vocabulary for durable assistant content. Any new assistant content shape lives here first.
Skills — src/fleet_rlm/skills/
The bundled Skill catalog is immutable and is constructed eagerly during create_app(). Bundled Skills are dspy-rlm, long-context, workspace-files, data-analysis, and report-builder. Each Skill’s contract lives in its bundled SKILL.md and its resolver in src/fleet_rlm/skills/.
Reading order
Read these files in order when you need to understand the live backend:src/fleet_rlm/api/app.pysrc/fleet_rlm/api/routes/turns.pysrc/fleet_rlm/chat/turn_coordinator.pysrc/fleet_rlm/chat/run_lifecycle.pysrc/fleet_rlm/rlm/runner.pysrc/fleet_rlm/daytona/interpreter.py
Source of truth
Transport and lifespan
src/fleet_rlm/api/ — routes, SSE, UI stream, OpenAPI derivation.Turn coordination
src/fleet_rlm/chat/ — coordinator, lifecycle, preparation, execution.Daytona substrate
src/fleet_rlm/daytona/ — interpreter, workspace gateway, recursive child runtime.Runtime configuration
config/fleet.toml — the certified runtime configuration surface.openapi.yaml.