fleet-rlm is a Daytona-backed recursive runtime wrapped by a thin transport shell and a narrow hosted-policy layer.
Three choices drive the shape of this codebase. They are intentional, not accidents of scope:
-
The backend is intentionally thin. The Python layer is a transport + orchestration shell over
dspy.ReAct,dspy.RLM, and Daytona sandboxes. "Intelligence" lives in DSPy (upstream) and in how recursive child sandboxes are scheduled (this repo). Expect to find plumbing insrc/fleet_rlm/api/and policy insrc/fleet_rlm/runtime/— not business logic mixed into request handlers. -
The UI is treated as core, not peripheral. The runtime emits streaming events, code-execution results, and artifacts that only make sense in an interactive surface. Hiding them behind CLI-only access would throw away most of the runtime's observability. That is why
src/frontend/is comparable in line count tosrc/fleet_rlm/— the UI is surfacing work the runtime does, not duplicating it. -
Two agent layers, both
dspy.*, both real.- Chat surface:
dspy.ReActatsrc/fleet_rlm/runtime/agent/agent.pyhandles turn-taking, tool dispatch, and the user-visible conversation loop. - Recursive engine:
dspy.RLMis assembled throughsrc/fleet_rlm/runtime/modules/factory.pyand the module registry insrc/fleet_rlm/runtime/modules/registry.py(with delegation atsrc/fleet_rlm/runtime/tools/rlm_delegate.py). Inputs cross into Daytona as sandbox-serializable payloads; sub-queries are dispatched recursively, bounded bymax_iterationsandmax_llm_calls; sandboxes are isolated per delegation.
The chat agent is the entry point; the recursive engine runs when a task exceeds what a single ReAct context can handle. Both use DSPy's module abstractions and share a single LLM-call budget across a recursive tree (see the
Recursive RLM isolationsection below). - Chat surface:
- Thin FastAPI/WebSocket transport in
src/fleet_rlm/api/ - Runtime core in
src/fleet_rlm/runtime/andsrc/fleet_rlm/integrations/daytona/ - Offline evaluation and optimization in
src/fleet_rlm/quality/
graph TB
CLIENTS["CLI / Web UI"] --> API["FastAPI transport\napi/main.py\napi/routers/*\napi/runtime_services/*"]
API --> RUNTIME["runtime/\nchat agent + execution helpers + modules"]
RUNTIME --> DAYTONA["integrations/daytona/\ninterpreter + runtime + filesystem"]
API --> EVENTS["api/events/\nexecution event shaping"]
API --> PERSISTENCE["integrations/local_store.py\nintegrations/database/"]
RUNTIME --> QUALITY["quality/\noffline GEPA + DSPy optimization"]
Primary files:
src/fleet_rlm/api/main.pysrc/fleet_rlm/api/routers/ws/endpoint.pysrc/fleet_rlm/api/runtime_services/chat_runtime.pysrc/fleet_rlm/api/runtime_services/chat_persistence.pysrc/fleet_rlm/api/runtime_services/diagnostics.pysrc/fleet_rlm/api/runtime_services/settings.pysrc/fleet_rlm/api/runtime_services/volumes.py
Responsibilities:
- App factory, lifespan, route mounting, and SPA asset serving
- Auth-derived HTTP and websocket identity
- Session lookup, runtime preparation, and service orchestration
- Websocket lifecycle and execution-event envelope delivery
- Runtime settings, diagnostics, and Daytona volume browsing
Primary files:
src/fleet_rlm/api/routers/ws/connection_loop.pysrc/fleet_rlm/api/routers/ws/turn_runner.pysrc/fleet_rlm/api/routers/ws/stream_loop.pysrc/fleet_rlm/runtime/factory.pysrc/fleet_rlm/runtime/agent/agent.pysrc/fleet_rlm/runtime/agent/runtime.pysrc/fleet_rlm/runtime/execution/*src/fleet_rlm/runtime/modules/*
Responsibilities:
- Shared chat/runtime execution
- Recursive delegation and tool execution
- Execution-event assembly and workbench hydration inputs
- Runtime module assembly, registry management, escalation, and RLM routing
Primary files:
src/fleet_rlm/integrations/daytona/interpreter.pysrc/fleet_rlm/integrations/daytona/workspace_manager.pysrc/fleet_rlm/integrations/daytona/sandbox_executor.pysrc/fleet_rlm/integrations/daytona/isolation.pysrc/fleet_rlm/integrations/daytona/runtime.pysrc/fleet_rlm/integrations/daytona/workspace_runtime.pysrc/fleet_rlm/integrations/daytona/sdk_ops.pysrc/fleet_rlm/integrations/daytona/diagnostics.py
Responsibilities:
- Public
DaytonaInterpreterfacade over typed workspace, execution, and child-delegation collaborators - Sandbox and interpreter lifecycle
- Repo checkout, workspace path staging, and durable mounted volumes
- Provider-specific diagnostics and volume normalization
- Pydantic v2 normalization at workspace config/state boundaries; lightweight dataclasses/functions on execution hot paths
Recursive RLM work has two entry points:
delegate_to_rlm()from the host ReAct tool registrysub_rlm()/sub_rlm_batched()from code running inside adspy.RLM
Both entry points use DaytonaInterpreter.build_delegate_child() so child creation follows one backend-owned policy. The default policy is RLM_CHILD_ISOLATION_MODE=auto:
- if the parent has no durable mounted volume, fork the parent Daytona sandbox into a child sandbox;
- if a durable volume is mounted, create a clean child Daytona sandbox with the same repo/ref/context paths and a child-specific
volume_subpath; - if fork creation fails and
RLM_CHILD_FORK_FALLBACK=clean, retry with a clean child sandbox; - delete child sandboxes after each recursive task.
RLM_CHILD_ISOLATION_MODE=context is retained only as a backend/local debugging opt-out. It preserves the previous same-sandbox fresh-context behavior and should not be treated as the production isolation contract. Child outputs return through the RLM answer; child files and artifacts are not promoted to the parent automatically.
When the parent turn is analyzing a local host checkout and no repo_url is available to recreate that checkout in a clean child sandbox, delegate_to_rlm() writes a bounded text snapshot of relevant local repository files into the child sandbox under artifacts/rlm-inputs/local_workspace_snapshot.txt and adds that path to the child context. This preserves child sandbox isolation while giving the child enough explicit evidence to inspect local code.
Sandbox code can call llm_query(), llm_query_batched(), sub_rlm(), and sub_rlm_batched() through the Daytona bridge. These callbacks dispatch to Fleet's interpreter methods, not DSPy's per-forward injected counters, so rlm_max_llm_calls is one shared semantic-call budget across a recursive tree. sub_rlm_batched() keeps the runtime parallelism cap at 4 while sharing that same budget across sibling children.
Session manifests on durable storage are the authoritative local restart-restore source. The manifest state payload restores:
dspy.Historyconversation turns;AgentRuntimecore memory, applied as default core memory plus persisted keys;- session-local loaded document paths;
- Daytona interpreter state, including sandbox ID, workspace path, repo/ref/context paths, volume name, and volume subpath.
Importing a session replaces session-local memory and document state instead of merging into the currently active runtime. Empty or missing state resets history, core memory, loaded documents, and sandbox buffers so switching sessions cannot leak stale agent context.
Primary files:
src/fleet_rlm/quality/*
Responsibilities:
- DSPy evaluation
- GEPA optimization
- Offline scoring, datasets, and module registry management
/health/readyGET /api/v1/auth/mePOST /api/v1/auth/ws-ticketGET /api/v1/infoGET/PATCH /api/v1/runtime/settingsPOST /api/v1/runtime/tests/daytonaPOST /api/v1/runtime/tests/lmGET /api/v1/runtime/statusGET /api/v1/runtime/volume/*GET/POST/PATCH/DELETE /api/v1/runtime/llm-profiles*GET/PATCH /api/v1/runtime/llm-rolesGET/PATCH/DELETE /api/v1/sessions/{id}GET /api/v1/sessions,/state,/{id}/turns,/{id}/stats,/{id}/traces, and/{id}/trace-debugPOST /api/v1/sessions/{id}/restore,/export, and/trace-exportGET /api/v1/sandboxesGET/DELETE /api/v1/sandboxes/{id}POST /api/v1/sandboxes/{id}/archiveGET /api/v1/runs/{run_id}/stepsGET /api/v1/optimization/statusGET /api/v1/optimization/modulesPOST /api/v1/optimization/runGET/POST /api/v1/optimization/runsGET /api/v1/optimization/runs/compareGET /api/v1/optimization/runs/{run_id},/details, and/resultsPOST /api/v1/optimization/runs/{run_id}/promotion-draftsGET/POST /api/v1/optimization/datasetsGET /api/v1/optimization/datasets/{dataset_id}POST /api/v1/optimization/transcript-datasetsPOST /api/v1/traces/feedbackWS /api/v1/ws/executionWS /api/v1/ws/execution/events
For execution-level detail on the runtime paths sketched above, see:
- Agent Runtime Execution Flow — traces a single chat turn from the WebSocket layer through
AgentRuntimeandEscalatingFleetModulerouting (CoT → ReAct → RLM), streaming, and post-turn operations. - Sandbox Execution Pipeline — details the host ↔ Daytona sandbox interaction during code execution: tool binding, session acquisition, setup injection, the Tool Bridge, the
SUBMIT()marker protocol, recursive delegation, and the nine synchronization points between host and sandbox. - DSPy Daytona Interpreter Boundary — async execution model,
asyncio.to_threadrationale, and RLM budget knobs. - Daytona Architecture — sandbox lifecycle, volumes, session continuity, and the persistent memory model.
When you need the current backend story, start here:
src/fleet_rlm/api/main.pysrc/fleet_rlm/api/routers/ws/endpoint.pysrc/fleet_rlm/api/routers/ws/connection_loop.pysrc/fleet_rlm/runtime/factory.pysrc/fleet_rlm/runtime/agent/agent.pysrc/fleet_rlm/integrations/daytona/interpreter.pysrc/fleet_rlm/integrations/daytona/runtime.py
Older transition notes may still mention orchestration_app/ and api/orchestration/. Those labels are historical only and are intentionally absent from the current tree.