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 <[email protected]>
|
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 <[email protected]>
633820a to
3d93e03
Compare
The design was that ACG adopted the provider codec first. If we are extending Relay to use provider codecs in more places, we can change the surface to pass this in. The consequences of this are that (1) ACG is really only support with Anthropic and (2) we need to ensure compatibility without breaking the existing public configuration surface. |
That makes sense! I just dropped the unused provider-aware tie-break code, and since that making |
Signed-off-by: Zhongxuan Wang <[email protected]>
…ider-schema-handling Signed-off-by: Zhongxuan Wang <[email protected]>
Signed-off-by: Zhongxuan Wang <[email protected]>
…ider-schema-handling Signed-off-by: Zhongxuan Wang <[email protected]>
|
/ok to test a369cd4 |
679ce9f to
a369cd4
Compare
Use OpenAIChat and OpenAIResponses to match OpenAIChatCodec and OpenAIResponsesCodec naming. Signed-off-by: Zhongxuan Wang <[email protected]>
89864f0 to
b200506
Compare
|
/ok to test e307e8d |
|
/merge |
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