The production diagrams show separate services with cross-instance previews enabled. A Service is a reachable endpoint. Depending on your deployment, a Kubernetes Service, gateway, or internal load balancer can provide that endpoint.
Local quickstart
status=SUCCEEDED. The first prints modelInvocations=1 and the second prints 0 because the runtime finds the completed Turn after restart. The example receives event callbacks in the JVM. A separate HTTP example hosts the API role and exposes POST /api and GET /events. Run the examples
Production with RocketMQ
RocketMqTurnScheduler publishes a readiness message. Configure its publisher on API-only hosts as well. A Brain consumes the message, checks the Turn revision and dispatch generation, and acquires the lease in a database transaction. Durable dispatch records allow workers to recover missed publications and take over expired leases.
Tool execution. Brain uses RocketMqRemoteExecutor to publish a tool call to the command topic. Hands uses RocketMqWorker to record acceptance before acknowledging the command. It publishes progress and results to the updates topic. Brain deduplicates each update and commits it before acknowledging the message. The control topic carries cancellation and status requests. The execution ledger and the final update tell the caller when the tool has finished.
Broker configuration. Deploy a LiteTopic-capable broker and Cluster Proxy. Point both Brain and Hands at the gRPC Proxy endpoint. In the same deployment namespace, create a NORMAL topic for ready Turns, LITE parent topics for Turn signals and owner notifications, and LITE parent topics for Hands commands, controls, and updates. Configure their consumer groups. Replicas in one Hands pool share its command consumer group and execution ledger. Clients receive Session events through the public API. Topics, consumer groups, and scheduler configuration
Production without RocketMQ
SseHandsExecutor on Brain. Mount the private Hands handler on Brain or on a host that shares its SessionBackend. Give the worker pool a stable address for that endpoint. Each SseHandsWorker opens one outbound command stream and can serve several Sessions concurrently. The following paths are relative to the private endpoint.
Authenticate the worker pool and authorize access to each Session. Disable proxy response buffering for SSE and reserve capacity for result POSTs alongside long-lived streams. Brain replicas share their ledger, and replicas in the same Hands pool share theirs. Both ledgers can use one PostgreSQL instance. The two-process repository example uses loopback HTTP and local storage to exercise this protocol. Worker-initiated SSE configuration
User SSE and infrastructure in production
Users connect to Agent API. For example, API A may hold a user’s connection while Brain B runs inference. A delivers both kinds of events on that one SSE connection. An authorized client can reconnect through another API replica.
Give each API instance a dedicated PostgreSQL listener connection, either direct or through a session-mode pool. Configure every reader and writer with
sessionEventPush and the same deployment-specific 32-byte key. Healthy connections consume notifications in memory. Initial cursor setup, reconnections, sequence gaps, and oversized notification payloads trigger reads from storage. Sessions created before push was enabled continue to use polling. The deployment without RocketMQ uses PostgreSQL for Turn discovery and HTTP for tool execution. It can still use Redis for live previews across processes. Preview transport configuration · PostgreSQL event push
Inference, sandboxes, and storage. Brain calls a model gateway or inference provider. Hands resolves the sandbox binding for each Session and runs tools in its workspace, so a worker can serve multiple isolated sandboxes. The sandbox provider supplies the execution environment and workspace storage. To prewarm a sandbox when a Session is created, connect Session admission to the preparation task. The host can run the dispatcher in-process or separately. Workspace volume or snapshot recovery and idle reclamation depend on the platform and provider. External object storage is optional for large checkpoints and artifacts. The Hands SSE transport uses bounded inline payloads. Persistent sandbox bindings