nemo-relay

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi.

NeMo Relay Core

The core runtime library for the NeMo Relay multi-language agent framework. This crate provides execution scope management, lifecycle event tracking, and middleware pipelines (guardrails and intercepts) for tool and LLM calls.

Architecture

The runtime is organized around a global context (api::runtime::NemoRelayContextState) that holds all registered middleware (guardrails, intercepts, subscribers) and a scope stack (api::runtime::ScopeStack) that tracks the hierarchical execution context via task-local or thread-local storage.

Primary Entry Points

Most integrations start with the high-level lifecycle helpers in api:

Modules

Middleware Pipeline

Both tool and LLM calls flow through a configurable middleware pipeline:

  1. Request intercepts - transform the request before execution
  2. Sanitize request guardrails - sanitize/normalize the request
  3. Conditional execution guardrails - gate execution (reject if criteria not met)
  4. Execution intercepts - optionally replace the execution function entirely
  5. Sanitize response guardrails - sanitize/normalize the response

All middleware is priority-ordered (ascending) and registered by name for easy addition and removal at runtime.

Modules

  • api: Public API for the NeMo Relay runtime.
  • codec: LLM codec types, traits, and built-in implementations.
  • config_editor: Typed configuration editor metadata.
  • error: Error types for the NeMo Relay runtime.
  • json: JSON utilities for the NeMo Relay runtime.
  • observability: Optional observability integrations for NeMo Relay Core.
  • plugin: Generic plugin infrastructure for NeMo Relay runtimes.
  • plugins: First-party plugin implementations for NeMo Relay Core.
  • stream: Streaming LLM response wrapper.

Macros