Expand description
§NeMo Flow Core
The core runtime library for the NeMo Flow 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::NemoFlowContextState) 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:
api::scope::push_scope/api::scope::pop_scopecreate nested execution scopes.api::tool::tool_call_executeruns a complete tool middleware pipeline.api::llm::llm_call_executeandapi::llm::llm_stream_call_executerun non-streaming and streaming LLM middleware pipelines.api::registryexposes global and scope-local middleware registration APIs.api::subscriberexposes lifecycle event subscriber registration APIs.
§Modules
api— Public API functions, handles, lifecycle event types, runtime helpers, and guardrail/intercept/subscriber registration. These are the primary entry points.error— Error types (error::FlowError) and theerror::Resulttype alias.json— JSON type alias (json::Json) and thejson::merge_jsonutility.observability— Built-in observability backends includingatif::AtifExporter,otel::OpenTelemetrySubscriber, andopeninference::OpenInferenceSubscriber.registry—SortedRegistry— a priority-sorted, named collection used for all guardrail and intercept registries.stream—stream::LlmStreamWrapper— a stream adapter that applies per-chunk intercepts and aggregates streaming LLM responses.
§Middleware Pipeline
Both tool and LLM calls flow through a configurable middleware pipeline:
- Request intercepts — transform the request before execution
- Sanitize request guardrails — sanitize/normalize the request
- Conditional execution guardrails — gate execution (reject if criteria not met)
- Execution intercepts — optionally replace the execution function entirely
- 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 Flow runtime.
- codec
- LLM codec types, traits, and built-in implementations.
- error
- Error types for the NeMo Flow runtime.
- json
- JSON utilities for the NeMo Flow runtime.
- observability
- Optional observability integrations for NeMo Flow Core.
- plugin
- Generic plugin infrastructure for NeMo Flow runtimes.
- registry
- Priority-sorted named registry.
- stream
- Streaming LLM response wrapper.