refactor: prefer normalized exporter fallbacks - #304
Conversation
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughObservability code now shares manual cost-policy parsing, response/model-based pricing selection, normalized tool-call extraction, and raw-event model-name derivation across ATIF, OpenInference, and OTEL paths. Tests were updated for cache precedence, pricing priority, tool-call aliases, and raw-model handling. ChangesShared observability parsing and pricing
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/tests/unit/observability/openinference_tests.rs`:
- Around line 1769-1781: The current test in display_text_from_tool_calls does
not exercise the intended precedence between toolName and function.name because
the first fixture includes name and short-circuits the fallback chain. Update
the openinference_tests case to add a fixture without name but with both
toolName and function.name populated, and assert the expected output so the
precedence behavior is explicitly pinned; keep the existing
display_text_from_tool_calls coverage for the other fallback cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 02876c85-4f2c-474b-b4eb-71f153c11c72
📒 Files selected for processing (2)
crates/core/src/observability/openinference.rscrates/core/tests/unit/observability/openinference_tests.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (26)
- GitHub Check: Rust / Test (windows-arm64)
- GitHub Check: Python / Test (macos-arm64)
- GitHub Check: Node.js / Test (windows-arm64)
- GitHub Check: Python / Test (windows-amd64)
- GitHub Check: Rust / Test (windows-amd64)
- GitHub Check: Python / Test (windows-arm64)
- GitHub Check: Python / Test (linux-arm64)
- GitHub Check: Python / Test (linux-amd64)
- GitHub Check: Node.js / Test (macos-arm64)
- GitHub Check: Node.js / Test (windows-amd64)
- GitHub Check: Rust / Test (linux-arm64)
- GitHub Check: Rust / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (windows-arm64)
- GitHub Check: Rust / Test (macos-arm64)
- GitHub Check: Node.js / Test (linux-arm64)
- GitHub Check: WebAssembly / Test (windows-amd64)
- GitHub Check: Go / Test (windows-arm64)
- GitHub Check: Node.js / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (linux-arm64)
- GitHub Check: Go / Test (windows-amd64)
- GitHub Check: WebAssembly / Test (linux-amd64)
- GitHub Check: Go / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (macos-arm64)
- GitHub Check: Go / Test (linux-arm64)
- GitHub Check: Go / Test (macos-arm64)
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Use
snake_casenaming convention for Rust identifiers (e.g.,nemo_relay_tool_call)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node work
**/*.rs: Runcargo fmt --allto format all Rust code
Runcargo clippy --workspace --all-targets -- -D warningsto enforce all clippy lints as errors
**/*.rs: Runcargo fmt --allwhen Rust files changed as part of WebAssembly work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files changed as part of WebAssembly work
**/*.rs: If any Rust code changed, always runjust test-rust
If any Rust code changed, also runcargo fmt --all
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting withcargo fmt --all
Run Rust linting withcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Usecargo fmtfor Rust code formatting
Runcargo clippy -- -D warningsto lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/core/tests/unit/observability/openinference_tests.rs
**/{Cargo.toml,**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Maintain consistency between Rust package names in
Cargo.tomland their actual usage across the codebase
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/core/tests/unit/observability/openinference_tests.rs
crates/core/src/observability/{atif,otel,openinference}.rs
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
When changing event fields in ATIF, OpenTelemetry, or OpenInference observability surfaces, keep the core event model in
crates/core/src/observability/atif.rs,crates/core/src/observability/otel.rs, andcrates/core/src/observability/openinference.rsin sync
Files:
crates/core/src/observability/openinference.rs
🔇 Additional comments (1)
crates/core/src/observability/openinference.rs (1)
1531-1532: 📐 Maintainability & Code QualityPlease record the required
crates/corevalidation matrix for this PR.This change is in
crates/core, but the supplied validation summary only mentions Rust-focused checks. Please add the required broader validation (validate-changeplus the full binding matrix:just test-python,just test-node,just test-go,just test-wasm) or note where those already passed. As per coding guidelines, "crates/core/**/*.rs: If the change touchedcrates/coreor shared runtime semantics, also usevalidate-changefor broader validation" and "crates/{core,adaptive}/**: Ifcrates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly."Source: Coding guidelines
willkill07
left a comment
There was a problem hiding this comment.
One of the primary goals of refactoring is avoid all of these or_else chains with using different keys and extraction methods.
We should be relying on the shape of AnnotatedLLMRequest and AnnotatedLLMResponse wherever possible.
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/observability/atif.rs`:
- Around line 1024-1029: ATIF tool-call name extraction in the `name` assembly
path is missing the camel-case `toolName` alias, so alias-only calls are
skipped. Update the fallback chain in the tool-call parsing logic to check
`toolName` on the tool-call object before synthesizing the id, alongside the
existing `name`, `tool_name`, and `function_name` lookups. Keep the change
localized to the extraction code that builds `name` in `atif.rs`.
- Around line 1458-1465: The paired span metric extraction is using only the end
event’s model name, which can miss the requested model stored on the start
event. Update the logic around the end_metrics extraction in atif.rs to use the
paired start event as the fallback model source when calling extract_metrics,
while still preferring the end event’s model_name if present. Use the start/end
span pairing helpers and the existing end.data(), end.name(), and
extract_metrics flow to locate the fix.
- Around line 767-775: The extra field collection in AtifMetrics is only reading
from token_usage_object(output), so unknown keys present in usage are being lost
when merged_usage combines both maps. Update the extra_map construction in the
relevant AtifMetrics/merged_usage path to inspect both usage sources and
preserve any non-known fields from each before storing them in
AtifMetrics.extra. Use the existing symbols merged_usage, token_usage_object,
raw_usage, and extra_map to locate the merge logic and ensure extras from both
maps are retained.
In `@crates/core/src/observability/openinference.rs`:
- Around line 1130-1138: The raw tool-name lookup in raw_tool_call_name
currently prefers function.name first, which diverges from the legacy precedence
used elsewhere. Update raw_tool_call_name to match display_text_from_tool_calls
by checking top-level name, toolName, and tool_name before falling back to
function.name and function_name, so replay payloads resolve the same tool name
consistently across raw OpenInference attributes and display text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: e26ecf92-dd47-49e4-ae96-0cdb5c8fe9e2
📒 Files selected for processing (7)
crates/core/src/observability/atif.rscrates/core/src/observability/manual.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/tests/unit/atif_tests.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/observability/openinference_tests.rs
💤 Files with no reviewable changes (2)
- crates/core/src/observability/manual.rs
- crates/core/tests/unit/observability/manual_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Use
snake_casenaming convention for Rust identifiers (e.g.,nemo_relay_tool_call)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node work
**/*.rs: Runcargo fmt --allto format all Rust code
Runcargo clippy --workspace --all-targets -- -D warningsto enforce all clippy lints as errors
**/*.rs: Runcargo fmt --allwhen Rust files changed as part of WebAssembly work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files changed as part of WebAssembly work
**/*.rs: If any Rust code changed, always runjust test-rust
If any Rust code changed, also runcargo fmt --all
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting withcargo fmt --all
Run Rust linting withcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Usecargo fmtfor Rust code formatting
Runcargo clippy -- -D warningsto lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rs
**/{Cargo.toml,**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Maintain consistency between Rust package names in
Cargo.tomland their actual usage across the codebase
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rs
crates/core/src/observability/{atif,otel,openinference}.rs
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
When changing event fields in ATIF, OpenTelemetry, or OpenInference observability surfaces, keep the core event model in
crates/core/src/observability/atif.rs,crates/core/src/observability/otel.rs, andcrates/core/src/observability/openinference.rsin sync
Files:
crates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/src/observability/atif.rs
🔇 Additional comments (3)
crates/core/tests/unit/atif_tests.rs (1)
20-21: LGTM!Also applies to: 103-130, 882-1375
crates/core/tests/unit/observability/openinference_tests.rs (1)
1768-1783: LGTM!crates/core/src/observability/otel.rs (1)
718-746: LGTM!
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/observability/atif.rs`:
- Around line 1024-1029: ATIF tool-call name extraction in the `name` assembly
path is missing the camel-case `toolName` alias, so alias-only calls are
skipped. Update the fallback chain in the tool-call parsing logic to check
`toolName` on the tool-call object before synthesizing the id, alongside the
existing `name`, `tool_name`, and `function_name` lookups. Keep the change
localized to the extraction code that builds `name` in `atif.rs`.
- Around line 1458-1465: The paired span metric extraction is using only the end
event’s model name, which can miss the requested model stored on the start
event. Update the logic around the end_metrics extraction in atif.rs to use the
paired start event as the fallback model source when calling extract_metrics,
while still preferring the end event’s model_name if present. Use the start/end
span pairing helpers and the existing end.data(), end.name(), and
extract_metrics flow to locate the fix.
- Around line 767-775: The extra field collection in AtifMetrics is only reading
from token_usage_object(output), so unknown keys present in usage are being lost
when merged_usage combines both maps. Update the extra_map construction in the
relevant AtifMetrics/merged_usage path to inspect both usage sources and
preserve any non-known fields from each before storing them in
AtifMetrics.extra. Use the existing symbols merged_usage, token_usage_object,
raw_usage, and extra_map to locate the merge logic and ensure extras from both
maps are retained.
In `@crates/core/src/observability/openinference.rs`:
- Around line 1130-1138: The raw tool-name lookup in raw_tool_call_name
currently prefers function.name first, which diverges from the legacy precedence
used elsewhere. Update raw_tool_call_name to match display_text_from_tool_calls
by checking top-level name, toolName, and tool_name before falling back to
function.name and function_name, so replay payloads resolve the same tool name
consistently across raw OpenInference attributes and display text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: e26ecf92-dd47-49e4-ae96-0cdb5c8fe9e2
📒 Files selected for processing (7)
crates/core/src/observability/atif.rscrates/core/src/observability/manual.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/tests/unit/atif_tests.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/observability/openinference_tests.rs
💤 Files with no reviewable changes (2)
- crates/core/src/observability/manual.rs
- crates/core/tests/unit/observability/manual_tests.rs
📜 Review details
🔇 Additional comments (3)
crates/core/tests/unit/atif_tests.rs (1)
20-21: LGTM!Also applies to: 103-130, 882-1375
crates/core/tests/unit/observability/openinference_tests.rs (1)
1768-1783: LGTM!crates/core/src/observability/otel.rs (1)
718-746: LGTM!
🛑 Comments failed to post (4)
crates/core/src/observability/atif.rs (3)
767-775: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Preserve extras from both
usagemaps.
merged_usagecombinesusageandtoken_usage, butextra_maponly inspectstoken_usage_object(output). When both maps exist, unknown fields underusageare dropped fromAtifMetrics.extra.Proposed fix
- let extra_map: serde_json::Map<String, Json> = raw_usage - .map(|usage| { - usage - .iter() - .filter(|(k, _)| !known.contains(k.as_str())) - .map(|(k, v)| (k.clone(), v.clone())) - .collect() - }) - .unwrap_or_default(); + let extra_map: serde_json::Map<String, Json> = output + .as_object() + .into_iter() + .flat_map(|output| { + ["usage", "token_usage"] + .into_iter() + .filter_map(|key| output.get(key).and_then(Json::as_object)) + }) + .flat_map(|usage| usage.iter()) + .filter(|(k, _)| !known.contains(k.as_str())) + .map(|(k, v)| (k.clone(), v.clone())) + .collect();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.let extra_map: serde_json::Map<String, Json> = output .as_object() .into_iter() .flat_map(|output| { ["usage", "token_usage"] .into_iter() .filter_map(|key| output.get(key).and_then(Json::as_object)) }) .flat_map(|usage| usage.iter()) .filter(|(k, _)| !known.contains(k.as_str())) .map(|(k, v)| (k.clone(), v.clone())) .collect();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/src/observability/atif.rs` around lines 767 - 775, The extra field collection in AtifMetrics is only reading from token_usage_object(output), so unknown keys present in usage are being lost when merged_usage combines both maps. Update the extra_map construction in the relevant AtifMetrics/merged_usage path to inspect both usage sources and preserve any non-known fields from each before storing them in AtifMetrics.extra. Use the existing symbols merged_usage, token_usage_object, raw_usage, and extra_map to locate the merge logic and ensure extras from both maps are retained.
1024-1029: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Handle
toolNamein ATIF tool-call extraction.OpenInference accepts the camel-case alias, but ATIF still skips alias-only calls because
nameremains empty. AddtoolNamebefore synthesizing the id.Proposed fix
let name = func .and_then(|f| f.get("name")) .or_else(|| tc_obj.get("name")) + .or_else(|| tc_obj.get("toolName")) .or_else(|| tc_obj.get("tool_name")) .or_else(|| tc_obj.get("function_name"))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.let name = func .and_then(|f| f.get("name")) .or_else(|| tc_obj.get("name")) .or_else(|| tc_obj.get("toolName")) .or_else(|| tc_obj.get("tool_name")) .or_else(|| tc_obj.get("function_name")) .and_then(Json::as_str)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/src/observability/atif.rs` around lines 1024 - 1029, ATIF tool-call name extraction in the `name` assembly path is missing the camel-case `toolName` alias, so alias-only calls are skipped. Update the fallback chain in the tool-call parsing logic to check `toolName` on the tool-call object before synthesizing the id, alongside the existing `name`, `tool_name`, and `function_name` lookups. Keep the change localized to the extraction code that builds `name` in `atif.rs`.
1458-1465: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use the paired start event as the requested-model fallback.
For paired spans, the start event can carry the requested model while the end event only carries usage. Passing only
end.model_name()makes pricing fall back toNoneeven thoughstartis available.Proposed fix
end_metrics: end.data().and_then(|output| { let normalized_response = end.normalized_llm_response(); + let requested_model = end.model_name().or_else(|| start.model_name()); extract_metrics( output, Some(end.name()), - end.model_name(), + requested_model, normalized_response.as_deref(), ) }),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.end_metrics: end.data().and_then(|output| { let normalized_response = end.normalized_llm_response(); let requested_model = end.model_name().or_else(|| start.model_name()); extract_metrics( output, Some(end.name()), requested_model, normalized_response.as_deref(), )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/src/observability/atif.rs` around lines 1458 - 1465, The paired span metric extraction is using only the end event’s model name, which can miss the requested model stored on the start event. Update the logic around the end_metrics extraction in atif.rs to use the paired start event as the fallback model source when calling extract_metrics, while still preferring the end event’s model_name if present. Use the start/end span pairing helpers and the existing end.data(), end.name(), and extract_metrics flow to locate the fix.crates/core/src/observability/openinference.rs (1)
1130-1138: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Match legacy raw tool-name precedence.
display_text_from_tool_callspreserves top-level/toolNameprecedence, but raw OpenInference attributes now preferfunction.name. The same replay payload can export different names in display text vsfunction.name.Proposed fix
fn raw_tool_call_name(tool_call: &Json) -> Option<&str> { tool_call - .get("function") - .and_then(|function| function.get("name")) - .and_then(Json::as_str) - .or_else(|| tool_call.get("name").and_then(Json::as_str)) + .get("name") + .and_then(Json::as_str) .or_else(|| tool_call.get("toolName").and_then(Json::as_str)) .or_else(|| tool_call.get("tool_name").and_then(Json::as_str)) .or_else(|| tool_call.get("function_name").and_then(Json::as_str)) + .or_else(|| { + tool_call + .get("function") + .and_then(|function| function.get("name")) + .and_then(Json::as_str) + }) }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.fn raw_tool_call_name(tool_call: &Json) -> Option<&str> { tool_call .get("name") .and_then(Json::as_str) .or_else(|| tool_call.get("toolName").and_then(Json::as_str)) .or_else(|| tool_call.get("tool_name").and_then(Json::as_str)) .or_else(|| tool_call.get("function_name").and_then(Json::as_str)) .or_else(|| { tool_call .get("function") .and_then(|function| function.get("name")) .and_then(Json::as_str) })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/src/observability/openinference.rs` around lines 1130 - 1138, The raw tool-name lookup in raw_tool_call_name currently prefers function.name first, which diverges from the legacy precedence used elsewhere. Update raw_tool_call_name to match display_text_from_tool_calls by checking top-level name, toolName, and tool_name before falling back to function.name and function_name, so replay payloads resolve the same tool name consistently across raw OpenInference attributes and display text.
|
Thanks. I reworked this so normalized/codec data is authoritative wherever available, and manual/raw extraction is only a narrow fallback. The shared manual layer now covers scalar usage/cost/model hints only. I removed the shared raw tool-call reader and kept the remaining replay-shaped tool-call alias handling local to OpenInference. I also updated the PR title/body and added coverage for normalized-first extraction, exporter cost-policy boundaries, and preserved local tool-call display behavior. |
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/observability/atif.rs`:
- Around line 1455-1463: The LLM metrics path in the end-event handling is only
forwarding the end/model fallback from category-profile data into
extract_metrics, so pricing can miss the requested model when it is present only
on the start payload. Update the end_metrics extraction block to also pass the
start-event model fallback from start.model_name() (alongside end.model_name())
into extract_metrics, ensuring estimate_cost_for_response_or_model can price
deduped LLM metrics even when the response echo is unpriced.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: a2172060-ee61-48c1-be91-2da366f8a7f5
📒 Files selected for processing (5)
crates/core/src/observability/atif.rscrates/core/src/observability/mod.rscrates/core/src/observability/openinference.rscrates/core/tests/unit/atif_tests.rscrates/core/tests/unit/observability/openinference_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Use
snake_casenaming convention for Rust identifiers (e.g.,nemo_relay_tool_call)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node work
**/*.rs: Runcargo fmt --allto format all Rust code
Runcargo clippy --workspace --all-targets -- -D warningsto enforce all clippy lints as errors
**/*.rs: Runcargo fmt --allwhen Rust files changed as part of WebAssembly work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files changed as part of WebAssembly work
**/*.rs: If any Rust code changed, always runjust test-rust
If any Rust code changed, also runcargo fmt --all
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting withcargo fmt --all
Run Rust linting withcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Usecargo fmtfor Rust code formatting
Runcargo clippy -- -D warningsto lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rs
**/{Cargo.toml,**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Maintain consistency between Rust package names in
Cargo.tomland their actual usage across the codebase
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/openinference.rscrates/core/src/observability/mod.rscrates/core/src/observability/atif.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rs
crates/core/src/observability/{atif,otel,openinference}.rs
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
When changing event fields in ATIF, OpenTelemetry, or OpenInference observability surfaces, keep the core event model in
crates/core/src/observability/atif.rs,crates/core/src/observability/otel.rs, andcrates/core/src/observability/openinference.rsin sync
Files:
crates/core/src/observability/openinference.rscrates/core/src/observability/atif.rs
🔇 Additional comments (5)
crates/core/src/observability/mod.rs (1)
16-75: 📐 Maintainability & Code QualityConfirm the required Rust/core validation was run.
This cohort changes
crates/coreRust observability behavior; please confirmcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust, and the affected full language matrix/pre-commit validation were run. As per coding guidelines, "Any Rust change must runjust test-rust", "Any Rust change must runcargo fmt --all", "Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings", and "Changes tocrates/coreorcrates/adaptivemust run the full language matrix."Source: Coding guidelines
crates/core/src/observability/atif.rs (1)
42-46: LGTM!Also applies to: 704-797, 995-1042, 1313-1363, 2266-2328
crates/core/tests/unit/atif_tests.rs (1)
972-999: LGTM!Also applies to: 1248-1286, 2140-2164
crates/core/src/observability/openinference.rs (1)
25-25: LGTM!Also applies to: 739-790, 1112-1125
crates/core/tests/unit/observability/openinference_tests.rs (1)
1301-1383: LGTM!
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/observability/atif.rs`:
- Around line 1457-1466: Update the ATIF metric fallback logic in the
`requested_model` construction so the paired start model is preferred for
pricing when available. In the `extract_metrics` paths around `requested_model`,
change the lookup order to use `start.model_name()` before `end.model_name()`,
while keeping the existing `model_name_for_llm_event(start)` fallback. Apply the
same adjustment in both affected metric paths to avoid using provider-echoed
aliases from `end` when the priced model is only present on `start`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 04748943-2e86-4de7-80f5-4cd7b5eb2f05
📒 Files selected for processing (2)
crates/core/src/observability/atif.rscrates/core/tests/unit/atif_tests.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Use
snake_casenaming convention for Rust identifiers (e.g.,nemo_relay_tool_call)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node work
**/*.rs: Runcargo fmt --allto format all Rust code
Runcargo clippy --workspace --all-targets -- -D warningsto enforce all clippy lints as errors
**/*.rs: Runcargo fmt --allwhen Rust files changed as part of WebAssembly work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files changed as part of WebAssembly work
**/*.rs: If any Rust code changed, always runjust test-rust
If any Rust code changed, also runcargo fmt --all
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting withcargo fmt --all
Run Rust linting withcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Usecargo fmtfor Rust code formatting
Runcargo clippy -- -D warningsto lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/core/tests/unit/atif_tests.rs
**/{Cargo.toml,**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Maintain consistency between Rust package names in
Cargo.tomland their actual usage across the codebase
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/tests/unit/atif_tests.rscrates/core/src/observability/atif.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/core/tests/unit/atif_tests.rs
crates/core/src/observability/{atif,otel,openinference}.rs
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
When changing event fields in ATIF, OpenTelemetry, or OpenInference observability surfaces, keep the core event model in
crates/core/src/observability/atif.rs,crates/core/src/observability/otel.rs, andcrates/core/src/observability/openinference.rsin sync
Files:
crates/core/src/observability/atif.rs
🔇 Additional comments (1)
crates/core/src/observability/atif.rs (1)
1343-1360: 📐 Maintainability & Code QualityRun the required
crates/corevalidation matrix for this revision.This PR changes
crates/core, so the repository guidance requires the Rust checks plus the full binding matrix. Please confirm this revision ranvalidate-change,uv run pre-commit run --all-files,just test-rust,just test-python,just test-go,just test-node,just test-wasm,cargo fmt --all, andcargo clippy --workspace --all-targets -- -D warnings. As per coding guidelines, "If the change touchedcrates/coreor shared runtime semantics, also usevalidate-changefor broader validation" and "Changes tocrates/coreorcrates/adaptivemust run the full language matrix."Source: Coding guidelines
Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
|
/merge |
Bring in NVIDIA#304 (prefer normalized exporter fallbacks) and NVIDIA#305 (shared relay DTO crate) so the token/cost docs and tests reflect current behavior. Clean auto-merge; my two contract tests pass on the merged tree. Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
…ss review (RELAY-243) After merging main, the docs predated NVIDIA#304 (prefer normalized exporter fallbacks) and NVIDIA#305 (shared DTO crate). Corrected: exporter cost precedence (normalized-first, umbrella wording); ATIF now consumes the codec annotation (not raw-only) in the exporter table, atif.mdx, and Stability; marked the ATIF raw-only divergence Fixed in 0.5 (known-issues), with USD-only cost kept as an active 0.5 limitation; qualified Granularity (user/agent steps; final_metrics sums present step metrics on this trajectory, excludes subagents); corrected the total_tokens projection note; scoped the additive-compat promise to serialized JSON/ATOF (Rust structs/enums are exhaustive); qualified 'optional/unset'. Tests: rewrote the OTel cost-only test to drive OtelEventProcessor and assert the finished span's keys (rejecting any token-ish or gen_ai key, closing the nemo_relay.prompt_tokens gap); added a codec-level test that OpenAIChatCodec drops completion_tokens_details. Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
The ATIF raw-only behavior was never a documented limitation on main, and NVIDIA#304 already resolved it, so this token/cost-semantics PR should not introduce a release-notes 0.5 section or document another PR's fix. The USD-only cost behavior remains documented in the provider-response-codecs contract page (exporter table + Stability). Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
#### Overview Backfill regression and parity coverage for the shared extraction seams established by #291, #300, #301, #304, and #318, so agent-payload extraction, provider-schema normalization, and exporter projection cannot drift silently. Test-only: the only `src` edits are `#[cfg(test)]` module wiring for two new suites; no production behavior changes. - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details **Agent payload extraction** (`crates/cli/tests/coverage/adapters_tests.rs`, 15 tests): - Per-host partial-sparse payloads for Claude Code, Codex, and Hermes (real identifiers kept, absent fields synthesized or null at the adapter boundary). - Path-precedence fallback-chain walks for session IDs, event names, subagent IDs, tool-call IDs, and tool results/status. - Hermes tool result and status extraction (previously uncovered), including explicit-status vs event-name-derived status interaction. - Claude Code LLM-hint extraction and hint field precedence chains. - JSON-path primitive edge cases: empty-string filtering, array intermediates, deep nesting, all-paths-miss. **Provider request extraction** (`crates/cli/tests/coverage/alignment_tests.rs`, 6 tests): - First coverage for `request_affinity_key` (route-gated, length-bounded) and `gateway_turn_input` (Claude Code + Anthropic Messages only). - Header-only session-id routing on the Models and Count-Tokens routes, contrasted with the body fallbacks on the Responses/Chat routes. - Gateway route name round-trips. **Codec parity** (`crates/core/tests/unit/codec/parity_tests.rs`, new, 14 tests): Each test builds the same logical scenario in all three provider schemas (OpenAI Chat Completions, Anthropic Messages, OpenAI Responses) and asserts the normalized output agrees: model name, finish reasons, tool calls (full-struct equality), usage incl. cache-read tokens, provider-reported and catalog-estimated cost, hint hardening (`normalize_request_with_hint`), and request normalization. Schema-inherent divergences are asserted explicitly as part of the parity contract, e.g. Responses normalizes a tool-call turn to `Complete` (no tool-use terminal status), cache-write tokens are Anthropic-only, reasoning tokens are Responses-only. **Exporter parity** (`crates/core/tests/unit/observability/exporter_parity_tests.rs`, new, 9 tests): A shared harness feeds one event stream to the ATIF exporter, `OpenTelemetrySubscriber`, and `OpenInferenceSubscriber` (in-memory span exporters) and asserts the projected facts agree: cost totals, usage, model names, tool-call projection, replay-payload preservation, and the consolidated manual-fallback path — run against both OpenAI-Chat-shaped and Anthropic-shaped payloads. Intentional projection divergences are pinned with explicit assertions so drift fails loudly, notably: OTel emits no token-count attributes, reasoning facts are ATIF-only, ATIF sums cache read+write while OpenInference splits them, and OpenInference omits raw LLM request JSON. Cost-currency policy boundaries stay covered by the existing per-exporter tests from #304 and are not duplicated here. **Validation** - `just test-rust` — full workspace green - `cargo clippy --workspace --all-targets -- -D warnings` — clean - `cargo fmt --all --check` — clean - `uv run pre-commit run --files <changed files>` — all hooks green (SPDX, fmt, clippy, check, linkcheck) - Rebased onto current `main` and re-ran `cargo test -p nemo-relay` and `cargo test -p nemo-relay-cli` — green, including the parity suites against the latest observability changes - Binding matrix not run: the change is test-only; the `#[cfg(test)]` modules are not compiled into the library targets, so binding-facing behavior is unchanged **Breaking changes** None. #### Where should the reviewer start? `crates/core/tests/unit/observability/exporter_parity_tests.rs` — the `export_through_all_exporters` harness and the explicitly pinned divergences. These assertions encode current behavior. The OTel cost-only projection and the ATIF cache-sum vs OpenInference cache-split asymmetry match the token/cost field-semantics contract documented in #330; the remaining pinned divergences (reasoning projection being ATIF-only, OTel not flattening LLM tool calls, OpenInference omitting raw LLM request JSON) encode current behavior without a recorded decision — if any is ruled a defect, the fix should land together with flipping the pinning assertion. Then `crates/core/tests/unit/codec/parity_tests.rs` for the cross-schema normalization contract, and the adapter/alignment additions in `crates/cli/tests/coverage/`. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to: none (test backfill for the extraction-strategy refactors #291, #300, #301, #304, #318) ## Summary by CodeRabbit * **Tests** * Added coverage for Hermes and Claude tool adapter/extractor precedence, partial payload handling, and hint/session/model/request-id resolution (including null/empty-string and fallback-chain behaviors). * Expanded gateway alignment tests for affinity-key/session-id gating and route/provider-specific prompt building. * Introduced core codec and observability cross-provider/exporter parity tests validating normalized fields, tool-call mapping, and consistent usage/cost/model/replay projections (with expected divergence checks). Authors: - Yuchen Zhang (https://github.com/yczhang-nv) Approvers: - Will Killian (https://github.com/willkill07) - Zhongxuan (Daniel) Wang (https://github.com/zhongxuanwang-nv) - Maryam Najafian (https://github.com/mnajafian-nv) URL: #355
#### Overview Document and stabilize NeMo Relay's LLM token and cost field semantics. This freezes the current behavior as a documented contract and locks it with characterization tests. There is no runtime behavior change. The branch is merged with current `main`, so the docs and tests reflect #304 (prefer normalized exporter fallbacks) and #305 (shared `nemo_relay_types` DTO crate). - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details Adds a canonical **Token and Cost Field Semantics** section to `docs/integrate-into-frameworks/provider-response-codecs.mdx`: - `Usage` and `CostEstimate` field reference (names, units, optionality; optional fields can also be codec-computed or pricing-synthesized). - Per-provider token normalization table (OpenAI Chat / OpenAI Responses / Anthropic → `Usage`). - **Granularity**: per-call values; an exported call yields a `user` start step (no metrics) and an `agent` end step that carries metrics; `final_metrics` is the only aggregate (a per-trajectory sum of present step metrics, excluding embedded subagent trajectories). - Exporter field-mapping table across ATOF / ATIF / OpenInference / OpenTelemetry: OpenTelemetry is cost-only and currency-aware; ATIF and OpenInference are USD-only; ATIF sources metrics from the codec-normalized usage with raw-payload fallback. - A **Stability** subsection (stable as of ATOF `0.1` / `ATIF-v1.7` / pricing catalog `version: 1`). The additive-compatibility promise is scoped to the serialized JSON/ATOF shapes; the Rust `Usage`/`CostEstimate` structs and `CostSource` enum are exhaustive, so adding a field/variant is source-breaking for Rust consumers. Short field pointers + back-links were added to the OpenTelemetry, OpenInference, and ATIF exporter pages. Cost policy is stated once on the canonical page, per the runtime-contract docs convention. Two characterization tests lock the freeze: - The OpenTelemetry LLM span emits cost only — driven end-to-end through `OtelEventProcessor`, asserting the finished span carries `nemo_relay.llm.cost.{total,currency}` and no token-count attribute in any namespace (`token`-containing or `gen_ai.*` keys fail). - `OpenAIChatCodec` drops `completion_tokens_details`, and `Usage` ignores unmodeled provider subfields (forward-compat: no serde catch-all). Existing tests already cover the remaining projections, per-provider mapping, reasoning-tokens-in-`api_specific`, and the USD-only/currency-aware cost behavior. **Testing:** targeted `cargo test` on the merged tree (the new/changed tests pass; perturbing the OTel exporter with a `nemo_relay.prompt_tokens` attribute makes the span test fail as intended, then reverted), `just docs-linkcheck` (0 errors), and `pre-commit` (SPDX, markdown linkcheck, cargo fmt/clippy/check) all pass. #### Where should the reviewer start? `docs/integrate-into-frameworks/provider-response-codecs.mdx` — the **Token and Cost Field Semantics** section (the exporter field-mapping table and the **Stability** subsection are the core contract). Then `crates/core/tests/unit/observability/otel_tests.rs::llm_end_emits_cost_only_no_token_or_gen_ai_attributes`. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - N/A ## Summary by CodeRabbit * **Bug Fixes** * Response decoding now preserves supported `usage` token totals while omitting provider-only completion token detail fields. * `Usage` serialization now ignores unknown/unmodeled provider subfields. * Observability “LLM end” spans now emit only total cost attributes (no token-related or `gen_ai*` attributes). * **Tests** * Added unit tests covering decoding behavior, handling of unmodeled `usage` fields, and cost-only observability attributes. * **Documentation** * Added/expanded stable “Token and Cost Field Semantics” mappings, including updates for ATIF, OpenInference, and OpenTelemetry expected-output fields. Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
Overview
Refines exporter fallback handling so codec-normalized LLM response data is authoritative where available, while manual/raw parsing remains a narrow fallback for payloads that do not have normalized provider data.
Details
Validation:
cargo fmt --allgit diff --checkcargo test -p nemo-relay observability::manual::tests -- --nocapturecargo test -p nemo-relay observability::atif::tests -- --nocapturecargo test -p nemo-relay observability::otel::tests -- --nocapturecargo test -p nemo-relay observability::openinference::tests -- --nocapturecargo check -p nemo-relay --no-default-featurescargo check -p nemo-relay --no-default-features --features otelcargo check -p nemo-relay --no-default-features --features openinferencecargo clippy -p nemo-relay --all-targets -- -D warningsPATH="$HOME/.local/nemo-relay-tools/bin:$PATH" uv run pre-commit run --all-filesPre-commit was run with the repo-pinned
cargo-about 0.8.4.Where should the reviewer start?
Start with
crates/core/src/observability/mod.rsfor the shared model/cost selection helpers andcrates/core/src/observability/manual.rsfor the narrowed scalar fallback policies.Then review the exporter call sites in
atif.rs,otel.rs, andopeninference.rsto see the normalized-first fallback order and exporter-local projection boundaries.The most important tests are in
manual_tests.rs,atif_tests.rs,openinference_tests.rs, andotel_tests.rs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit