Conversation
merceod
force-pushed
the
engine/generate-websocket
branch
from
September 23, 2026 23:14
e72ae96 to
350fa7c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
/generate/ws, the native/generaterequest over one persistent WebSocket, for clients that run a control loop against the server (robot policies, streaming world models) and can't afford an HTTP round trip per step./generatefields (text,filesas[{"name","data"}],input_modalities,output_modalities,model_kwargs,request_id). JSON text frames carrydataas base64, msgpack binary frames carry raw bytes, so images and actions skip base64.ResultChunk({"request_id","modality","data","metadata"}) followed by{"request_id","finish": true}. Errors travel in-band as{"request_id","error"}and the socket stays open.request_id. Closing the socket cancels the tasks, and tearing downiter_result_chunksaborts the engine request the same way/generatestreaming does.upload_dirwith the same layout as the multipart route (shared_decode_ws_files/_ws_input_layout), so models see identicalfile_paths/prompt_parts.submit_requestanditer_result_chunksare reused unchanged.Also adds the
websocketsdependency (uvicorn needs a WS implementation), a section indocs/clients.rst, andexamples/cosmos3_action_ws_client.py, an openpi-style policy client that streams observations, decodes float32[chunk, action_dim]replies and reports chunks/s, actions/s and latency percentiles.Tests in
test/modular/test_generate_ws.py(Starlette in-process client against a fake API server) cover a JSON round trip with media persisted in order, three pipelined msgpack requests, rejected messages answered in-band without dropping the socket, the not-ready close (1013), undecodable / non-object / empty frames, and a mid-stream disconnect cancelling the request.ruffandtest/modularpass.