gRPC Worker Protocol Reference
The Rust host, Rust worker SDK, and Python worker SDK use
nvidia.nemo.relay.worker.v1, with contract version 1.0.0.
The canonical protobuf files live under
crates/worker-proto/proto/nvidia/nemo/relay/worker/v1/.
Crate and wheel release versions remain independent of this contract version.
Upgrade the host and workers together. Set
compat.worker_protocol = "nvidia.nemo.relay.worker.v1" and
compat.relay = ">=1.0.0,<2.0" in worker manifests. Regenerate custom bindings or
rebuild workers with the new SDK. Old grpc-v1 workers cannot connect. The old
schema and generated bindings have been removed. Their definitions remain in
Git history.
SDK callbacks use shared domain types in Rust and authoring dictionaries and
dataclasses in Python. Private converters translate those values into typed
protobuf messages. Use JsonValue only for application or provider-owned data.
Worker Service
The fully qualified service is
nvidia.nemo.relay.worker.v1.PluginWorkerService. Each RPC has its own
<Method>Request and <Method>Response message.
Each request contains Credentials with the activation ID and token. The server
checks credentials before validating the message or running a callback. Handshake
proposes a ProtocolIdentity with the exact name and contract version. Lifecycle
replies carry a typed WorkerIdentity. The following table describes each RPC:
The SDKs also expose standard grpc.health.v1.Health Check and Watch probes.
These are separate from the authenticated worker lifecycle Health RPC.
Host Liveness
Relay launches a worker with a pipe on standard input and keeps the write end for the life of the activation. A worker whose standard input is a pipe must stop when it reads EOF, because EOF confirms that the Relay host closed or exited. On Unix, Relay starts each worker as the leader of its own process group and terminates that group when it stops the worker. A worker that leads its own process group and stops because of EOF must terminate that group before it exits, so its child processes do not outlive the host. The Rust and Python worker SDKs implement this behavior.
Do not infer host death from a failed RPC or gRPC connectivity state. Local
transport failures can be transient. Older hosts give workers the null device
instead of a pipe. Those workers continue to rely on the authenticated Shutdown
RPC.
Registration Surfaces
The InvokeRequest.invocation oneof selects the callback type. There is no
separate surface field that could conflict with the selected input. Registration
plans carry each callback’s surface, local name, priority, and break-chain flag.
Each callback type accepts these success results:
ATOF events retain UUIDs, timestamps, category profiles, and runtime propagation fields. Scope sanitizer inputs must match their start or end lifecycle phase. Closed LLM models represent message roles, multimodal parts, provider-specific fields, tool choices, finish reasons, and optional empty collections explicitly. Application and provider extensions use JSON. Rust conversions follow the native SDK’s number limits, as described below.
Host Runtime Service
Workers call nvidia.nemo.relay.worker.v1.RelayHostRuntimeService on the host endpoint.
Requests contain credentials. Each scope or access handle belongs to the
activation or callback that created it. The service provides these RPCs:
Request and response codecs have separate access handles. An explicit none
means that no codec is selected. A selected codec can carry a host-issued access
handle. Access ends when the callback finishes or is cancelled. For streaming
calls, it lasts until the stream finishes or closes. Streaming execution has a
request codec but no completed-response codec.
Continuation calls can repeat or overlap while the interceptor is active. Each call uses an isolated copy of the scope stack. Finish this work before returning from the interceptor. Return or re-raise the original downstream error to preserve its source. A new error counts as a plugin failure.
Codec References and Provider Data
Built-in, runtime-registered, and dynamic codecs use the same LlmCodecReference
fields: an open namespace (kind) and an optional stable id. These fields
describe the codec; they do not select a provider or codec implementation.
LlmCodecContext carries the access handle for the host’s selected codec.
Shared annotated requests and responses use typed messages. Their api_specific
fields use the native SDK’s JSON representation for every codec. Rust converters
preserve signed and unsigned 64-bit integers and finite 64-bit floating-point
values. They do not preserve decimal spelling or precision beyond those types.
Provider fields and custom codecs do not need protobuf changes. The transport checks JSON syntax and required message fields. The codec interprets provider data. The host checks who owns an access handle, its direction, and its lifetime.
Scope Snapshot Extension
GetCurrentScopeStackSnapshot selects a typed snapshot or explicit no_context.
Snapshot entries contain validated scope UUIDs and recognized scope categories.
Inspection does not create a stack. Invalid or expired bindings fail with a gRPC
status. The historical grpc-v1 extension cannot be used with the new services.
Diagnostic Delivery
The optional RelayDiagnosticsService service shares the authenticated host endpoint.
It exposes six RPCs:
GetDiagnosticCapabilities.OpenDiagnosticSession.SubmitDiagnostic.ReadDiagnosticPage.GetDiagnosticDiscovery.InspectDiagnosticMemory.
Its decode and admission limits are separate from RelayHostRuntimeService, logging,
and execution payload limits.
Older hosts return UNIMPLEMENTED. For unsupported hosts or disabled collection,
the SDK returns an inactive helper that skips lazy observation factories. Diagnostic
availability does not decide whether a plugin executes.
Negotiate Settings and Authority
The host returns DiagnosticCapabilities before opening a session and again when
the session opens. Both values must agree. The SDK checks contract versions and
its local safety ceilings. It then uses the host’s exact request and response
limits, queue capacity, retry count, and per-attempt timeout.
A mismatch, unsupported limit, or malformed session response produces an inactive
unsupported helper. This includes a session ID that is not 16 bytes long.
Plugin execution continues. The SDK does not negotiate different limits or use
local delivery defaults. Bootstrap calls have a separate local safety timeout.
Flush and shutdown drain also have local bounds. These are separate from the
host’s per-attempt RPC timeout.
Recording uses activation credentials. Those credentials do not grant snapshot
read access: can_read_context is false, and canonical reads are denied. Query
filters do not grant permission. The read RPC reserves a separate access boundary.
Opening an already live session returns the same session. The host assigns its UUID and ownership. Registration returns component and code handles. Code handles are one-based positions in the registration’s code list.
Workers can register common plugin failure codes, but not host-owned lifecycle codes. Extensions can describe failure, success, or unspecified outcomes under a host-assigned session namespace. Unknown authoring codes and failure classes are rejected. Detail and correlation limits come from the core context.
Submit and Retry Observations
SubmitDiagnostic uses one sequence, starting at one, for registration, recording,
component close, and session close. Positive counts of two and three add five
occurrences. The host commits a digest and receipt atomically with the record.
Receipts and sequence handling follow these rules:
- Retrying the last request with identical content returns its receipt without counting the observation again. Conflicts, gaps, and older sequences fail.
- Malformed requests do not consume a sequence. A valid request that passes
admission but fails policy consumes a sequence and returns a terminal
Rejectedreceipt. Recordedconfirms in-memory counts. Evidence can be retained, truncated, or dropped.Registered,Closed, andDisabledadd no occurrences.
The SDK freezes request bytes and sends one request at a time. Each retry uses identical bytes, up to the host’s attempt count and per-attempt deadline. If the SDK cannot confirm acceptance, it stops delivery. Pending observations are never replayed into a new session.
This release allows one session per activation. A closed session keeps its last receipt until activation cleanup. Starting a new session requires a new activation.
Delivery Limits
Delivery uses the following limits in addition to core storage limits:
The service takes a concurrency permit before decoding protobuf. A slow response keeps that permit until its body reaches its delivery deadline or is dropped. HTTP/2 buffers, channel state, allocator overhead, and core pools have separate costs. These limits do not cap whole-process RSS.
Handle Loss and Shutdown
delivery_stats reports local dropped, rejected, and uncertain totals separately
from host occurrence counts. An explicit INVALID_ARGUMENT response counts as
rejected, even when the host leaves its sequence available for a corrected request.
A host capacity rejection uses RESOURCE_EXHAUSTED with
nemo-relay-diagnostic-not-consumed: 1 status metadata. The SDK counts a definite
rejection and preserves the sequence for later submissions. The metadata confirms
only that attempt. If an earlier attempt had an uncertain result, the SDK keeps
retrying the identical request within its policy. Without a receipt, delivery stays
uncertain and stops. A client-side or unmarked capacity error is also uncertain.
These decisions never depend on error-message text.
flush waits for earlier queued work. It returns an error for uncertain delivery.
Counters expose known losses. close drains and releases queued work within the
shutdown allowance. Activation teardown stops submissions and closes registrations.
The runtime context remains available.
Restricted evidence uses state-only recording. It never enters Log, EmitMark,
legacy reports, or exporters.
Execution Protocol Compatibility
The active protocol is nvidia.nemo.relay.worker.v1, contract 1.0.0.
Workers built for grpc-v1 must rebuild with the updated SDK and update their
manifest’s worker_protocol. There is no automatic adapter between namespaces.
Generate custom clients from the protobuf source in crates/worker-proto/proto/.
The worker implements PluginWorkerService. Relay implements
RelayHostRuntimeService and RelayDiagnosticsService. Each RPC has a dedicated
request and response message; streaming invocations use InvokeStreamRequest.
Empty responses acknowledge successful operations; failures use gRPC statuses.
Authentication and Endpoints
Relay creates a fresh activation ID and high-entropy token, passes the worker and host endpoints through the activation environment, and sends the same values in handshake. Every later worker and host-runtime request includes the activation ID and token. SDKs bind the endpoint locally, prefer Unix domain sockets where supported, constrain TCP fallback to loopback, and reject mismatched credentials. Local authentication prevents accidental cross-activation calls; it does not make untrusted worker code safe.
Relay supplies the following process environment to Rust, Python, and custom-command workers:
Use load.forward_env
to pass selected host environment variables to the worker. Forwarded values cannot
replace the settings that Relay supplies in the table.
Configure Execution Message Size
Configure these tables in relay-plugin.toml, separate from the component
configuration in plugins.toml. For timeout settings and a combined example,
refer to Worker Timeouts and Payload Limits.
Use exact callback registration names, as shown in the following example:
Relay uses the following settings in order, from highest to lowest priority:
- Host
NEMO_RELAY_WORKER_MAX_MESSAGE_BYTES_BY_NAME: JSON callback-to-bytes map, such as{"input_guardrail":16777216}. - Host
NEMO_RELAY_WORKER_MAX_MESSAGE_BYTES: decimal fallback for all RPCs. - Plugin
load.max_message_bytes.by_name: exact callback registration name. - Plugin
load.max_message_bytes.default_bytes, then 4 MiB.
Limits must be whole numbers from 1 through 2,147,483,647 bytes. They apply to each sent or received message for that callback, including stream chunks and calls to continuations. They do not limit the total stream size. Control RPCs use the default limit. Zero is invalid. These limits do not change model context limits or provide automatic compaction. Reactivate the plugin after changing the manifest or host environment.
Validation and Errors
The host and SDKs run Protovalidate checks before calling callbacks. They also check JSON syntax, timestamps, and durations. Schema rules enforce required alternatives, enum values, UUIDs, nonempty IDs, and relationships between fields. Runtime code separately checks credentials, access rights, message sizes, and operation order. Failures use the following error forms:
WorkerError preserves a code, message, retryability, optional HTTP status, and
optional downstream continuation identity. Successful empty runtime operations
return empty dedicated response messages. Empty or contradictory result oneofs
are malformed; they do not mean allow, unchanged, or successful completion.
JsonValue contains UTF-8 JSON bytes and preserves JSON null and large integers.
JsonObject represents a JSON object. Closed Relay structures use typed protobuf
messages, not schema-tagged JSON envelopes. Handshake checks the contract identity.
Payloads do not repeat it.
Cancellation and Shutdown
The SDK tracks active unary and streaming callbacks by invocation ID. Duplicate active IDs are rejected. Cancellation aborts callback tasks, waits for their owned resources to drop, and revokes scope, continuation, and codec access. An accepted cancellation acknowledges callback cleanup; it does not prove that arbitrary blocking work started by plugin code has stopped.
Stream setup, consumption, EOF, terminal error, consumer drop, and cancellation all release invocation ownership. Stream items are ordered and bounded, with backpressure and at most one terminal error. A transport failure does not make execution safe to replay.
Shutdown stops new work and bounds callback and diagnostic cleanup. The host retains responsibility for process termination and activation-owned resource cleanup. Worker processes isolate dependencies and crashes; they are trusted extensions and do not form a security sandbox.