Retriever
Technical blog

Retriever: Composing the Perception-Reasoning-Action Loop for Long-Horizon Manipulation

A framework for composing closed-loop asynchronous robot programs.

A foundation-model call can take seconds, but the environment does not pause during inference: control must continue, and the result may be stale when it arrives. Unlike layers in a deep learning graph, robot modules must also compose in time: when each runs and which inputs it consumes. We call this temporal compositionality. Retriever makes these temporal choices explicit in the graph, separate from module code, so they can be specified and inspected.

This post walks through the design requirements, how they lead to three primitives, the guarantees they give, the runtime and middleware comparison, and the evidence. The home page shows the Retriever-0 robot agent and its program.

Design requirements

A foundation model may think for seconds while the controller must keep acting. So a robot program must say when each part runs and what it reads.

Compose modules
and their timing.

Temporal compositionality. Reusable Flows compute from their inputs and local state. Each Flow declares a Clock, and each input edge declares a Sync policy. Feedback such as inspect, update memory, replan, run the next skill is wired in the graph, not hidden in callbacks.

Paper: D1 compositionality, D3 closed‑loop modularity

Slow models,
fast control.

Physical time. A foundation-model call may take seconds while control must keep acting. Flows run side by side, each on its own Clock. At each tick, a Sync policy decides which inputs a Flow reads, whether the producer is faster or slower: drop stale data, play back an action chunk, time out, or fall back when an input lags.

Paper: D2 asynchronous multi‑rate, D4 explicit time semantics

Replay what ran,
and when.

Replayable timing. With deterministic Flows and Sync policies, fixed initial states, recorded inputs, clock and commit decisions (including lag), fixed random draws, strictly causal feedback, and same-tick reads in dependency order, the agent's output history is unique under replay. It replays the program, not the physical world. Timing is declared in the graph, not in the backend, so the same graph and its declarations run on any backend with an adapter; live traces can still differ.

Paper: D5 determinism and replay, D6 supported backend mapping

The six design requirements (D1–D6)
RequirementQuestion it answersDrawer-search example
D1 · CompositionalityCan a stateful component be reused?Memory keeps which drawers were checked
D2 · Asynchronous multi-rateWhen does each component run?Planning is slow, control is fast
D3 · Closed-loop modularityCan information flow back upstream?Skill progress returns to the monitor
D4 · Explicit time semanticsWhich inputs belong to each invocation?Each policy call reads specific camera frames
D5 · Determinism, replay, and debuggabilityWhen can we replay the computation?Deterministic modules, fixed initial states, logged inputs, clocks, and random draws
D6 · Supported backend mappingIs the program separate from its runtime?Same program runs in-process, across processes, or on Dora

From requirements to primitives

Each part of Retriever’s design answers one of these requirements directly:

Three primitives

We lift the standard agent–environment loop to continuous time: observations, computation completions, and actions become streams over event time rather than values locked to one global step. A causal map between these streams is a causal stream function (CSF). A Flow is a CSF bound to a clock and sync policies: the CSF fixes what it computes, the clock when it runs, and the sync policies which aligned snapshot it consumes.

Flow(F,C,σ):Stream(I)→Stream(O)\mathsf{Flow}(\mathcal{F}, \mathcal{C}, \sigma) : \mathsf{Stream}(\mathcal{I}) \to \mathsf{Stream}(\mathcal{O})

In code, a clock attaches to a Flow with @, and each edge declares its sync policy:

# 1) Define Flows (what) + run clocks (when)
vla = VLASkillFlow("pi05") @Rate(hz=2)
robot = ControllerFlow(id=0) @Rate(hz=200)
# 2) Build the graph (composition + sync on edges)
with pipe:
wrist_cam.then(vla, sync=Latest())\
.then(robot, sync=Latest())

Flow: what it computes

A Flow is analogous to nn.Module in PyTorch: a stateful Python class with typed inputs and outputs that you can instantiate, call directly with flow(inp), and compose with others—no async runtime required for local testing. The difference is that PyTorch has no notion of when a module runs or how long computation takes; Retriever adds that timing layer by binding each Flow to one declared clock and attaching sync policies to its incoming edges.

At the kk-th tick tkt_k, a Flow evaluates its synchronous local transition

(htk+,  ytk)  =  f(htk−,  xtk),(h_{t_k^+},\; y_{t_k}) \;=\; f(h_{t_k^-},\; x_{t_k}),

where ht−h_{t^-} and ht+h_{t^+} are the local state immediately before and after the event, and xtkx_{t_k} is the synchronized input snapshot consumed by the step. Every Flow owns exactly one run clock, enforcing single-threaded sequential semantics per module.

# Example: a VLA skill flow @2Hz
# (wrist cam, robot state, SkillCmd) -> ActionChunk
class VLASkillFlow(Flow):
def reset(self):
self.skill = None
def step(self, inp):
# inp is aligned by sync policies
cam_obs, state, skill_cmd = inp
self.skill = skill_cmd
return self.vla(cam_obs, state, self.skill)

Inputs are aligned before step(inp); the Flow owns local state and runs on its one declared clock.

Full typed Flow and Retriever-0 port-mapping example
from dataclasses import dataclass
from retriever import Flow, io
@io
@dataclass
class VLAInput:
camera: CameraData
state: RobotState
skill_cmd: SkillCommand
class VLASkillFlow(Flow[VLAInput, ActionChunk]):
def __init__(self, model_name: str):
self.processor = load_vla_processor(model_name)
self.policy = load_vla_policy(model_name)
self.last_chunk = None
def reset(self):
self.last_chunk = None
def step(self, inp: VLAInput) -> ActionChunk:
model_inputs = self.processor.prepare(
image=inp.camera.rgb,
proprio=self._encode_state(inp.state),
instruction=inp.skill_cmd.text,
previous_chunk=self.last_chunk,
)
raw_actions = self.policy.sample_actions(model_inputs, horizon=8)
chunk = self.processor.decode_chunk(raw_actions, reference_state=inp.state)
self.last_chunk = chunk
return chunk
# Direct local call without any runtime infrastructure:
vla = VLASkillFlow("pi05")
chunk = vla(VLAInput(camera=cam_frame, state=robot_state, skill_cmd=cmd))
# Illustrative Retriever-0 port mappings; field and trigger names are simplified
wrist_cams = WristCameraFlow() @ Rate(hz=30)
head_cam = HeadCameraFlow() @ Rate(hz=30)
goal = GoalFlow() @ Rate(hz=1)
belief = BeliefMemoryFlow() @ Trigger("inspection_done")
planner = VLMPlanFlow("gemini") @ Trigger("replan_request")
monitor = ExecMonitorFlow() @ Trigger("belief_or_progress")
vla = VLASkillFlow("pi05") @ Rate(hz=2)
ctrl = ControllerFlow() @ Rate(hz=200)
teleop = TeleopFlow() @ Rate(hz=100)
with Pipeline("Retriever-0") as pipe:
goal.then(planner, map={"task": "task"}, sync=Latest())
goal.then(monitor, map={"task": "task"}, sync=Latest())
wrist_cams.then(belief, map={"frame": "frames"}, sync=Latest())
belief.then(planner, map={"belief": "state"}, sync=Latest())
belief.then(monitor, map={"belief": "state"}, sync=Latest())
head_cam.then(planner, map={"frame": "frame"}, sync=Latest())
planner.then(monitor, map={"result": "planner_result"}, sync=Latest())
monitor.then(planner, map={"replan_trigger": "context"}, sync=Latest())
monitor.then(belief, map={"inspection_done": "inspection"}, sync=Latest())
monitor.then(vla, map={"current_skill": "prompt"}, sync=Latest())
vla.then(monitor, map={"feedback": "policy_feedback"}, sync=Latest())
wrist_cams.then(vla, map={"frame": "obs_dict"}, sync=Latest())
vla.then(ctrl, sync=Latest())
teleop.then(ctrl, sync=Latest())
pipe.run(backend="dora", duration=300.0)

Clock: when it runs

A clock C\mathcal{C} defines when a module runs. Clocks can be periodic, event-driven, a union of both, or driven by external synchronization signals. Event time remains continuous; clocks induce local decision epochs, so composition yields interleaved local steps rather than one global step sequence. In Retriever-0, the cameras run at @Rate(hz=30), the VLA at @Rate(hz=2), the controller at @Rate(hz=200), and the planner at @Trigger("replan").

Sync policy: which inputs each run consumes

Each Flow runs on its own clock, so upstream outputs arrive at different rates and times, and each Flow must align its inputs locally. A sync policy is a deterministic function of the upstream inputs and their timestamps. Before each step(), it selects values from the committed upstream histories and builds one input snapshot. Downstream sync policies read events committed up to their own tick, with events of the same tick read in dependency order, and a Prev() edge reads only events committed before the tick.

For example, an edge carries the (time, value) events (0.10, 1), (0.20, 4), (0.35, 9), (0.60, 16), and the consumer ticks at 0.50. Assume each event becomes visible at its timestamp; the history visible at this tick drops the future event at 0.60. The same history then yields different snapshots under different policies:

hist = edge.visible_history(0.50)
sync(Latest(), hist) -> 9
sync(Window(duration=0.30), hist) -> [4, 9]
sync(Window(duration=0.45), hist) -> [1, 4, 9]

Latest samples and holds at the downstream tick, Window(duration=w) keeps events timestamped in [t − w, t], and Join bundles synchronized edge values into one downstream input record. A sensor timestamp alone does not establish that the event had arrived by the tick. When compute cannot keep up, the user chooses the fallback for each edge and clock: hold the last valid value for a bounded duration, mark an input missing or expired, trigger a safe fallback, or raise an error in debug mode.

A downstream step() consumes a synchronized snapshot assembled by deterministic policies such as Latest() and Window() from asynchronous streams.

Temporal chunking

Between Flows with mismatched rates, plan chunks and action chunks carry time-extended outputs, so slow planning overlaps skill execution and 2 Hz inference keeps 200 Hz control fed. Chunking uses the same primitives, as a buffering policy on an edge or as a small Flow.

High-level planning, low-level skills, and controller timelines with computation intervals and plan and action chunks.

Arrows are computation intervals; blocks are chunk-validity horizons. Overlap keeps downstream clocks running while the next plan or action chunk is produced.

Theoretical guarantees

Closed-loop composition makes these graphs cyclic. Instantaneous cycles would impose algebraic constraints such as xt=f(xt)x_t = f(x_t). Therefore every directed cycle must contain at least one delay or strictly causal edge whose consumer sees only producer events from times <t<t. A finite graph of CSFs is itself a CSF when its feedback is strictly causal and its events are locally finite.

Proposition 1 (Closure of Flows)

If all its ticks, including event-driven ones, are locally finite and its same-instant dependencies are acyclic, a finite graph of Flows is again a Flow: for fixed initial states, boundary inputs, and a fixed clock/commit trace (including lag decisions), it has one behavior, and one Flow on the covering clock (the union of all tick and commit times in the graph) gives the same boundary outputs.

Theorem 1 (Expressiveness)

Any deterministic policy in the asynchronous agent–environment loop with locally finite decision times, computable transitions, fixed-size memory, finite aligned inputs from committed observation histories via deterministic sync policies, and strictly causal feedback can be implemented by a Retriever graph with the same action stream for every committed observation history and clock/commit trace.

The proof constructs a single-rate policy as a Scan, optionally followed by a Map, under one Clock; multi-rate policies couple such loops through deterministic sync edges. Policies whose actions depend on message arrival order, or on wall-clock reads that are not logged as input streams, fall outside this class. A stream of realized draws, seeds, or logged model outputs extends the result to stochastic policies.

Theorem 2 (Functional Determinism)

For a finite graph, fix deterministic Flow code and sync policies, initial states, committed external-input histories, and a locally finite clock/commit trace (including lag decisions and which commits each consumer sees at each tick), with strictly causal feedback and same-tick reads in dependency order. If stochastic calls use logged outputs or deterministic sampling with fixed seeds, the output history is unique and independent of runtime scheduling.

Replay requires initial states, consumed input identities and payloads, consumer-visible histories, clock/commit decisions (including lag and tie decisions), and stochastic seeds or outputs.

Runtime

Retriever separates graph definition from execution:

  1. Definition (Python). Users define Flows and connect them into a graph. This code is declarative; no threads are spawned yet.
  2. Compilation (IR). The system compiles the Python objects into a static IR that captures topology, clock definitions, and synchronization parameters.
  3. Execution (actors). The IR is sent to a backend. Each actor typically runs one Flow with its own state; edges become message channels and deterministic adapters.

The same graph can run with supported executors, including in-process stepping, multiprocessing, and Dora: pipe.step(dt=0.1) runs in the main process for debugging, and pipe.run(backend="dora") runs asynchronously to deploy. Live clock/commit traces can differ across backends, and graph portability alone does not guarantee real-time deadlines. ROS 2, Dora, and other messaging substrates still handle transport and device integration; Retriever complements this communication layer at a higher level of abstraction. The home page shows recording and replaying a run.

01

Definition

Write Flows, clocks, ports, and edge policies as one agent graph. No runtime placement is implied yet.

02

Clear semantics

Clocks and sync policies define input selection from visible histories. Exact replay also fixes initial states, the clock/commit trace, and stochastic outcomes.

03

Runtime mapping

Dispatch the graph to local stepping, multiprocessing, or a supported transport backend while preserving the same consumed-input contract.

04

Hardware abstraction

Device and transport adapters sit below the graph, so hardware-specific behavior is not treated as part of the algorithm.

Illustrative IR snippet
{
"version": "1.0.0",
"metadata": {
"name": "Agent",
"validated": true,
"optimized": false
},
"nodes": [
{
"id": "camera",
"type": "CameraSourceFlow",
"config": {"clock": {"Rate": {"hz": 30}}}
},
{
"id": "vla",
"type": "VLASkillFlow",
"config": {"clock": {"Rate": {"hz": 2}}}
}
],
"edges": [
{
"source": {"node": "camera", "port": "rgb"},
"destination": {"node": "vla", "port": "camera"},
"adapter": {"latest": {"buffer_size": 1}},
"qsize": 10
}
],
"topology": {
"node_count": 2,
"edge_count": 1,
"has_cycle": false
}
}
Execution modes: in-process, multiprocess, and Dora

The same authored graph can be lowered into several execution modes:

  • in-process for local debugging and deterministic stepping, where pipe.step() lets you inspect one logical firing at a time
  • multiprocess when you want isolation between modules on one machine while keeping the same authored graph
  • Dora-backed execution when you want the same graph on a different runtime substrate with explicit transport underneath

What changes between those modes is the execution mapping underneath the graph, not the authored graph itself. The Python Flow classes, the clocks, and the edgewise sync policies stay fixed while the runtime decides how to place and schedule them.

Middleware comparison

Program semantics are separate from communication: different communication substrates can support the same abstraction. Retriever makes activation clocks and input selection explicit in the authored graph, whereas ROS 2 and Dora provide transport and scheduling tools on top of which applications define their own callback, buffer, and timer contracts.

RetrieverPub/Sub (ROS 2, Dora)

Authoring model

Ordinary step() code over one aligned input

Async coordination logic spread across callbacks, timers, and topic state

Time semantics

Explicit clocks and sync policies select from consumer-visible histories

The application defines its input-selection contract using callbacks, buffers, and timers

Functional determinism

Same outputs under the fixed-trace replay conditions above

Equivalent contracts can reproduce the same selections and decisions; transport alone does not define them

Variable latency

Declared via clocks, triggers, and buffer policies

Manual worker threads, queues, drop logic, and stale-data handling

Illustrative code: Retriever vs. ROS 2

The snippets below omit message definitions and model-loading boilerplate. They show where timing, buffering, and launch logic end up.

from dataclasses import dataclass

from retriever import Flow, Pipeline, Rate, Latest, io
from retriever.flow import Trigger

@io
@dataclass
class VLAInput:
  camera: "CameraFrame"
  state: "RobotState"
  active_skill: "SkillCommand"

class PlannerFlow(Flow["BeliefState", "PlanChunk"]):
  def step(self, belief):
      return self.vlm_plan(belief)

class VLASkillFlow(Flow[VLAInput, "ActionChunk"]):
  def step(self, inp):
      return self.vla(inp.camera, inp.state, inp.active_skill)

with Pipeline("Agent") as pipe:
  cam = CameraSourceFlow() @ Rate(hz=30)
  belief = BeliefUpdaterFlow() @ Trigger("observation")
  planner = PlannerFlow("gemini") @ Trigger("state")
  monitor = ExecutionMonitorFlow() @ Trigger("belief_or_progress")
  vla = VLASkillFlow("pi05") @ Rate(hz=2)
  ctrl = ControllerFlow() @ Rate(hz=200)

  cam.then(belief, sync=Latest())
  belief.then(planner, sync=Latest())
  belief.then(monitor, sync=Latest())
  planner.then(monitor, sync=Latest())
  cam.then(vla, sync=Latest())
  monitor.then(vla, sync=Latest())
  vla.then(ctrl, sync=Latest())

if __name__ == "__main__":
  pipe.run(backend="dora", duration=30.0)

Design lineage

Retriever draws on classic systems ideas while adapting them to cyclic, stateful, latency-sensitive robot agents whose graphs must specify both what data flows and when each output is valid.

UNIX

Composable processes. Small units become powerful when connected by simple streams; Retriever keeps that compositional instinct while adding clocks, feedback, and typed temporal handoff.

PyTorch

Graphs as program structure. ML frameworks make computation graphs concrete enough to inspect and execute; Retriever uses a graph boundary for stateful robot Flows over time.

Ray

Actors as runtime units. Actor systems are a natural execution model for independent modules; Retriever uses that lesson below the programming model while preserving graph semantics.

ROS

Robotics middleware. Robot systems need practical message passing and device integration; Retriever focuses on the agent-level timing and handoff contract above that substrate.

Evidence

The evaluation asks three questions. Capability: can Retriever support long-horizon real-world manipulation that coordinates slow reasoning (VLM), medium-frequency skills (VLA), and fast control? Efficiency: how much transport overhead does Retriever add, and how does the pipeline behave when each of four architectural features is removed? Usability: does making time explicit help reproduce, replay, and debug agent behavior?

Capability and ablations

Retriever-0 runs on a bimanual robot in two tasks. In spice search, spice bottles are placed across four closed drawers, with the target in the second, third, or fourth drawer. In bag retrieval, one arm lifts and steadies a deformable bag while the other reaches in to retrieve the target item. Task progress is the fraction of the task’s skills completed, with partial credit for the skill in progress; it is not a success rate.

The full pipeline reaches 73% on spice search (averaged over the three cases) and 100% on bag retrieval. The policy-only baselines receive camera observations, robot state, and the language goal, but no explicit planner, belief memory, execution monitor, or skill-program structure. They score 0% on the drawer cases; on bag retrieval, π0.5 reaches 41% and the diffusion policy 23%.

The full pipeline makes the most progress on both tasks; policies alone reach 0% on drawer search.

Condition Drawer searchBag retrieval
Full pipeline 73% 100%
− Plan chunking 63% 93%
− Progress prediction 12.5% 25%
− Belief memory 20% 66%
− Replanning 15% 47%
π0.5 alone 0% 41%
Diffusion policy alone 0% 23%
Table III: reported task progress (fraction of skills completed, with partial credit), not a success rate. Drawer values are averaged over the three cases. The teleoperation-assisted condition is not shown.

Each ablation removes one feature:

Table III as published
ConditionSpice: proj. timeSpice: task progressBag: proj. timeBag: task progress
Retriever-0 (full)56 s73%36 s100%
− Plan chunking65 s63%37 s93%
− Progress prediction—12.5%—25%
− Belief memory—20%45 s66%
− Replanning—15%—47%
+ Human-in-the-loop50 s100%35 s100%
π0.5 (VLA only)—0%41 s41%
Diffusion policy only—0%40 s23%

Projected time divides elapsed time to best progress by that progress, rounded to seconds. It is a descriptive linear normalization, not measured completion time or a validated speedup estimate. ”—” denotes a stalled or otherwise non-projectable run. The human-in-the-loop condition uses teleoperation; it is not autonomous.

Efficiency: message-passing overhead

Overhead

Message latency benchmark

Retriever adds little overhead to the transport it runs on: with the Dora backend, it closely matches native Dora.

Compared with the ROS 2 process-based baselines (Python and C++), Retriever-Dora has higher median latency for small payloads, from 512 B through 64 KB (through 256 KB for C++), and lower latency from about 512 KB upward. The figure also shows a stronger ROS 2 C++ components baseline, in which composable nodes share one process; it should be compared with Retriever’s single-process backend, which has lower latency for small messages used in control and coordination.

Latency benchmark results across payload sizes.

Producer–consumer message latency versus payload size.

Differentiability

Hybrid differentiable physics

A discrete bouncing-ball program combines numerical integration with impact branches over 100 steps of 0.01 s; fixing which earlier state each step reads fixes the differentiated program.

Path-gradient consistency. The nominal loop produces one identical trace and gradient (−0.005496) across 100 runs, while an arbitrary-history stress variant (uniform earlier state with probability 0.2) yields a gradient standard deviation of 0.1788.

Illustrative bouncing-ball trajectories with discrete impact events.

Illustrative bouncing-ball trajectories with discrete impact events.

Histogram of discrete-program path gradients comparing identical nominal runs against arbitrary-history state selection.

Discrete-program gradients of squared terminal-height loss across 100 runs: the nominal loop gives one gradient (−0.005496, matching the dashed central finite-difference reference), while arbitrary-history state selection spreads across runs (σ = 0.1788).

Usability: determinism and replay

Theorem 2 gives the replay guarantee for a fixed trace.