Skip to content

refactor: share agent and provider extraction strategies#318

Merged
rapids-bot[bot] merged 20 commits into
NVIDIA:mainfrom
yczhang-nv:refactor/shared-extraction-strategies
Jul 1, 2026
Merged

refactor: share agent and provider extraction strategies#318
rapids-bot[bot] merged 20 commits into
NVIDIA:mainfrom
yczhang-nv:refactor/shared-extraction-strategies

Conversation

@yczhang-nv

@yczhang-nv yczhang-nv commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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 main after PR #333 removed Cursor support; the agent-side extraction split now covers the supported coding-agent integrations: Claude Code, Codex, and Hermes.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

What changed

Provider schema extraction (crates/core):

  • Renamed the internal codec registry surface to provider-extraction names: SurfaceDescriptorProviderSurfaceDescriptor, REGISTRYBUILTIN_PROVIDER_SURFACES, per-codec SURFACE_DESCRIPTORPROVIDER_SURFACE, and the detector fn aliases to RequestSurfaceDetector / ResponseSurfaceDetector. All remain pub(crate).
  • Documented LlmResponseCodec::decode_response as the provider response-extraction interface (model name, finish reason, tool calls, usage, cost, provider-specific fields, replayable response data).
  • Added hint-aware request normalization: normalize_request_with_hint(request, hint) (the existing normalize_request now delegates with None). EventNormalizationExt threads the managed provider-route event name (e.g. anthropic.messages) as the codec hint, so an Anthropic Messages body without a top-level system no longer misroutes to the OpenAI Chat codec. The Anthropic detector accepts both "anthropic" and "anthropic.messages" hints.

Agent payload extraction (crates/cli):

  • Added shared low-level JSON-path primitives in crates/cli/src/json_path.rs, consumed by both adapter and alignment code (existing names preserved via re-export).
  • Split agent payload extraction into per-host AgentPayloadExtractor implementations for Claude Code, Codex, and Hermes; event construction (common_*_event, classify) stays shared and takes &dyn AgentPayloadExtractor.
  • Split provider request extraction into per-route ProviderRequestExtractor implementations (OpenAI Responses / Chat Completions / Models, Anthropic Messages / Count-Tokens), selected by gateway route.
  • Compatibility fallbacks (synthetic session IDs, synthetic tool-call IDs, unknown_tool, generic subagent ID, Value::Null) stay at the adapter/session boundary; extractors return None for absent fields. Path/PII fields (cwd, transcript_path, project_dir, user email) are not promoted into shared metadata.

Docs:

  • New "Extraction Strategy Boundaries" section in docs/about-nemo-relay/concepts/codecs.mdx documenting 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 --all
  • cargo test -p nemo-relay-cli adapters::tests
  • PYO3_PYTHON=/Users/yuchenz/Desktop/Work/Project/NeMo-Flow/.venv/bin/python cargo clippy --workspace --all-targets -- -D warnings
  • just test-rust
  • git diff --check

Additional 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-change was used to select the required matrix. Because this PR touches crates/core event normalization (EventNormalizationExt and normalize_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, and just test-wasm.
  • Docs changes should also be covered by just docs before merge. Binding behavior is expected to remain compatible because the core API change is additive, event shapes are unchanged, and renamed codec registry symbols remain pub(crate); the full binding matrix is still the required check set for this crates/core change.

Breaking changes

None from this PR. normalize_request_with_hint is additive; normalize_request keeps its signature and behavior (delegates with no hint).

Where should the reviewer start?

crates/cli/src/adapters/mod.rs (the AgentPayloadExtractor implementations and the per-agent path tables), then crates/cli/src/json_path.rs and the adapter coverage tests, then crates/cli/src/alignment/mod.rs (ProviderRequestExtractor split), and finally crates/core/src/codec/resolve.rs (descriptor rename + hint threading) with crates/core/src/api/event.rs for the hint wiring.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

@yczhang-nv yczhang-nv self-assigned this Jun 26, 2026
@yczhang-nv yczhang-nv requested review from a team and lvojtku as code owners June 26, 2026 22:23
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The 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.

Changes

Descriptor-driven extraction and normalization

Layer / File(s) Summary
Provider surface registry and dispatch
crates/core/src/codec/*, crates/core/src/codec/resolve.rs, crates/core/tests/unit/codec/resolve_tests.rs
resolve.rs now selects request/response codecs from descriptor predicates, per-codec modules export PROVIDER_SURFACE, and tests cover descriptor priority and Anthropic hint-based decoding.
Event-name hint normalization
crates/core/src/api/event.rs, crates/core/src/api/llm.rs, crates/core/src/api/runtime/state.rs, crates/core/tests/unit/types_tests.rs
normalized_llm_request now passes the event name as a provider hint, and the API docs and unit test reflect gateway-managed route names and Anthropic-specific request decoding from that hint.
Shared agent payload extraction
crates/cli/src/adapters/mod.rs, crates/cli/src/adapters/*.rs, crates/cli/tests/coverage/adapters_tests.rs
AgentPayloadExtractor, ExtractedLlmHint, and ExtractedToolCall centralize session, event, metadata, subagent, hint, and tool-call extraction, with coverage for default and populated payloads plus metadata placement changes.
Provider request extraction
crates/cli/src/alignment/mod.rs, crates/cli/src/session.rs, crates/cli/tests/coverage/alignment_tests.rs, crates/cli/src/json_path.rs, crates/cli/src/main.rs
ProviderRequestExtractor centralizes affinity-key normalization and Claude-only gateway turn input construction, request affinity tracking becomes provider-scoped, and JSON path helpers are shared through a new module.
Extraction boundary docs
docs/about-nemo-relay/concepts/codecs.mdx
The concepts page adds sections for provider schema extraction, agent payload extraction, and exporter projection.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Uses a valid Conventional Commits refactor title and accurately summarizes the extraction-strategy refactor.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description includes the required Overview, Details, reviewer start, and issue sections, and the checklist is completed; only the issue field is non-critically unfilled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:L PR is large Improvement improvement to existing functionality lang:rust PR changes/introduces Rust code labels Jun 26, 2026
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
@github-actions

Copy link
Copy Markdown

@yczhang-nv yczhang-nv force-pushed the refactor/shared-extraction-strategies branch from f62642e to 655f4c2 Compare June 26, 2026 22:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b9a530 and f62642e.

📒 Files selected for processing (8)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • docs/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_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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.toml and their actual usage across the codebase

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/src/adapters/mod.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/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.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/src/adapters/mod.rs
crates/core/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/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.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • docs/about-nemo-relay/concepts/codecs.mdx
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/alignment/mod.rs
  • crates/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.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/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. Use just docs for docs-site builds and just docs-linkcheck when links changed
Run docs site build with just 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-linkcheck when 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 docs or ./scripts/build-docs.sh html to 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 Quality

Add the required core-runtime validation before merge.

This changes crates/core codec dispatch, but the PR validation list still omits cargo clippy --workspace --all-targets -- -D warnings, the full binding test matrix, and validate-change. Please include those runs so the shared runtime contract is exercised outside the Rust-only path.

As per coding guidelines, "If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly" and "If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation."

Also applies to: 92-103

Source: Coding guidelines

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b9a530 and f62642e.

📒 Files selected for processing (8)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • docs/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 Quality

Add the required core-runtime validation before merge.

This changes crates/core codec dispatch, but the PR validation list still omits cargo clippy --workspace --all-targets -- -D warnings, the full binding test matrix, and validate-change. Please include those runs so the shared runtime contract is exercised outside the Rust-only path.

As per coding guidelines, "If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly" and "If the change touched crates/core or shared runtime semantics, also use validate-change for 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 -C2

Repository: 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' || true

Repository: NVIDIA/NeMo-Relay

Length of output: 50374


user_email should 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.rs

Repository: 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.rs

Repository: NVIDIA/NeMo-Relay

Length of output: 32368


Anthropic detector needs a discriminator beyond system. Valid Anthropic Messages requests can omit top-level system, but this predicate falls through to OpenAIChat for that shape, so resolve_request_surface() rejects raw Anthropic requests and normalize_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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f62642e and 655f4c2.

📒 Files selected for processing (8)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • docs/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_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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.toml and their actual usage across the codebase

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/cli/src/adapters/mod.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/cli/src/adapters/mod.rs
crates/core/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/src/codec/openai_chat.rs
  • crates/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.rs
  • crates/core/src/codec/openai_responses.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/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 Quality

Please add the required crates/core validation before merge.

The PR summary lists cargo fmt --all, targeted Rust tests, just test-rust, and just docs, but the repo guidance for crates/core Rust changes also expects cargo 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, "If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly."

Source: Coding guidelines

Comment thread crates/cli/src/adapters/mod.rs Outdated
Comment thread crates/core/src/codec/resolve.rs
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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 655f4c2 and ad1fbb8.

📒 Files selected for processing (6)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • docs/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_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • 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.toml and their actual usage across the codebase

Files:

  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/src/alignment/mod.rs
  • crates/core/src/codec/resolve.rs
  • docs/about-nemo-relay/concepts/codecs.mdx
  • crates/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.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/resolve.rs
crates/core/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/resolve.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/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.rs
  • crates/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. Use just docs for docs-site builds and just docs-linkcheck when links changed
Run docs site build with just 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-linkcheck when 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 docs or ./scripts/build-docs.sh html to 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 Quality

Run the required Rust lint pass.

The PR validation list covers cargo fmt --all and just test-rust, but it omits cargo 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 run cargo 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 & Availability

Confirm normalize_request threads the provider hint, not just detection.

detect_request_surface deliberately delegates with None, but the prior review flagged that normalize_request also hardcodes None, so the event.rs fallback path normalizes messages-only Anthropic requests through the OpenAI Chat descriptor. The new request_descriptor helper and the test at resolve_tests.rs:297-300 confirm that a None hint resolves messages-only payloads to OpenAIChat — 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!

Comment thread crates/cli/src/adapters/mod.rs Outdated
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad1fbb8 and 20816ae.

📒 Files selected for processing (7)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/api/event.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/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 as crates/core/src/api/runtime/, crates/core/src/codec/, or crates/core/src/json.rs

Files:

  • crates/core/src/api/event.rs
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/core/src/api/event.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • 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.toml and their actual usage across the codebase

Files:

  • crates/core/src/api/event.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/core/src/api/event.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/core/src/api/event.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/core/src/codec/resolve.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/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.rs
  • crates/core/tests/unit/types_tests.rs
  • crates/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_hint is now the hint-aware entry point and event.rs calls it, so the messages-only Anthropic fallback path is no longer forced through OpenAI Chat when a hint is present. normalize_request preserving None keeps 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 Correctness

Need the LLM handle construction and the provider-hint matcher to decide whether the name is contractual or just a caller-controlled label.

Comment thread crates/cli/tests/coverage/adapters_tests.rs
Signed-off-by: Yuchen Zhang <yuchenz@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Exercise the populated event builders, not just the extractor.

This test proves BUILTIN_AGENT_PAYLOAD_EXTRACTOR, but the PR also rewired common_llm_hint_event and common_tool_event to consume that data. A field-mapping regression there would still pass. Add assertions on the emitted LlmHintEvent/ToolEvent for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 20816ae and 720e19e.

📒 Files selected for processing (9)
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/src/gateway.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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 as crates/core/src/api/runtime/, crates/core/src/codec/, or crates/core/src/json.rs

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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 as SortedRegistry<GuardrailEntry<T>> or SortedRegistry<Intercept<T>> to NemoRelayContextState in crates/core/src/api/runtime/state.rs
Add chain execution helpers to NemoRelayContextState following the pattern of existing methods like tool_sanitize_request_chain or tool_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.toml and their actual usage across the codebase

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/core/src/codec/resolve.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/core/src/codec/resolve.rs
crates/core/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/core/src/api/event.rs
  • crates/cli/src/gateway.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/codec/anthropic.rs
  • crates/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.rs or crates/core/src/api/llm.rs at 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 Quality

Add the missing Rust validation steps before merge.

The PR validation list includes cargo fmt --all and just test-rust, but it still needs cargo clippy --workspace --all-targets -- -D warnings and uv run pre-commit run --all-files for a Rust change in this repo. Please include those results as well. As per coding guidelines, "Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings" and "Validate Rust code with uv 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 Quality

Please add the required repo validation for this crates/core change.

The PR summary only lists targeted Rust tests, cargo fmt --all, just test-rust, and just docs, but the repo guidance for crates/core changes is stricter: run the full binding matrix plus the required Rust lint/pre-commit checks before merge. Please attach results for cargo 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

@github-actions github-actions Bot added size:XL PR is extra large and removed size:L PR is large labels Jun 30, 2026
@yczhang-nv

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yczhang-nv yczhang-nv changed the title refactor: define shared agent-payload and provider-schema extraction strategies refactor: share agent and provider extraction strategies Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20816ae and 72d90ad.

📒 Files selected for processing (18)
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/json_path.rs
  • crates/cli/src/main.rs
  • crates/cli/src/session.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/api/event.rs
  • crates/core/src/api/llm.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/codec/resolve.rs
  • crates/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

View job details

##[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

View job details

##[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

View job details

##[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 as crates/core/src/api/runtime/, crates/core/src/codec/, or crates/core/src/json.rs

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/api/llm.rs
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.rs: If any Rust code changed, always run just test-rust
If any Rust code changed, also run cargo fmt --all
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to 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 with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/core/src/api/event.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.toml and their actual usage across the codebase

Files:

  • crates/core/src/api/event.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
{crates/core,crates/adaptive}/**/*

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/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.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/cli/src/alignment/mod.rs
crates/core/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

crates/core/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in core runtime paths. Keep errors explicit and binding-appropriate at the wrapper layer.

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/core/src/codec/resolve.rs
crates/{core,adaptive}/**

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/core/src/api/event.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/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.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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 prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/core/src/api/event.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/core/src/api/event.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. 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.rs
  • crates/cli/src/adapters/codex.rs
  • crates/cli/src/adapters/claude_code.rs
  • crates/cli/src/gateway.rs
  • crates/cli/src/adapters/cursor.rs
  • crates/cli/src/main.rs
  • crates/core/src/api/runtime/state.rs
  • crates/cli/src/json_path.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/cli/src/adapters/hermes.rs
  • crates/cli/src/session.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/cli/tests/coverage/alignment_tests.rs
  • crates/core/src/codec/resolve.rs
  • crates/cli/src/adapters/mod.rs
  • crates/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.rs
  • crates/core/src/api/runtime/state.rs
  • crates/core/src/codec/anthropic.rs
  • crates/core/src/api/llm.rs
  • crates/core/tests/unit/codec/resolve_tests.rs
  • crates/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 as SortedRegistry<GuardrailEntry<T>> or SortedRegistry<Intercept<T>> to NemoRelayContextState in crates/core/src/api/runtime/state.rs
Add chain execution helpers to NemoRelayContextState following the pattern of existing methods like tool_sanitize_request_chain or tool_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.rs or crates/core/src/api/llm.rs at 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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/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.rs
  • crates/cli/tests/coverage/adapters_tests.rs
  • crates/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 Quality

Run the repo’s required Rust validation before merge.

The PR summary lists cargo fmt --all and just test-rust, but the repo guidance for Rust changes also requires cargo clippy --workspace --all-targets -- -D warnings and uv run pre-commit run --all-files. Please add those results before landing. As per coding guidelines, "If any Rust code changed, always run just test-rust", "Run cargo clippy --workspace --all-targets -- -D warnings", and "Validate Rust code with uv run pre-commit run --all-files to 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

Comment thread crates/cli/src/adapters/mod.rs
Comment thread crates/cli/src/alignment/mod.rs
Comment thread crates/core/src/api/event.rs
@github-actions

Copy link
Copy Markdown

@yczhang-nv

Copy link
Copy Markdown
Contributor Author

We need to lean more into Traits which model expected behavior/APIs. And have implementations of those Traits be dependent on either (1) the agent harness supported (2) the LLM provider being used and/or (3) a combination of both.

We should avoid these best-effort chains for information extraction.

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 AgentPayloadExtractor trait with one implementation per harness. And the provider side has a ProviderRequestExtractor trait with per-route impls (OpenAI Responses/Chat, Anthropic Messages/CountTokens) selected by GatewayRouteKind. Each impl owns its own schema paths instead of a single shared chain.

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 willkill07 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/cli/src/adapters/mod.rs Outdated
Comment thread crates/cli/src/adapters/mod.rs Outdated
Comment thread crates/cli/src/adapters/mod.rs
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>
@yczhang-nv

Copy link
Copy Markdown
Contributor Author

If things are provider-specific, then we should be offloading that extraction based on the provider rather than generalizing on the harness.

@willkill07 Those paths are harness-specific: session-id and event-name are canonical (same across harnesses, only the header policy differs); subagent-id and tool-call/arg precedence genuinely vary by harness.

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.

@yczhang-nv

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot rapids-bot Bot merged commit 5e25878 into NVIDIA:main Jul 1, 2026
72 of 73 checks passed
@yczhang-nv yczhang-nv deleted the refactor/shared-extraction-strategies branch July 1, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement improvement to existing functionality lang:rust PR changes/introduces Rust code size:XL PR is extra large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants