Skip to content

Low-Level Streaming Protocol and Wire Conventions ​

Runtime RPC endpoints define explicit event formats and lifecycle semantics. In typical development workflows, applications interact with streams through the standard SDK without needing to parse low-level binary gRPC frames directly.

Streaming Endpoints and Lifecycle Behaviors ​

EndpointNormal CompletionInterruption & Recovery Handling
StreamScenarioEmits terminal frame with completed statusEmits explicit failed events; socket disconnects trigger connection timeouts
SubscribeScenarioJobEventsDelivers status snapshots up to terminal state, then closesRe-query with GetScenarioJob; ending observation does not cancel background compute
ExportAuditEventsFinal batch marked with eof: trueInterrupted streams yield partial output; re-exporting requires a new export request over the desired time window
Long-Lived SubscriptionsFollows specific owner resource lifecyclesCleanly terminates upon session invalidation or daemon restart

Generation Stream Handling Principles ​

  1. Strict Ordering: Incremental text deltas maintain strict sequential ordering across the transport layer, ensuring coherent text reassembly in the UI.
  2. Separation of Metrics and Data: Content chunks, performance metrics (e.g., token usage), and lifecycle signals (start, completion) are demarcated into distinct message envelopes.
  3. Reconnection Strategies: For interactive streaming, brief disconnects prompt actionable retry banners; for asynchronous jobs, client apps re-bind using the persistent jobId.

Backpressure and Resource Protection ​

To prevent slow consumers from causing memory exhaustion within Runtime:

  • Bounded Buffers: Streaming channels enforce bounded sliding windows, applying backpressure upstream to inference workers when buffers saturate.
  • Connection Pruning: Dangling or unresponsive socket connections are reclaimed automatically after bounded timeouts, freeing system socket handles.

Source Basis ​

Documentation for Nimi — the installable, open-source, local-first personal AI product.