refactor: hoist provider schema detection and normalization - #291
Conversation
… Chat Completions Consolidate provider schema handling for OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages behind a single codec-layer path so exporters and plugins consume normalized data instead of re-parsing raw provider JSON. - Add codec::resolve: ProviderSurface detection + fail-open normalize_request/normalize_response as the canonical detect-then-decode entry. - Add Event::normalized_llm_request/response annotation-first helpers and consume them in the OpenInference exporter (annotation -> OpenClaw replay -> codec detection), so un-annotated provider events emit structured attributes. - Extend OpenAIResponsesCodec to decode top-level and item-level output_text. - Dedupe the otel/openinference non-provider usage/cost fallback into observability::manual (currency policy parameterized). - ATIF reads normalized message text from annotations (raw fallback for multimodal); tool calls and metrics stay on the raw path to preserve provider extras. - adaptive delegates request-surface detection to codec::resolve. - Fix the misleading "global codec registry" docstring and document the annotation-vs-raw-fallback rule. Relates to RELAY-325. Signed-off-by: Zhongxuan Wang <daniewang@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:
WalkthroughAdds a ChangesCodec resolve pipeline and observability integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/adaptive/src/acg/request_surfaces/mod.rs`:
- Around line 83-89: The detect_request_surface function classifies
messages-only requests (containing only {"messages": ...}) as OpenAiChat, which
causes failures when the provider is "anthropic" at the supports_provider check
around lines 97-103. Add provider-aware tie-breaking logic before the
supports_provider validation to handle provider-specific variations where
certain providers like Anthropic can accept messages without a top-level system
field, ensuring that messages-only requests are properly disambiguated based on
the actual provider capability rather than just the detected surface
classification.
In `@crates/core/tests/unit/types_tests.rs`:
- Around line 673-676: The test for normalized_llm_request() currently only
asserts that the messages list is not empty, but does not verify the actual
decoded content or which source won in the fallback/preference logic. Replace
the assertion checking is_empty() with stronger assertions that validate the
specific content of the decoded request from normalized.messages, ensuring the
test proves which source (annotation vs raw payload) was actually used rather
than just confirming that some content was returned.
🪄 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: f2c4301e-8dc2-446c-b1bd-201859045b54
📒 Files selected for processing (18)
crates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/api/event.rscrates/core/src/codec/mod.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/src/codec/traits.rscrates/core/src/observability/atif.rscrates/core/src/observability/manual.rscrates/core/src/observability/mod.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/tests/unit/atif_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/types_tests.rsdocs/integrate-into-frameworks/provider-response-codecs.mdx
📜 Review details
⏰ Context from checks skipped due to timeout. (25)
- GitHub Check: WebAssembly / Test (windows-arm64)
- GitHub Check: Rust / Test (linux-arm64)
- GitHub Check: Rust / Test (linux-amd64)
- GitHub Check: Rust / Test (windows-arm64)
- GitHub Check: WebAssembly / Test (windows-amd64)
- GitHub Check: Go / Test (windows-arm64)
- GitHub Check: Rust / Test (macos-arm64)
- GitHub Check: WebAssembly / Test (linux-arm64)
- GitHub Check: WebAssembly / Test (macos-arm64)
- GitHub Check: Rust / Test (windows-amd64)
- GitHub Check: WebAssembly / Test (linux-amd64)
- GitHub Check: Go / Test (linux-arm64)
- GitHub Check: Node.js / Test (windows-amd64)
- GitHub Check: Python / Test (linux-arm64)
- GitHub Check: Go / Test (linux-amd64)
- GitHub Check: Go / Test (macos-arm64)
- GitHub Check: Python / Test (linux-amd64)
- GitHub Check: Go / Test (windows-amd64)
- GitHub Check: Python / Test (windows-amd64)
- GitHub Check: Node.js / Test (macos-arm64)
- GitHub Check: Node.js / Test (windows-arm64)
- GitHub Check: Python / Test (macos-arm64)
- GitHub Check: Python / Test (windows-arm64)
- GitHub Check: Node.js / Test (linux-amd64)
- GitHub Check: Node.js / Test (linux-arm64)
🧰 Additional context used
📓 Path-based instructions (29)
**/*.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/tests/unit/types_tests.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rsdocs/integrate-into-frameworks/provider-response-codecs.mdxcrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/src/codec/mod.rscrates/core/src/codec/traits.rscrates/adaptive/src/acg/request_surfaces/mod.rscrates/core/src/observability/mod.rscrates/core/src/observability/manual.rscrates/core/src/api/event.rscrates/core/tests/unit/types_tests.rscrates/core/src/observability/atif.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rscrates/core/src/observability/otel.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/codec/resolve_tests.rscrates/core/tests/unit/types_tests.rscrates/core/tests/unit/observability/manual_tests.rscrates/core/tests/unit/codec/openai_responses_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/atif_tests.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers
Files:
crates/adaptive/src/acg/request_surfaces/mod.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations
Files:
crates/adaptive/src/acg/request_surfaces/mod.rs
{docs/**,README.md,CONTRIBUTING.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
{docs/**,README.md,CONTRIBUTING.md}: For docs-only changes, run targeted checks only if commands, package names, or examples changed. Usejust docsfor docs-site builds andjust docs-linkcheckwhen links changed
Run docs site build withjust docs
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
{docs/**,README.md,CONTRIBUTING.md,**/*.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Run docs link validation with
just docs-linkcheckwhen links change
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
{docs/**,README.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Verify README and docs entry points still match current package names and paths for large or public-facing changes
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
{docs/**,examples/**,README.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Verify examples still run with documented commands for large or public-facing changes
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
{docs/**,README.md,**/Cargo.toml,**/package.json,**/*.md}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Ensure renamed public surfaces are reflected consistently in manifests and docs for large or public-facing changes
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
**/*.{md,mdx,py,sh,yaml,yml,toml,json}
📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)
Keep package names, repo references, and build commands current
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
**/*.mdx
📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)
In MDX files, top-of-file comments must use JSX comment delimiters: {/* to open and */} to close. Do not use HTML comments for MDX SPDX headers.
MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
**/*.{html,md,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Include SPDX license header in HTML and Markdown files using HTML comment syntax
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Update embedded documentation snippets, patch docs, and binding-support notes if examples or supported bindings changed
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
docs/**
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Run
just docsor./scripts/build-docs.sh htmlto regenerate ignored Fern API reference pages before validation for documentation site changes
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}
⚙️ CodeRabbit configuration file
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}: Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.
Flag stale examples, missing SPDX headers where required, and instructions that no longer match CI or pre-commit behavior.
Files:
docs/integrate-into-frameworks/provider-response-codecs.mdx
crates/core/src/api/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Implement behavior first in Rust core API modules:
crates/core/src/api/and related core modules such ascrates/core/src/api/runtime/,crates/core/src/codec/, orcrates/core/src/json.rs
Files:
crates/core/src/api/event.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.rscrates/core/src/observability/otel.rscrates/core/src/observability/openinference.rs
🔇 Additional comments (19)
crates/core/src/codec/resolve.rs (1)
1-94: LGTM!crates/core/src/codec/mod.rs (1)
13-22: LGTM!crates/core/src/codec/traits.rs (1)
21-23: LGTM!crates/core/src/codec/openai_responses.rs (1)
195-199: LGTM!Also applies to: 252-259, 472-473
crates/core/tests/unit/codec/resolve_tests.rs (1)
1-221: LGTM!crates/core/tests/unit/codec/openai_responses_tests.rs (1)
314-364: LGTM!crates/adaptive/src/acg/request_surfaces/mod.rs (1)
19-51: LGTM!crates/core/src/observability/mod.rs (1)
16-17: LGTM!crates/core/src/observability/manual.rs (1)
1-197: LGTM!crates/core/tests/unit/observability/manual_tests.rs (1)
1-106: LGTM!crates/core/src/observability/openinference.rs (1)
23-23: LGTM!Also applies to: 726-745, 756-773, 807-822, 831-838, 1140-1142, 1161-1161
crates/core/tests/unit/observability/openinference_tests.rs (1)
957-963: LGTM!Also applies to: 965-1148, 2268-2268
docs/integrate-into-frameworks/provider-response-codecs.mdx (1)
482-489: LGTM!crates/core/src/api/event.rs (2)
18-18: LGTM!Also applies to: 27-31
614-638: 📐 Maintainability & Code QualityConfirm required Rust/core validation before merge.
This shared Event API path affects core observability contracts; please ensure the PR/CI evidence includes the exact Rust checks and full binding matrix, or explicitly documents any draft-only omissions.
As per coding guidelines, “Any Rust change must run
just test-rust”, “Run Rust formatting withcargo fmt --all”, “Runcargo clippy --workspace --all-targets -- -D warnings”, and changes tocrates/coremust run “the full matrix across Rust, Python, Go, Node.js, and WebAssembly”.Source: Coding guidelines
crates/core/tests/unit/types_tests.rs (1)
604-677: LGTM!crates/core/src/observability/otel.rs (1)
23-29: LGTM!Also applies to: 683-704
crates/core/src/observability/atif.rs (1)
41-42: LGTM!Also applies to: 1058-1087, 2246-2249, 2290-2293
crates/core/tests/unit/atif_tests.rs (1)
11-26: LGTM!Also applies to: 70-84, 133-142, 196-235, 275-290, 1717-1927
|
@coderabbitai review |
✅ Action performedReview finished.
|
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/adaptive/src/acg/request_surfaces/mod.rs`:
- Around line 99-109: The comment preceding the provider check for Anthropic
does not accurately describe the detection behavior. The comment states "A
messages-only request" but the actual detection via surface ==
RequestSurface::OpenAIChat is broader and matches any request with messages but
without system/input/instructions, regardless of other keys like response_format
or tools. Replace the comment block before the if provider == "anthropic"
condition with a more accurate description that explains the detection
classifies requests with messages but without system/input/instructions as
OpenAI Chat, which are also valid Anthropic Messages requests, and when the
provider is Anthropic, the surface is preferred accordingly.
🪄 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: 0832fde5-bcf6-4ff6-96b9-77eb1fef1ddf
📒 Files selected for processing (2)
crates/adaptive/src/acg/request_surfaces/mod.rscrates/adaptive/tests/unit/acg/request_surface_tests.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (26)
- GitHub Check: Rust / Test (macos-arm64)
- GitHub Check: Rust / Test (windows-arm64)
- GitHub Check: Rust / Test (linux-arm64)
- GitHub Check: WebAssembly / Test (linux-arm64)
- GitHub Check: WebAssembly / Test (linux-amd64)
- GitHub Check: Rust / Test (windows-amd64)
- GitHub Check: Rust / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (macos-arm64)
- GitHub Check: WebAssembly / Test (windows-amd64)
- GitHub Check: Node.js / Test (linux-arm64)
- GitHub Check: Python / Test (windows-arm64)
- GitHub Check: Node.js / Test (macos-arm64)
- GitHub Check: WebAssembly / Test (windows-arm64)
- GitHub Check: Python / Test (linux-arm64)
- GitHub Check: Node.js / Test (windows-arm64)
- GitHub Check: Python / Test (linux-amd64)
- GitHub Check: Node.js / Test (linux-amd64)
- GitHub Check: Go / Test (windows-arm64)
- GitHub Check: Node.js / Test (windows-amd64)
- GitHub Check: Go / Test (linux-amd64)
- GitHub Check: Python / Test (macos-arm64)
- GitHub Check: Go / Test (windows-amd64)
- GitHub Check: Go / Test (linux-arm64)
- GitHub Check: Python / Test (windows-amd64)
- 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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers
Files:
crates/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations
Files:
crates/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rscrates/adaptive/src/acg/request_surfaces/mod.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/adaptive/tests/unit/acg/request_surface_tests.rs
🔇 Additional comments (2)
crates/adaptive/src/acg/request_surfaces/mod.rs (1)
44-51: LGTM!crates/adaptive/tests/unit/acg/request_surface_tests.rs (1)
309-322: LGTM!
|
/ok to test 633820a |
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
633820a to
3d93e03
Compare
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
…ider-schema-handling Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
|
/ok to test a369cd4 |
679ce9f to
a369cd4
Compare
Use OpenAIChat and OpenAIResponses to match OpenAIChatCodec and OpenAIResponsesCodec naming. Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
89864f0 to
b200506
Compare
|
/ok to test e307e8d |
|
/merge |
…try (#301) #### Overview Implements RELAY-362, the follow-up requested in review of #291: move provider-surface detection out of the hard-coded `if/else` chains in `codec::resolve` into **codec-owned descriptors** iterated through a small built-in registry. `resolve.rs` is now provider-agnostic (no provider field-name literals), new built-in surfaces become additive, and a codec-owned **provider hint** can disambiguate the one ambiguous request shape (an Anthropic request without a top-level `system`). The change is additive, Rust-core-only, and behavior-preserving: every existing `codec::resolve` test passes unchanged and the adaptive path is untouched. - [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 - **`codec::resolve`** — added a `pub(crate) SurfaceDescriptor` (a hint-aware request detector, a response detector, and decode entry points) and a by-value `static REGISTRY` ordered by request-detection priority (Responses > Anthropic > Chat). The public functions are now provider-agnostic policy only: first registry match for requests, unique match for responses, fail-open `normalize_*`. `ProviderSurface` and every existing public signature are unchanged. - **New `pub fn detect_request_surface_with_hint(body, Option<&str>)`** — `detect_request_surface` delegates to it with `None` for exact parity. A recognized hint can only *upgrade* the ambiguous `messages`-only shape; registry priority order keeps it from overriding a strong `input`/`instructions`/`system` signal. - **Codec-owned detection** — each built-in codec module (`openai_chat`, `openai_responses`, `anthropic`) owns its detectors (as closures) and decode entry points in a `SURFACE_DESCRIPTOR` const. Only Anthropic's request detector is hint-aware (it claims a system-less `messages` body when the hint is `"anthropic"`); the OpenAI detectors ignore the hint. Adding a future built-in surface (e.g. Gemini) means registering a descriptor, not editing detection logic. - **Not wired into adaptive (deferred follow-up)** — the hint is available but not yet called. Wiring it into `resolve_request_surface` / `build_semantic_request_view` would change ACG pass-through behavior, so it is intentionally left to a separate follow-up. The shape-only ACG path and its source-guard test are untouched. - **Tests** — added hint coverage (parity with a `None` hint, the Anthropic upgrade, "never overrides a strong signal", non-object input); the existing detection/normalization tests are unchanged. No breaking changes. Local validation: `cargo test -p nemo-relay`, `-p nemo-relay-adaptive`, and `-p nemo-relay-pii-redaction` pass; `cargo clippy -p nemo-relay --all-features --all-targets`, `cargo fmt --check`, and `cargo doc -p nemo-relay` are clean for the changed files. The full cross-language matrix is left to CI (no binding surfaces `codec::resolve`). #### Where should the reviewer start? `crates/core/src/codec/resolve.rs` — the `SurfaceDescriptor` + `REGISTRY` and the detection-policy functions (`detect_request_surface_with_hint`, `detect_response_surface`). Then the per-codec `SURFACE_DESCRIPTOR` blocks, especially `anthropic.rs`'s hint-aware `detect_request`: registry priority order (Responses before Anthropic) is what keeps the `"anthropic"` hint from overriding a strong `input`/`instructions` signal. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Closes RELAY-362 ## Summary by CodeRabbit * **New Features** * Added centralized, surface-descriptor-based request/response detection for Anthropic and OpenAI formats. * Introduced provider hints to disambiguate request classification when payload signals overlap. * **Bug Fixes** * Reduced misclassification by selecting a format only when the response shape matches exactly one supported descriptor. * Updated normalization to decode via the detected format while preserving fail-open behavior on unrecognized inputs. * **Tests** * Expanded unit coverage for hint behavior, request decoding, and stricter handling of ambiguous response shapes. Authors: - Zhongxuan (Daniel) Wang (https://github.com/zhongxuanwang-nv) - Maryam Najafian (https://github.com/mnajafian-nv) Approvers: - Maryam Najafian (https://github.com/mnajafian-nv) URL: #301
#### 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
Consolidate provider schema handling for OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages behind a single codec-layer path, so exporters and plugins consume normalized provider data instead of re-implementing provider parsing from raw JSON. This adds new public Rust core API (
codec::resolve,Event::normalized_llm_request/normalized_llm_response); the change is additive and Rust-only, with no breaking changes.Local validation:
cargo test -p nemo-relay(638 passing),cargo clippy -p nemo-relay --all-features --all-targetsclean, single-feature (otel/openinference) builds warning-free, and adaptive request-surface tests pass. The full cross-language matrix is left to CI.Details
codec::resolve(new) — the canonical detect-then-decode entry point:ProviderSurface+detect_request_surface(priority order hoisted from adaptive) /detect_response_surface(strict; ambiguous or empty payloads classify toNone) + fail-opennormalize_request/normalize_response.Event::normalized_llm_request/normalized_llm_response— annotation-firstCowhelpers over the detector;annotated_*()left unchanged. Rustdoc documents the{headers, content}LlmRequestprecondition for the request fallback.OpenAIResponsesCodec— response-only extension to decode top-leveloutput_textand item-leveloutput[].type == "output_text"(structuredoutputkeeps precedence).observability::manual(new) — the OpenTelemetry/OpenInference non-provider usage/cost fallback de-duplicated into one module, with the USD-only vs emit-any-currency policy parameterized.resolve_request_surface_from_requestdelegates tocodec::resolve::detect_request_surface.provider-response-codecs.mdx; fixed the misleading "global codec registry" / "request codecs' priority order" docstrings and noted the detection limitation forsystem-less Anthropic requests.Where should the reviewer start?
crates/core/src/codec/resolve.rs(the single detect-then-decode path), thencrates/core/src/observability/atif.rsandopeninference.rs— the annotation-first / raw-fallback consumers are the trickiest equivalence surface, where the raw parser is intentionally retained because the normalized form would be lossy (tool-call extras, multimodal content, metrics).Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
Release Notes
New Features
Improvements