feat(robot): OpenPI policy harness, H.264 trace video, rollout batching against one agent#425
feat(robot): OpenPI policy harness, H.264 trace video, rollout batching against one agent#425lukass16 wants to merge 19 commits into
Conversation
| except Exception: # not found: build it under this name | ||
| await daytona.snapshot.create( | ||
| CreateSnapshotParams(name=self.snapshot_name, image=self._image) | ||
| ) |
There was a problem hiding this comment.
Daytona snapshot probe swallows errors
Medium Severity
DaytonaRuntime._ensure_snapshot treats any snapshot.get failure like a missing snapshot and always calls snapshot.create. Transient API or auth errors can trigger a redundant create attempt and mark the snapshot resolved, hiding the real failure until sandbox startup.
Reviewed by Cursor Bugbot for commit 446a05b. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
There are 4 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 82c1ef8. Configure here.
| if self._init_sent and btype == b"mdat": | ||
| self._dispatch(self._pending) | ||
| self._pending = b"" | ||
| return len(b) # return the number of bytes written |
There was a problem hiding this comment.
MP4 sink buffer grows unbounded
High Severity
SegmentEncoder.write advances _scan after extracting MP4 boxes but never discards consumed bytes from _buf, while _pos keeps growing with every mux write. Each camera encoder retains a full copy of all muxed output for the episode, so long rollouts or many cameras can inflate memory without bound.
Reviewed by Cursor Bugbot for commit 82c1ef8. Configure here.
| # Start camera video at env's control rate; capture trace id for encoder span attribution. | ||
| self._video = video.VideoStreamer( | ||
| fps=client.get_control_rate(), trace_id=get_current_trace_id() | ||
| ) |
There was a problem hiding this comment.
LeRobot policy not reset per episode
Medium Severity
Episode startup no longer calls policy.reset() on LeRobot checkpoints. The prior harness reset the policy (and optional ensembler) in on_episode_start; that hook was removed while reusing the same LeRobotModel across sequential rollouts, so internal episode state can carry into the next episode.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 82c1ef8. Configure here.
| """Ship one request dict → the server's ``[T, A]`` chunk, returned as ``[1, T, A]``.""" | ||
| self.connect() # lazy connect on first call (blocks until the server is up) | ||
| chunk = np.asarray(self._client.infer(batch)[self.response_key], dtype=np.float32) | ||
| return chunk[None] # add the leading N=1 batch dim |
There was a problem hiding this comment.
Shared RemoteModel lacks infer lock
Medium Severity
RemoteModel.infer uses one lazy WebSocket client with no serialization. Concurrent rollouts that share a single RemoteModel (common when fanning out parallel OpenPI evals) can interleave infer calls on the same connection and corrupt requests or responses.
Reviewed by Cursor Bugbot for commit 82c1ef8. Configure here.
Feat: hud-python sdk v6
L/v6 template updates
Adds a -p/--preset flag (and an interactive picker on a TTY) so hud init can fetch the same starter environments as the platform's environments/new flow. Presets live in hud/cli/presets.py (blank, browser, deepresearch, cua, autonomous-businesses, verilog) and are materialized by downloading the repo's main tarball from codeload (no git, path-traversal-safe). With no preset in a non-interactive shell it still writes the minimal local scaffold. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Apply tar members' execute bits after write so starter entrypoints/scripts stay runnable. Pass preset=None in the direct-call init tests (typer Option defaults to OptionInfo when the command function is called directly). Co-authored-by: Cursor <cursoragent@cursor.com>
feat(cli): hud init --preset to scaffold from GitHub starters
Docker for slow envs like Isaac Sim publishes the port before @env.initialize finishes, so hello retries can exceed 120s on slow container boots.
Add a weightless Model that queries a remote policy server over the OpenPI msgpack/WebSocket protocol: the adapter builds the request dict, the server owns all pre/post-processing + the forward, and infer() ships it and returns the [T, A] chunk. connect() is lazy and idempotent (blocks until the server is up); response_key covers "actions" (stock OpenPI) vs "action" (Cosmos).
…erence BatchedModel wraps any Model and coalesces concurrent ainfer() calls into a single stacked forward: a lazily-started worker drains up to batch_size queued calls (or flushes after max_wait_s for the suite tail), runs one inner.infer, and scatters the [N, T, A] rows back to each caller. BatchedAgent wraps a RobotAgent and shallow-clones it per run so each rollout keeps isolated episode state while sharing the one batched model. Usage stays a one-liner: BatchedAgent(agent, batch_size=8) with max_concurrent set to match.
Migrate the robot harness to OpenPI-standard, slash-delimited observation keys end-to-end, and add a thin OpenPIAdapter so a generic OpenPI policy server drives the harness with no agent code changes.
Replace per-tick JPEG observation images with per-camera H.264/CMAF video streaming for robot traces: - Add hud/agents/robot/video.py (SegmentEncoder/VideoStreamer): encode each camera on a background thread, emitting CMAF fragments as VideoSegmentStep spans without blocking the act loop. - RobotAgent starts/finalizes the streamer at the env control rate; finalize in `finally` so a crashed run still leaves video. - ObservationStep.from_obs records only numeric state now; camera frames travel as video. - Step.emit accepts an explicit trace_id so the encoder thread (no contextvars trace context) attributes spans correctly. - Add RobotClient.get_control_rate(); add "video_segment" RobotStepSource; add PyAV (av>=12) to the robot extra.
Remove the per-episode model.reset() hook (Model/LeRobotModel/RemoteModel/ BatchedModel + agent.on_episode_start); per-episode state lives only on the agent, so a shared BatchedModel can no longer clear one rollout's policy state mid-episode. Document that RemoteModel is not batchable (OpenPI server has no batched-request shape) on RemoteModel, BatchedModel, and BatchedAgent.
…ship Spell out on Model.infer/ainfer that implementations must keep the leading batch dim N (ainfer indexes [0], BatchedModel scatters rows along it) and add a one-line assert in LeRobotModel.infer. Document that BatchedAgent mutates the passed-in agent in place, leaving it permanently batched. Co-authored-by: Cursor <cursoragent@cursor.com>
Clamp get_control_rate to max(1, round(...)) so sub-0.5 Hz contracts no longer emit 0 FPS on VideoSegmentStep. Init _hooks_done before add_capability in Environment.__init__. Load optional robot deps via importlib for pyright, add shim-test ignores, and ruff-format flagged files. Co-authored-by: Cursor <cursoragent@cursor.com>
Wrap long lines, move NDArray to TYPE_CHECKING, noqa intentional 0.0.0.0 bind in LocalRuntime, and reformat legacy shim test imports. Co-authored-by: Cursor <cursoragent@cursor.com>


Issue
The v6 robot harness needed to drive real OpenPI policy servers, run concurrent rollouts efficiently, and stream camera data to traces without bloating each step with JPEG frames. Slow sim boots (e.g. Isaac Sim) also exceeded the default env connect timeout.
Solution
RemoteModel— WebSocket/msgpack client for OpenPI policy servers (lazy connect, supportsactions/actionresponse keys).BatchedAgent/BatchedModel— coalesce concurrentainfer()calls into stacked forwards for parallel rollouts.OpenPIAdapterso a stock OpenPI server drives the harness with no agent changes.VideoStreamer(hud/agents/robot/video.py); numeric state stays onObservationStep, frames go asVideoSegmentStepspans.RobotClientconnectready_timeoutdefault to 240s for slow container boots.lukass/modal-daytona-runtimes.Outcome / Verification
RemoteModel+OpenPIAdapterBatchedAgent(batch_size=N)video_segmentspans with playable H.264 segmentsNote
Medium Risk
Robot rollout, inference batching, and trace shape change observability (video segments vs per-step images); connect timeout and init download behavior affect all env provisioning paths.
Overview
Robot harness gains an OpenPI path:
RemoteModeltalks to a policy server over WebSocket,OpenPIAdaptermaps observations to OpenPI wire keys, andModelis now stateless with a fixed[N, T, A]batch contract (LeRobot inlined;Ensembler/lerobot_inferremoved).BatchedModel/BatchedAgentcoalesce concurrentainfercalls into one forward for in-process models only (RemoteModelstays one agent per rollout).Tracing stops embedding per-tick JPEGs on
ObservationStep;RobotAgentrunsVideoStreamer(PyAV/x264 CMAF) and emitsVideoSegmentStepspans with optionaltrace_idonStep.emit.RobotClient.get_control_rate()drives encoder FPS. Therobotextra now requiresav>=12.Platform polish: default
connect(..., ready_timeout)rises 120s → 240s;hud initcan download GitHub starter presets (--preset/ TTY picker) with safe tarball extract; RL cookbook uses file-levelMODEL/TASKSETinstead ofHUD_MODEL/HUD_TASKSET; new v6 Environments and Tasks docs plus.gitignoreexception sodocs/v6/build/stays tracked; version 0.6.1.Reviewed by Cursor Bugbot for commit 4c85e4a. Bugbot is set up for automated code reviews on this repo. Configure here.