Unary tools synthesize a single ToolEvent::Result under the
hood; client-side call_tool unwraps so unary callers never see
envelopes directly. Streaming callers (call_tool_streaming) see
each event as it arrives.
JSON-encoded per chunk (not postcard) so dumps stay readable and
clients can use whatever JSON parser they already have for the
typed request body. The envelope is the ONE convention every
provider adapter (OpenAI / Anthropic / Gemini / MCP / Hermes /
custom) lowers into the framework’s native streaming protocol.
Plan: locked decision #4 in
docs/plans/NRPC_AI_TOOL_CALLING_AND_AGENT_DX.md.
Fires once on stream open. Carries the substrate’s call_id
so clients can correlate later events to the outstanding
invocation (useful when an agent has multiple tool calls
in flight at once).
Partial output — model tokens, file bytes, log lines. The
adapter decides how to lower these into the provider’s
streaming protocol (Anthropic tool_use_block_delta, etc.).
True if self is a terminal envelope (Result or Error). Used
by the SDK’s streaming wrapper to detect end-of-stream when
the underlying RpcStream is still open (e.g. a misbehaving
handler that emitted Result but didn’t close).