About gRPC Worker Plugins
A worker plugin runs outside the Relay process. It implements
nvidia.nemo.relay.worker.v1 and supports 17 subscriber and middleware callback
types. It can call the host’s remaining execution chain through continuations,
use codecs during a callback, emit marks, and manage scope stacks.
The current contract is nvidia.nemo.relay.worker.v1, version 1.0.0, introduced
in Relay 1.0. Upgrade the host and worker SDK together, regenerate custom bindings,
and set compat.worker_protocol = "nvidia.nemo.relay.worker.v1" in the manifest.
Set compat.relay = ">=1.0.0,<2.0" for the current SDK. Old grpc-v1 workers
cannot use these services. Package versions continue to follow Relay releases.
Tool callbacks and ToolNext continuations preserve an application result and
optional opaque annotation; execution intercepts can add Relay-owned pending
marks. LLM execution callbacks receive LlmExecutionContext, which provides
request codecs and a response codec for non-streaming callbacks.
Workers can add a data schema, log severity, and semantic category to a mark, emit validated metric measurements, and read the current host-level runtime diagnostics. These diagnostics are ordered by code and are not attributed to a particular plugin. They are the legacy report, not canonical snapshots. Rust and Python workers can also record internal observations through the canonical diagnostics delivery API. Refer to Plugin Diagnostics for matching examples and delivery limits. Worker recording does not grant canonical read access.
Choose a worker when a separate process or dependency environment is worth the extra gRPC calls and data conversion. A worker crash does not crash the Relay process, but the worker is still trusted code. It is not a security sandbox. Relay uses a separate authentication token for each activation. That token lets the worker request host operations for that activation.
Choose the Implementation
Choose one of these implementation paths:
Async Python and Rust callback work is cancelled cooperatively when the host caller times
out, a stream consumer disconnects, or shutdown begins. Dropping a future or cancelling an
asyncio task cannot preempt arbitrary blocking work or a separately spawned process.
Keep blocking work off the SDK event loop, propagate cancellation, and put external
cleanup in a guaranteed finalizer.
Let the SDK Own the Transport
Implement Plugin and let the SDK run the protobuf server. serve_plugin
reads Relay’s activation environment and opens the authenticated local endpoint.
It handles handshake, health, validation, registration, callbacks, cancellation,
and shutdown.
Configure the Snapshot Location
Before starting a worker, Relay copies its package and runtime files into an
activation snapshot. This is a separate directory for that activation. Set
NEMO_RELAY_PLUGIN_SNAPSHOT_DIR in the environment that starts Relay to choose
where snapshots are stored. Relay creates the directory if needed. Keep it
outside plugin packages and all copied entrypoint and library directories. The following examples set the
snapshot location in PowerShell and Bash:
Python supports synchronous or asynchronous registration. Rust registration returns a future that the SDK awaits before sending the registration response. The installed callbacks can be asynchronous.
Rust plugin_kind() and Python plugin_id must match the manifest ID and handshake
identity. A mismatch
fails activation before any callback runs.
Complete Path
Follow these pages in order to build, activate, exercise, and stop a worker plugin:
- Use Python Worker when Relay should provision and own the Python environment, or Rust Worker for the checked compiled counterpart.
- Implement all callback families with Middleware and Continuations, paying particular attention to repeated downstream calls and lazy streams.
- Use Runtime Events and Scopes for marks, scope stacks, binding, restoration, and failure cleanup.
- Use the gRPC Protocol Reference to audit an SDK or implement a custom command.
The Rust lifecycle test builds the executable in an isolated target directory,
creates a manifest and checks its digest. It then activates the worker, runs a
managed tool call through nvidia.nemo.relay.worker.v1, checks a host-runtime mark,
and verifies shutdown. The Rust and Python callback-contract tests then isolate the sanitizer,
continuation, streaming, codec, cancellation, and scope-cleanup behavior. Merely
starting a process and registering one intercept is not enough evidence.