refactor: share agent and provider extraction strategies#318
Conversation
|
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:
WalkthroughThe PR centralizes provider and agent payload extraction behind descriptors and extractor traits, threads provider hints through request normalization and session affinity tracking, and updates docs and tests to match the new extraction boundaries. ChangesDescriptor-driven extraction and normalization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
f62642e to
655f4c2
Compare
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/cli/src/adapters/mod.rs`:
- Around line 120-132: The normalized metadata builder in the adapter should
stop propagating user_email, since it is currently inserted alongside other
fields and later exported in traces. Update the metadata normalization logic in
the function that iterates over the payload keys to omit user_email entirely, or
only include it behind an explicit redaction/opt-in gate. Keep the existing
handling for cwd, transcript_path, project_dir, model, agent_id, and agent_type
unchanged.
In `@crates/core/src/codec/anthropic.rs`:
- Around line 43-50: The Anthropic request detector in PROVIDER_SURFACE is too
narrow because detect_request only checks for a top-level system field, so raw
Anthropic Messages requests without system get misrouted to OpenAIChat. Update
the AnthropicMessages surface detection to recognize another Anthropic-specific
discriminator or use provider context in
resolve_request_surface/normalize_request, and ensure AnthropicMessagesCodec is
selected for no-system requests. Add a regression test around the Anthropic
detector and surface resolution for the no-system case.
🪄 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: 7cad5b0d-f873-4f2c-89ba-d70d00f2a393
📒 Files selected for processing (8)
crates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rsdocs/about-nemo-relay/concepts/codecs.mdx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (25)
**/*.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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/mod.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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.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/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rsdocs/about-nemo-relay/concepts/codecs.mdxcrates/core/src/codec/resolve.rscrates/cli/src/alignment/mod.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.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.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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/codecs.mdx
🔇 Additional comments (3)
docs/about-nemo-relay/concepts/codecs.mdx (1)
83-131: LGTM!crates/cli/src/adapters/mod.rs (1)
34-118: LGTM!Also applies to: 133-321, 335-386
crates/core/src/codec/resolve.rs (1)
27-53: 📐 Maintainability & Code QualityAdd the required core-runtime validation before merge.
This changes
crates/corecodec dispatch, but the PR validation list still omitscargo clippy --workspace --all-targets -- -D warnings, the full binding test matrix, andvalidate-change. Please include those runs so the shared runtime contract is exercised outside the Rust-only path.As per coding guidelines, "If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly" and "If the change touchedcrates/coreor shared runtime semantics, also usevalidate-changefor broader validation."Also applies to: 92-103
Source: Coding guidelines
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 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/cli/src/adapters/mod.rs`:
- Around line 120-132: The normalized metadata builder in the adapter should
stop propagating user_email, since it is currently inserted alongside other
fields and later exported in traces. Update the metadata normalization logic in
the function that iterates over the payload keys to omit user_email entirely, or
only include it behind an explicit redaction/opt-in gate. Keep the existing
handling for cwd, transcript_path, project_dir, model, agent_id, and agent_type
unchanged.
In `@crates/core/src/codec/anthropic.rs`:
- Around line 43-50: The Anthropic request detector in PROVIDER_SURFACE is too
narrow because detect_request only checks for a top-level system field, so raw
Anthropic Messages requests without system get misrouted to OpenAIChat. Update
the AnthropicMessages surface detection to recognize another Anthropic-specific
discriminator or use provider context in
resolve_request_surface/normalize_request, and ensure AnthropicMessagesCodec is
selected for no-system requests. Add a regression test around the Anthropic
detector and surface resolution for the no-system case.
🪄 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: 7cad5b0d-f873-4f2c-89ba-d70d00f2a393
📒 Files selected for processing (8)
crates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rsdocs/about-nemo-relay/concepts/codecs.mdx
📜 Review details
🔇 Additional comments (3)
docs/about-nemo-relay/concepts/codecs.mdx (1)
83-131: LGTM!crates/cli/src/adapters/mod.rs (1)
34-118: LGTM!Also applies to: 133-321, 335-386
crates/core/src/codec/resolve.rs (1)
27-53: 📐 Maintainability & Code QualityAdd the required core-runtime validation before merge.
This changes
crates/corecodec dispatch, but the PR validation list still omitscargo clippy --workspace --all-targets -- -D warnings, the full binding test matrix, andvalidate-change. Please include those runs so the shared runtime contract is exercised outside the Rust-only path.As per coding guidelines, "If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly" and "If the change touchedcrates/coreor shared runtime semantics, also usevalidate-changefor broader validation."Also applies to: 92-103
Source: Coding guidelines
🛑 Comments failed to post (2)
crates/cli/src/adapters/mod.rs (1)
120-132: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash rg -nP '\buser_email\b' --type=rust rg -nP '\.metadata\b' --type=rust crates/cli/src -C2Repository: NVIDIA/NeMo-Relay
Length of output: 155
🏁 Script executed:
#!/bin/bash set -euo pipefail git ls-files crates/cli/src/adapters/mod.rs crates/cli/src | sed -n '1,120p' echo '--- outline ---' ast-grep outline crates/cli/src/adapters/mod.rs --view expanded || true echo '--- lines 1-260 ---' sed -n '1,260p' crates/cli/src/adapters/mod.rs | cat -n echo '--- search metadata consumers in cli ---' rg -n 'metadata' crates/cli/src -g '*.rs' -C 2 || true echo '--- search user_email across repo ---' rg -n 'user_email' -g '*.rs' -g '*.md' -g '*.toml' || trueRepository: NVIDIA/NeMo-Relay
Length of output: 50374
user_emailshould not be propagated into normalized metadata. It is merged into session/scope metadata and ends up in exported traces; drop it or gate it behind an explicit redaction/opt-in flag.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/cli/src/adapters/mod.rs` around lines 120 - 132, The normalized metadata builder in the adapter should stop propagating user_email, since it is currently inserted alongside other fields and later exported in traces. Update the metadata normalization logic in the function that iterates over the payload keys to omit user_email entirely, or only include it behind an explicit redaction/opt-in gate. Keep the existing handling for cwd, transcript_path, project_dir, model, agent_id, and agent_type unchanged.Source: Coding guidelines
crates/core/src/codec/anthropic.rs (1)
43-50: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n== relevant files ==\n' git ls-files crates/core/src/codec | sed -n '1,120p' printf '\n== anthropic codec outline ==\n' ast-grep outline crates/core/src/codec/anthropic.rs --view expanded || true printf '\n== resolve outline ==\n' ast-grep outline crates/core/src/codec/resolve.rs --view expanded || true printf '\n== request surface adapter outline ==\n' ast-grep outline crates/adaptive/src/acg/request_surfaces/mod.rs --view expanded || true printf '\n== search detector definitions ==\n' rg -n "detect_request:|ProviderSurface::AnthropicMessages|OpenAIChat|OpenAIResponses|detect_request_surface|normalize_request" \ crates/core/src/codec crates/adaptive/src/acg/request_surfaces -n printf '\n== anthropic codec excerpt ==\n' sed -n '1,180p' crates/core/src/codec/anthropic.rs printf '\n== resolve excerpt ==\n' sed -n '1,220p' crates/core/src/codec/resolve.rs printf '\n== request surfaces excerpt ==\n' sed -n '1,260p' crates/adaptive/src/acg/request_surfaces/mod.rsRepository: NVIDIA/NeMo-Relay
Length of output: 32089
🏁 Script executed:
#!/bin/bash set -euo pipefail printf '\n== resolve tests ==\n' sed -n '1,260p' crates/core/tests/unit/codec/resolve_tests.rs printf '\n== anthropic codec tests ==\n' sed -n '850,980p' crates/core/src/codec/anthropic.rs printf '\n== anthropic request decode/encode path ==\n' sed -n '180,620p' crates/core/src/codec/anthropic.rs printf '\n== adaptive request surface tests ==\n' sed -n '1,260p' crates/adaptive/src/acg/request_surfaces/mod.rsRepository: NVIDIA/NeMo-Relay
Length of output: 32368
Anthropic detector needs a discriminator beyond
system. Valid Anthropic Messages requests can omit top-levelsystem, but this predicate falls through toOpenAIChatfor that shape, soresolve_request_surface()rejects raw Anthropic requests andnormalize_request()picks the wrong codec. Add another Anthropic-specific check or route by provider context, and cover the no-system case with a regression test.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/src/codec/anthropic.rs` around lines 43 - 50, The Anthropic request detector in PROVIDER_SURFACE is too narrow because detect_request only checks for a top-level system field, so raw Anthropic Messages requests without system get misrouted to OpenAIChat. Update the AnthropicMessages surface detection to recognize another Anthropic-specific discriminator or use provider context in resolve_request_surface/normalize_request, and ensure AnthropicMessagesCodec is selected for no-system requests. Add a regression test around the Anthropic detector and surface resolution for the no-system case.
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/cli/src/adapters/mod.rs`:
- Around line 117-127: The metadata normalization in the adapter is promoting
high-cardinality/PII fields into shared event metadata, which should be kept
low-cardinality and stable. Update the normalization logic in the helper around
the header/payload mapping so `cwd`, `transcript_path`, `project_dir`, and
`user_email` are not copied into the shared metadata object; keep them only in
the raw payload or redact/hash them before insertion. Apply the same fix in the
corresponding event normalization block referenced by the same field set so both
locations stay consistent.
In `@crates/core/src/codec/resolve.rs`:
- Around line 114-117: normalize_request currently ignores provider context by
always calling request_descriptor with None, so ambiguous messages-only
Anthropic requests can still resolve to the OpenAI Chat codec through the event
fallback path. Update normalize_request (and the call site in event.rs if
needed) to thread through a provider hint or add a hint-aware normalization
entry point that uses detect_request_surface_with_hint. Add a regression test
covering the Anthropic {"messages": ...} shape to verify it normalizes to the
Anthropic path instead of the OpenAI one.
🪄 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: f61c0bfa-a0a1-4f85-a97b-cef13c07969d
📒 Files selected for processing (8)
crates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/openai_chat.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rsdocs/about-nemo-relay/concepts/codecs.mdx
💤 Files with no reviewable changes (1)
- docs/about-nemo-relay/concepts/codecs.mdx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (14)
**/*.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/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_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/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.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/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/mod.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/openai_responses.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.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/openai_responses.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.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/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.rscrates/cli/src/adapters/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/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/openai_responses.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/src/codec/openai_chat.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.rs
🔇 Additional comments (1)
crates/core/src/codec/resolve.rs (1)
52-56: 📐 Maintainability & Code QualityPlease add the required
crates/corevalidation before merge.The PR summary lists
cargo fmt --all, targeted Rust tests,just test-rust, andjust docs, but the repo guidance forcrates/coreRust changes also expectscargo clippy --workspace --all-targets -- -D warnings,uv run pre-commit run --all-files,validate-change, and the full binding matrix (just test-python,just test-node,just test-go,just test-wasm). As per coding guidelines, "Ifcrates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly."Source: Coding guidelines
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/cli/src/adapters/mod.rs`:
- Around line 201-204: This is a tracked migration TODO for the free-function
shims in `mod.rs`; make sure the planned shim removal won’t be lost by filing or
linking a follow-up issue. Update the `TODO(extraction)` note near the shim
functions to reference the tracking issue, and keep the callers pointed at
`AgentPayloadExtractor` implementations as the migration progresses.
🪄 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: 251f94b1-8c28-48e3-911c-329a8b0e2383
📒 Files selected for processing (6)
crates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rsdocs/about-nemo-relay/concepts/codecs.mdx
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (25)
**/*.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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/src/alignment/mod.rscrates/core/src/codec/resolve.rsdocs/about-nemo-relay/concepts/codecs.mdxcrates/cli/src/adapters/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/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/codec/resolve_tests.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/resolve.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/resolve.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/resolve.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/resolve.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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/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/about-nemo-relay/concepts/codecs.mdx
🔇 Additional comments (8)
crates/cli/src/alignment/mod.rs (1)
606-609: 📐 Maintainability & Code QualityRun the required Rust lint pass.
The PR validation list covers
cargo fmt --allandjust test-rust, but it omitscargo clippy --workspace --all-targets -- -D warnings, which is required for any Rust change in this repo. As per coding guidelines,**/*.rs: "If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings."Source: Coding guidelines
docs/about-nemo-relay/concepts/codecs.mdx (1)
83-138: LGTM!crates/core/src/codec/resolve.rs (2)
70-72: 🩺 Stability & AvailabilityConfirm
normalize_requestthreads the provider hint, not just detection.
detect_request_surfacedeliberately delegates withNone, but the prior review flagged thatnormalize_requestalso hardcodesNone, so theevent.rsfallback path normalizes messages-only Anthropic requests through the OpenAI Chat descriptor. The newrequest_descriptorhelper and the test atresolve_tests.rs:297-300confirm that aNonehint resolves messages-only payloads toOpenAIChat— verify the normalization entry point actually plumbs the provider hint so this isn't silently mis-decoded.#!/bin/bash # Inspect normalize_request and its event.rs call site for hint threading. fd resolve.rs -p crates/core/src/codec --exec sed -n '104,130p' rg -nP -C3 '\bnormalize_request\s*\(' crates/core/src
38-47: LGTM!crates/core/tests/unit/codec/resolve_tests.rs (1)
289-313: LGTM!crates/cli/src/adapters/mod.rs (1)
139-198: LGTM!crates/cli/tests/coverage/adapters_tests.rs (2)
234-317: LGTM!
340-341: LGTM!
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/cli/tests/coverage/adapters_tests.rs`:
- Line 820: The coverage test around the normalized payload only checks that
`metadata` no longer contains `cwd`, so it can still pass if `cwd` is dropped
entirely. Update the test in `adapters_tests.rs` to also assert the relocated
`cwd` remains present on `event.payload["cwd"]`, using the existing normalized
event assertions in this test case so the relocation contract is fully covered.
🪄 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: 9c33e325-6e14-454c-ab62-d52e0d81f7cd
📒 Files selected for processing (7)
crates/cli/src/adapters/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/api/event.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/tests/unit/types_tests.rs
💤 Files with no reviewable changes (1)
- crates/cli/src/adapters/mod.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (15)
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
**/*.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/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_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/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
**/*.{h,hpp,c,cpp,rs}
📄 CodeRabbit inference engine (.agents/skills/maintain-packaging/SKILL.md)
Ensure FFI header and library naming follows consistent conventions across platform-specific builds
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/src/api/event.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update Rust crate names and module prefixes during coordinated rename operations
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
crates/core/**/*.rs: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.
Files:
crates/core/src/api/event.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
crates/{core,adaptive}/**
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly
Files:
crates/core/src/api/event.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
**/*.{rs,py,go,js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions: Rust and Python use
snake_case, C FFI exports prefixednemo_relay_, Go usesPascalCasefor public APIs, Node.js usescamelCase.
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
crates/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
UseJson = serde_json::Valuein Rust-facing runtime APIs for JSON payload handling.
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points wasm/ # wasm-bindgen WebAssembly binding and JS wrappers python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile third_party/ # P...
Files:
crates/core/src/api/event.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/src/api/event.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/types_tests.rscrates/core/src/codec/anthropic.rscrates/core/tests/unit/codec/resolve_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Maintain documented and tested validation and report behavior for adaptive surfaces
Files:
crates/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/types_tests.rscrates/core/tests/unit/codec/resolve_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/cli/tests/coverage/adapters_tests.rscrates/core/tests/unit/types_tests.rscrates/core/tests/unit/codec/resolve_tests.rs
🔇 Additional comments (6)
crates/cli/tests/coverage/adapters_tests.rs (1)
31-37: LGTM!Also applies to: 342-345
crates/core/src/codec/anthropic.rs (1)
43-58: LGTM!crates/core/src/codec/resolve.rs (1)
118-131: Resolves the prior hint-threading gap.normalize_request_with_hintis now the hint-aware entry point andevent.rscalls it, so the messages-only Anthropic fallback path is no longer forced through OpenAI Chat when a hint is present.normalize_requestpreservingNonekeeps existing shape-only behavior intact.crates/core/tests/unit/codec/resolve_tests.rs (1)
278-356: LGTM!crates/core/tests/unit/types_tests.rs (1)
679-708: LGTM!crates/core/src/api/event.rs (1)
42-42: 🎯 Functional CorrectnessNeed the LLM handle construction and the provider-hint matcher to decide whether the name is contractual or just a caller-controlled label.
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/cli/tests/coverage/adapters_tests.rs (1)
278-319: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winExercise the populated event builders, not just the extractor.
This test proves
BUILTIN_AGENT_PAYLOAD_EXTRACTOR, but the PR also rewiredcommon_llm_hint_eventandcommon_tool_eventto consume that data. A field-mapping regression there would still pass. Add assertions on the emittedLlmHintEvent/ToolEventfor this populated payload. As per path instructions, "Tests should cover the behavior promised by the changed API surface."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/cli/tests/coverage/adapters_tests.rs` around lines 278 - 319, This test only validates BUILTIN_AGENT_PAYLOAD_EXTRACTOR, but the changed behavior also flows through common_llm_hint_event and common_tool_event. Update the populated payload test to assert the emitted LlmHintEvent and ToolEvent values, not just the extracted hint/tool call data, so the field mapping from the builder functions is covered. Use the existing builtin_extractor_reads_agent_hint_and_tool_call_fields test as the anchor and verify the full event contents for the same payload.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/api/event.rs`:
- Around line 42-45: The request normalization in event handling is using
LlmHandle.name as a codec hint, which can change classification for non-gateway
callers. Update resolve::normalize_request_with_hint usage in the event path so
only known gateway route names are treated as hints, or add a separate explicit
provider-surface hint field instead of reusing the logical name. Keep
CreateLlmHandleParams::name as a logical/provider identifier and preserve
existing fallback normalization behavior for non-gateway cases.
---
Outside diff comments:
In `@crates/cli/tests/coverage/adapters_tests.rs`:
- Around line 278-319: This test only validates BUILTIN_AGENT_PAYLOAD_EXTRACTOR,
but the changed behavior also flows through common_llm_hint_event and
common_tool_event. Update the populated payload test to assert the emitted
LlmHintEvent and ToolEvent values, not just the extracted hint/tool call data,
so the field mapping from the builder functions is covered. Use the existing
builtin_extractor_reads_agent_hint_and_tool_call_fields test as the anchor and
verify the full event contents for the same payload.
🪄 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: 14e1d14b-eaf5-4591-ad5b-3099be3cc670
📒 Files selected for processing (9)
crates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/cli/src/gateway.rscrates/cli/tests/coverage/adapters_tests.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (17)
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/runtime/state.rscrates/core/src/api/event.rscrates/core/src/api/llm.rs
**/*.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.rs
crates/core/src/api/runtime/state.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
crates/core/src/api/runtime/state.rs: Add registry fields asSortedRegistry<GuardrailEntry<T>>orSortedRegistry<Intercept<T>>toNemoRelayContextStateincrates/core/src/api/runtime/state.rs
Add chain execution helpers toNemoRelayContextStatefollowing the pattern of existing methods liketool_sanitize_request_chainortool_request_intercepts_chain
Files:
crates/core/src/api/runtime/state.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/cli/src/gateway.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/cli/src/alignment/mod.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/src/adapters/mod.rscrates/core/src/codec/resolve.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/src/api/runtime/state.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rs
crates/core/src/api/{tool,llm}.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Wire the new middleware chain into the execute path in
crates/core/src/api/tool.rsorcrates/core/src/api/llm.rsat the appropriate pipeline stage
Files:
crates/core/src/api/llm.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/cli/tests/coverage/adapters_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/cli/tests/coverage/adapters_tests.rs
🔇 Additional comments (4)
crates/cli/src/adapters/mod.rs (1)
82-86: 📐 Maintainability & Code QualityAdd the missing Rust validation steps before merge.
The PR validation list includes
cargo fmt --allandjust test-rust, but it still needscargo clippy --workspace --all-targets -- -D warningsanduv run pre-commit run --all-filesfor a Rust change in this repo. Please include those results as well. As per coding guidelines, "Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings" and "Validate Rust code withuv run pre-commit run --all-files."Source: Coding guidelines
crates/cli/tests/coverage/adapters_tests.rs (1)
238-275: LGTM!crates/cli/src/alignment/mod.rs (1)
90-117: LGTM!Also applies to: 613-625
crates/core/src/codec/resolve.rs (1)
30-32: 📐 Maintainability & Code QualityPlease add the required repo validation for this
crates/corechange.The PR summary only lists targeted Rust tests,
cargo fmt --all,just test-rust, andjust docs, but the repo guidance forcrates/corechanges is stricter: run the full binding matrix plus the required Rust lint/pre-commit checks before merge. Please attach results forcargo clippy --workspace --all-targets -- -D warnings,uv run pre-commit run --all-files,validate-change, and the affected binding suites. As per coding guidelines, "If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly" and "Validate Rust code with uv run pre-commit run --all-files."Source: Coding guidelines
|
@coderabbitai review |
✅ Action performedReview finished.
|
✅ Action performedReview finished.
|
…raction-strategies
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/cli/src/adapters/mod.rs`:
- Around line 681-689: The synthetic fallback session ID is being regenerated
inside session_id, which can split related events from the same payload across
different session_id values. Compute the fallback once per
payload/classification path and pass it through common_session_event and the
prompt-submitted/stop event builders instead of calling session_id with a fresh
Uuid::now_v7() in each helper; use session_id, common_session_event, and the
prompt-submitted/stop branches as the main places to update.
In `@crates/cli/src/alignment/mod.rs`:
- Around line 54-64: Keep the provider-name mapping single-sourced between
GatewayRouteKind::from_provider_name and ProviderRoute::name so they cannot
drift. Update the mapping logic to reuse a shared source of truth from
GatewayRouteKind, ProviderRoute, or a common constant/table, and add a parity
test that verifies every ProviderRoute::name() value maps back through
GatewayRouteKind::from_provider_name(). This should cover the OpenAI and
Anthropic variants used by gateway_session_id(), request_affinity_key(), and
gateway_turn_input().
In `@crates/core/src/api/event.rs`:
- Around line 42-45: This core change needs the missing validation matrix added
to the PR checks. Update the required verification for the event normalization
path in event::Event and resolve::normalize_request_with_hint to include cargo
clippy --workspace --all-targets -- -D warnings, validate-change, and the full
binding matrix, in addition to the existing fmt/tests/docs steps. Make sure the
validation guidance explicitly reflects that changes under crates/core require
broader runtime and language-matrix coverage before merge.
🪄 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: f186e849-a2b8-4c8b-a415-14a52c21e936
📒 Files selected for processing (18)
crates/cli/src/adapters/claude_code.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/cursor.rscrates/cli/src/adapters/hermes.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.rscrates/cli/src/gateway.rscrates/cli/src/json_path.rscrates/cli/src/main.rscrates/cli/src/session.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/api/event.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/codec/resolve.rscrates/core/tests/unit/codec/resolve_tests.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (21)
- GitHub Check: Node.js / Test (windows-arm64)
- GitHub Check: Python / Test (windows-arm64)
- GitHub Check: Node.js / Test (windows-amd64)
- GitHub Check: Python / Test (macos-arm64)
- GitHub Check: Node.js / Test (linux-arm64)
- GitHub Check: Node.js / Test (macos-arm64)
- GitHub Check: Go / Test (windows-amd64)
- GitHub Check: Python / Test (linux-arm64)
- GitHub Check: Python / Test (windows-amd64)
- GitHub Check: Go / Test (windows-arm64)
- GitHub Check: Rust / Test (linux-arm64)
- GitHub Check: Rust / Test (macos-arm64)
- GitHub Check: Rust / Test (windows-arm64)
- GitHub Check: Go / Test (macos-arm64)
- GitHub Check: Rust / Test (windows-amd64)
- GitHub Check: Rust / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (linux-arm64)
- GitHub Check: WebAssembly / Test (linux-amd64)
- GitHub Check: WebAssembly / Test (windows-amd64)
- GitHub Check: WebAssembly / Test (windows-arm64)
- GitHub Check: WebAssembly / Test (macos-arm64)
⚠️ CI failures not shown inline (3)
GitHub Actions: Fern Docs / Preview docs: refactor: split CLI extraction strategies
Conclusion: failure
##[group]Run bail() {
�[36;1mbail() {�[0m
�[36;1m printf '::error::install-action: %s\n' "$*"�[0m
GitHub Actions: Fern Docs / 0_Preview docs.txt: refactor: split CLI extraction strategies
Conclusion: failure
##[group]Run bail() {
�[36;1mbail() {�[0m
�[36;1m printf '::error::install-action: %s\n' "$*"�[0m
GitHub Actions: Fern Docs / Preview docs: refactor: split CLI extraction strategies
Conclusion: failure
##[group]Run set -euo pipefail
�[36;1mset -euo pipefail�[0m
�[36;1mpr_number="${GITHUB_REF_NAME#pull-request/}"�[0m
�[36;1mpreview_id="pull-request-${pr_number}"�[0m
�[36;1mif OUTPUT="$("$GITHUB_WORKSPACE/source-checkout/node_modules/.bin/fern" generate --docs --preview --id "$preview_id" 2>&1)"; then�[0m
�[36;1m fern_exit=0�[0m
�[36;1melse�[0m
�[36;1m fern_exit=$?�[0m
�[36;1mfi�[0m
�[36;1mprintf '%s\n' "$OUTPUT"�[0m
�[36;1mif [[ "$fern_exit" -ne 0 ]]; then�[0m
�[36;1m echo "::error::Fern docs preview generation failed"�[0m
🧰 Additional context used
📓 Path-based instructions (17)
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.rscrates/core/src/api/runtime/state.rscrates/core/src/api/llm.rs
**/*.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/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/resolve.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/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/mod.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/src/api/event.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/resolve.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/src/api/event.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/resolve.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/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/cli/src/adapters/codex.rscrates/cli/src/adapters/claude_code.rscrates/cli/src/gateway.rscrates/cli/src/adapters/cursor.rscrates/cli/src/main.rscrates/core/src/api/runtime/state.rscrates/cli/src/json_path.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/cli/src/adapters/hermes.rscrates/cli/src/session.rscrates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rscrates/core/src/codec/resolve.rscrates/cli/src/adapters/mod.rscrates/cli/src/alignment/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/core/src/api/event.rscrates/core/src/api/runtime/state.rscrates/core/src/codec/anthropic.rscrates/core/src/api/llm.rscrates/core/tests/unit/codec/resolve_tests.rscrates/core/src/codec/resolve.rs
crates/core/src/api/runtime/state.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
crates/core/src/api/runtime/state.rs: Add registry fields asSortedRegistry<GuardrailEntry<T>>orSortedRegistry<Intercept<T>>toNemoRelayContextStateincrates/core/src/api/runtime/state.rs
Add chain execution helpers toNemoRelayContextStatefollowing the pattern of existing methods liketool_sanitize_request_chainortool_request_intercepts_chain
Files:
crates/core/src/api/runtime/state.rs
crates/core/src/api/{tool,llm}.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Wire the new middleware chain into the execute path in
crates/core/src/api/tool.rsorcrates/core/src/api/llm.rsat the appropriate pipeline stage
Files:
crates/core/src/api/llm.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/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}
⚙️ CodeRabbit configuration file
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.
Files:
crates/core/tests/unit/codec/resolve_tests.rscrates/cli/tests/coverage/adapters_tests.rscrates/cli/tests/coverage/alignment_tests.rs
🔇 Additional comments (16)
crates/core/src/codec/anthropic.rs (1)
43-51: LGTM!crates/core/src/codec/resolve.rs (1)
30-32: LGTM!Also applies to: 79-81
crates/core/src/api/llm.rs (1)
43-47: LGTM!Also applies to: 71-72
crates/core/src/api/runtime/state.rs (1)
419-421: LGTM!crates/cli/src/adapters/claude_code.rs (1)
7-9: LGTM!Also applies to: 23-23
crates/core/tests/unit/codec/resolve_tests.rs (1)
346-347: LGTM!crates/cli/src/adapters/codex.rs (1)
7-7: LGTM!Also applies to: 19-19
crates/cli/src/adapters/cursor.rs (1)
7-7: LGTM!Also applies to: 19-19
crates/cli/src/adapters/hermes.rs (1)
8-11: LGTM!Also applies to: 20-20, 68-68, 77-77, 95-109
crates/cli/tests/coverage/adapters_tests.rs (1)
238-301: LGTM!Also applies to: 303-346, 348-509, 982-1009
crates/cli/src/gateway.rs (1)
958-960: LGTM!crates/cli/src/alignment/mod.rs (1)
94-190: 📐 Maintainability & Code QualityRun the repo’s required Rust validation before merge.
The PR summary lists
cargo fmt --allandjust test-rust, but the repo guidance for Rust changes also requirescargo clippy --workspace --all-targets -- -D warningsanduv run pre-commit run --all-files. Please add those results before landing. As per coding guidelines, "If any Rust code changed, always runjust test-rust", "Runcargo clippy --workspace --all-targets -- -D warnings", and "Validate Rust code withuv run pre-commit run --all-filesto enforce cargo fmt formatting check, cargo clippy lints, and cargo deny auditing."Source: Coding guidelines
crates/cli/src/json_path.rs (1)
1-41: LGTM!crates/cli/src/main.rs (1)
15-15: LGTM!crates/cli/tests/coverage/alignment_tests.rs (1)
325-325: LGTM!Also applies to: 343-343, 363-363, 386-386, 409-409, 437-437, 468-472, 484-487, 521-532, 629-636
crates/cli/src/session.rs (1)
973-977: LGTM!Also applies to: 1037-1041, 1853-1853, 2044-2058
Thanks @willkill07 for the elaboration! PR updated with the refactor direction you pointed out. The shared best-effort chains are gone. Agent payloads now go through an |
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
…raction-strategies Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com> # Conflicts: # crates/cli/src/adapters/cursor.rs # crates/cli/src/adapters/mod.rs # crates/cli/tests/coverage/adapters_tests.rs
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
willkill07
left a comment
There was a problem hiding this comment.
I like the shape a lot more. Just some nits on how to meaningfully extract information based on Agent. If things are provider-specific, then we should be offloading that extraction based on the provider rather than generalizing on the harness.
Move the shared agent payload extraction behavior into default methods on AgentPayloadExtractor and reduce each harness impl to only the hooks where its hook payloads genuinely deviate. Collapse the duplicated session-id, event-name, and tool-call-id path constants into single canonical lists, keeping per-harness deviations (Codex RelayOnly + thread-spawn nickname + arguments-first, Hermes child-subagent-first, Claude tool_use_id-first) explicit and documented. Add a test that locks the Codex RelayOnly session-header policy so every per-harness deviation is directly covered. Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
@willkill07 Those paths are harness-specific: The latest commit extracted the canonical paths, and ensured each harness overrides only the hooks where it genuinely deviates, making the code easier to understand and maintain. |
|
/merge |
Overview
Establish explicit, shared extraction-strategy boundaries before code is moved onto them: provider schema extraction (codec-owned), agent payload extraction (harness-owned), and exporter projection. This is a refactor — runtime ownership, event shapes, and binding-facing behavior are unchanged. The only public surface added is the additive
normalize_request_with_hint.This branch has been merged with current
mainafter PR #333 removed Cursor support; the agent-side extraction split now covers the supported coding-agent integrations: Claude Code, Codex, and Hermes.Details
What changed
Provider schema extraction (
crates/core):SurfaceDescriptor→ProviderSurfaceDescriptor,REGISTRY→BUILTIN_PROVIDER_SURFACES, per-codecSURFACE_DESCRIPTOR→PROVIDER_SURFACE, and the detector fn aliases toRequestSurfaceDetector/ResponseSurfaceDetector. All remainpub(crate).LlmResponseCodec::decode_responseas the provider response-extraction interface (model name, finish reason, tool calls, usage, cost, provider-specific fields, replayable response data).normalize_request_with_hint(request, hint)(the existingnormalize_requestnow delegates withNone).EventNormalizationExtthreads the managed provider-route event name (e.g.anthropic.messages) as the codec hint, so an Anthropic Messages body without a top-levelsystemno longer misroutes to the OpenAI Chat codec. The Anthropic detector accepts both"anthropic"and"anthropic.messages"hints.Agent payload extraction (
crates/cli):crates/cli/src/json_path.rs, consumed by both adapter and alignment code (existing names preserved via re-export).AgentPayloadExtractorimplementations for Claude Code, Codex, and Hermes; event construction (common_*_event,classify) stays shared and takes&dyn AgentPayloadExtractor.ProviderRequestExtractorimplementations (OpenAI Responses / Chat Completions / Models, Anthropic Messages / Count-Tokens), selected by gateway route.unknown_tool, generic subagent ID,Value::Null) stay at the adapter/session boundary; extractors returnNonefor absent fields. Path/PII fields (cwd, transcript_path, project_dir, user email) are not promoted into shared metadata.Docs:
docs/about-nemo-relay/concepts/codecs.mdxdocumenting the provider / agent / exporter split and fallback semantics for missing, sparse, lossy, and summary-only payloads.Why
Multiple components pull structured information from heterogeneous agent and provider payloads. Defining the strategy interfaces (and separating agent-payload extraction from provider-schema extraction) up front lets later work migrate the duplicated, best-effort extraction chains onto shared seams without widening the public API.
How it was tested
Latest validation after merging current
main:cargo fmt --allcargo test -p nemo-relay-cli adapters::testsPYO3_PYTHON=/Users/yuchenz/Desktop/Work/Project/NeMo-Flow/.venv/bin/python cargo clippy --workspace --all-targets -- -D warningsjust test-rustgit diff --checkAdditional validation performed earlier on this branch:
uv run pre-commit run --all-files— SPDX/fmt/clippy/audit + public-docstring gate.Validation scope for review:
validate-changewas used to select the required matrix. Because this PR touchescrates/coreevent normalization (EventNormalizationExtandnormalize_request_with_hint), pre-merge verification should include the broader runtime/language matrix, not Rust-only coverage:cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust,just test-python,just test-node,just test-go, andjust test-wasm.just docsbefore merge. Binding behavior is expected to remain compatible because the core API change is additive, event shapes are unchanged, and renamed codec registry symbols remainpub(crate); the full binding matrix is still the required check set for thiscrates/corechange.Breaking changes
None from this PR.
normalize_request_with_hintis additive;normalize_requestkeeps its signature and behavior (delegates with no hint).Where should the reviewer start?
crates/cli/src/adapters/mod.rs(theAgentPayloadExtractorimplementations and the per-agent path tables), thencrates/cli/src/json_path.rsand the adapter coverage tests, thencrates/cli/src/alignment/mod.rs(ProviderRequestExtractorsplit), and finallycrates/core/src/codec/resolve.rs(descriptor rename + hint threading) withcrates/core/src/api/event.rsfor the hint wiring.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)