Skip to content

fix: restrict typed reconstruction to registered types - #1304

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1031-release-0.10
Oct 13, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1031-release-0.10

Conversation

@willkill07

@willkill07 willkill07 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Overview

Restrict Python tagged-value reconstruction to types registered in the current process, and keep LangChain/LangGraph tool arguments as plain JSON. Registered typed values and framework tool results continue to round-trip without public API signature changes.

  • 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

  • Remove the import-path fallback from BestEffortAnyCodec; dataclass and Pydantic tags resolve only through the runtime type registry populated by to_json().
  • Use JsonPassthrough for both sync and async LangChain/LangGraph tool arguments, while preserving the existing result codecs.
  • Cover both tag families, import side effects, constructor/validator calls, registered round trips, and both framework execution boundaries.
  • Document that unregistered tags remain dictionaries. Stored or cross-process payloads should use an explicit DataclassCodec or PydanticCodec to select their type.

No public API signatures change. The behavior change is that unregistered tagged payloads no longer reconstruct Python objects, and tagged integration arguments remain JSON even when their runtime type token is registered.

Validation passed: 65 focused checks; just test-python (83 native binding tests, 785 Python tests, and 24 example tests); just test-python-langchain (134 integration tests); and all repository pre-commit hooks. Rust, Node.js, and Go surfaces are unchanged, so their standalone suites were not run.

Where should the reviewer start?

Start with python/nemo_relay/typed.py, then review the argument codecs in python/nemo_relay/integrations/langchain/middleware.py and python/nemo_relay/integrations/langgraph/tool_node.py. The regressions in python/tests/test_typed.py and the corresponding integration test files exercise the changed behavior.

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

Summary by CodeRabbit

  • Bug Fixes

    • Tool arguments in LangChain and LangGraph integrations now pass through as JSON without reconstructing dataclass or Pydantic types, while result handling remains unchanged.
    • Type tags reconstruct only types registered in the current process; unregistered tags remain JSON dictionaries.
  • Documentation

    • Clarified that stored or cross-process payloads require explicit codec selection, and that JSON passthrough is recommended for model-controlled tool arguments.

@willkill07
willkill07 requested review from a team as code owners October 13, 2026 13:02
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:python PR changes/introduces Python code labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: aec86115-7d79-48b2-906e-2441df893dc7
📥 Commits

Reviewing files that changed from the base of the PR and between 2747f4a and 94a5824.

📒 Files selected for processing (7)
  • docs/integrate-into-frameworks/using-codecs.mdx
  • python/nemo_relay/integrations/langchain/middleware.py
  • python/nemo_relay/integrations/langgraph/tool_node.py
  • python/nemo_relay/typed.py
  • python/tests/integrations/langchain_tests/test_middleware.py
  • python/tests/integrations/langgraph_tests/test_langgraph_integration.py
  • python/tests/test_typed.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Python / Test (windows-arm64)
  • GitHub Check: Python / Test (windows-amd64)
  • GitHub Check: Python / Test (linux-amd64)
  • GitHub Check: Python / Package (windows-arm64)
  • GitHub Check: Python / Test (macos-arm64)
  • GitHub Check: Python / Test (linux-arm64)
  • GitHub Check: Python / Package (linux-arm64)
  • GitHub Check: Python / Package (linux-musl-arm64)
  • GitHub Check: Python / Package (linux-musl-amd64)
  • GitHub Check: Python / Package (linux-amd64)
  • GitHub Check: Python / Package (windows-amd64)
  • GitHub Check: Python / Package (macos-arm64)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
🧰 Additional context used
📚 Code guidelines (5)
.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
.agents/skills/prepare-code-freeze/SKILL.md — configured
CONTRIBUTING.md — configured
.agents/skills/draft-release-notes/SKILL.md — configured
📓 Path-based instructions (9)
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/integrate-into-frameworks/using-codecs.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • python/tests/integrations/langgraph_tests/test_langgraph_integration.py
  • python/tests/integrations/langchain_tests/test_middleware.py
  • python/tests/test_typed.py
Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.

⚙️ CodeRabbit configuration file

Files:

  • python/nemo_relay/integrations/langgraph/tool_node.py
  • python/nemo_relay/typed.py
  • python/nemo_relay/integrations/langchain/middleware.py
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/integrate-into-frameworks/using-codecs.mdx
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/integrate-into-frameworks/using-codecs.mdx
Source excerpt: Search documentation source for references to the old version and update current-version install commands, package examples, and configuration examples to `` where appropriate: Review matches before changing th...

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

Files:

  • docs/integrate-into-frameworks/using-codecs.mdx
Source excerpt: Use the naming conventions appropriate to each language: Rust `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase`, Node.js `camelCase`, Python `snake_case`.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • python/tests/integrations/langgraph_tests/test_langgraph_integration.py
  • python/nemo_relay/integrations/langgraph/tool_node.py
  • python/tests/integrations/langchain_tests/test_middleware.py
  • python/nemo_relay/typed.py
  • python/nemo_relay/integrations/langchain/middleware.py
  • python/tests/test_typed.py
Source excerpt: Preserve MDX front matter and the JSX SPDX comment.

📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/SKILL.md)

Files:

  • docs/integrate-into-frameworks/using-codecs.mdx
Source excerpt: **Linting**: [Ruff](https://docs.astral.sh/ruff/) with rule sets `E`, `F`, `W`, `I` Source excerpt: **Formatting**: Ruff formatter (line length 120, double quotes) Source excerpt: **Type checking**: [ty](https://github.com/a...

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • python/tests/integrations/langgraph_tests/test_langgraph_integration.py
  • python/nemo_relay/integrations/langgraph/tool_node.py
  • python/tests/integrations/langchain_tests/test_middleware.py
  • python/nemo_relay/typed.py
  • python/nemo_relay/integrations/langchain/middleware.py
  • python/tests/test_typed.py
🔇 Additional comments (8)
python/nemo_relay/typed.py (2)

282-284: LGTM!

346-346: LGTM!

python/tests/test_typed.py (1)

863-887: LGTM!

Also applies to: 891-891, 899-899, 907-907

docs/integrate-into-frameworks/using-codecs.mdx (1)

109-112: LGTM!

python/nemo_relay/integrations/langchain/middleware.py (1)

160-160: LGTM!

Also applies to: 200-200

python/nemo_relay/integrations/langgraph/tool_node.py (1)

110-110: LGTM!

Also applies to: 155-155

python/tests/integrations/langchain_tests/test_middleware.py (1)

1108-1108: LGTM!

Also applies to: 1136-1136, 1387-1440

python/tests/integrations/langgraph_tests/test_langgraph_integration.py (1)

869-921: LGTM!

Walkthrough

Tagged Python payloads now reconstruct only types registered in the current process. LangChain and LangGraph tool integrations use JSON passthrough for arguments while keeping best-effort encoding for results.

Changes

Python codec behavior

Layer / File(s) Summary
Registered-type decoding
python/nemo_relay/typed.py, python/tests/test_typed.py, docs/integrate-into-frameworks/using-codecs.mdx
Tagged dataclass and Pydantic payloads reconstruct only registered runtime types. Unregistered tags remain dictionaries. Tests cover unregistered tags, and the guide describes codec selection for stored or cross-process payloads.
Framework tool argument encoding
python/nemo_relay/integrations/langchain/middleware.py, python/nemo_relay/integrations/langgraph/tool_node.py, python/tests/integrations/langchain_tests/test_middleware.py, python/tests/integrations/langgraph_tests/test_langgraph_integration.py
Both integrations use JsonPassthrough for tool arguments. Tests verify tagged arguments reach handlers unchanged without model validation. Result encoding remains unchanged.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 94a58

No actionable issue identified; the PR is mergeable after normal checks.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 6 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title follows Conventional Commits format with the allowed lowercase type fix. It clearly summarizes the main change, is imperative, is 54 characters long, and has no trailing period.
Description check Passed The description includes all required sections, completed contribution and duplicate-work confirmations, clear implementation details, reviewer guidance, validation results, and a valid Fixes issue …
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown

@willkill07 willkill07 self-assigned this Oct 13, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 13, 2026
@willkill07
willkill07 merged commit dd66d8f into NVIDIA:release/0.10 Oct 13, 2026
47 checks passed
willkill07 added a commit that referenced this pull request Oct 14, 2026
#### Overview

Add 0.10.1 release notes covering the fifteen PRs merged into
`release/0.10` since `0.10.0`, plus the anticipated merge of #1317, with
matching patch-upgrade guidance. Preserve the 0.10.0 notes and follow
the NVIDIA documentation style guide.

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

#### Details

- Cover daemon-worker LLM middleware (#1281), the YAML dependency update
(#1282), hook timeout and failure-policy fixes (#1288, #1289, #1290),
and request-edit preservation (#1296).
- Cover Anthropic streaming storage (#1303), Python typed reconstruction
(#1304), Go native handle lifetimes (#1302), authenticated Pi hooks and
session ownership (#1306), dynamic plugin trust failures (#1305), and
verified native plugin loading (#1307).
- Cover Pi named-upstream restrictions (#1314), LangChain tool-schema
edits (#1316), and the configurable ChatGPT Codex endpoint (#1319).
- Assume #1317 will merge: document plugin HTTP error helpers and
prefixes, preservation of remote Guardrails and forwarded hook HTTP
error statuses, verified reporting identities, and streaming limits.
Verified against its current head
`b61bb7da0bc6de7b7d5d27a569981867b7b2fcb9`; its implementation is not
merged into this branch.
- Add upgrade guidance for hook credentials and registration, generated
hooks, daemon response behavior, request edits, Pi extensions and
private provider endpoints, native plugin dependencies, stored Python
typed values, ChatGPT endpoints, and HTTP error handling.
- Keep PR references and counts out of user-facing release notes.
Preserve the prior CodeRabbit corrections for MCP route registration,
forwarded-stream observation limits, sanitizer-only behavior, and 0.10.1
installation pins.
- Merge the latest `release/0.10` into the PR branch. Distinguish
personal hook refresh commands from administrator-managed daemon
bundles.

Validation: `just docs`, `uv run pre-commit run`, and `git diff --cached
--check` passed. Fern skipped the published redirect-history check
because FDR returned HTTP 403. Verified the merged release range against
source and public documentation, and the assumed #1317 behavior against
its current PR source and docs.
Language test suites were not run because the PR diff only updates
documentation prose and installation version pins. Package installation
commands, live daemon upgrades, plugin activations, and hook refreshes
were not executed. Validation runs on the current release branch; #1317
remains an explicit release-content assumption.

#### Where should the reviewer start?

Start with `Release 0.10.1` in
`docs/about-nemo-relay/release-notes/index.mdx`, then review `Update
from NeMo Relay 0.10.0 to 0.10.1` in
`docs/reference/migration-guides.mdx`. Review the new Pi endpoint,
ChatGPT endpoint, LangChain tool-edit, and HTTP error guidance,
including the #1317 merge assumption. Check matching version pins in
`docs/getting-started/installation.mdx`.

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

- Relates to: none


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added NeMo Relay 0.10.0 and 0.10.1 release notes, including feature
highlights, compatibility updates, fixes, and known issues.
* Expanded migration guidance with upgrade steps and details on hook
credentials and delivery, daemon-worker middleware behavior, request
editing, plugin requirements, and Python value handling.
* Updated installation examples across supported platforms, packages,
and integrations to reference version 0.10.1.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>
willkill07 added a commit that referenced this pull request Oct 15, 2026
#### Overview

Direct users of `BestEffortAnyCodec` could supply a copied runtime type
token and modified data to run a registered class's constructor or
validators. Tagged dataclass and Pydantic values now remain JSON
dictionaries by default. Callers must list the classes they want to
restore in `allowed_types`.

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

#### Details

- Replace the process-wide registry with an explicit list of classes for
each codec. Encoding never adds classes to this list.
- Resolve tags only against supplied class objects. Ignore old runtime
type tokens. Keep pickle decoding restricted to builtin containers.
- Allow known framework result types in LangChain and LangGraph. Use the
request's declared schemas for LangChain structured responses. This
includes raw unions and `AutoStrategy` unions. Keep tool arguments as
plain JSON.
- Cover modified data, copied tokens, isolation between codecs, and
structured-response schemas. Update the usage guide, migration guide,
and API docstrings.

**Breaking change:** `BestEffortAnyCodec()` no longer restores dataclass
or Pydantic objects by default. Use
`BestEffortAnyCodec(allowed_types=[SearchArgs, SearchResult])` for typed
round trips. Allowed constructors and validators still run on input
data.

Validation passed:

- `just test-python`: 83 native binding tests, 1,002 Python tests, and
24 example tests.
- `just test-python-langchain`: 182 integration tests.
- `just docs`: local checks passed. Published-redirect verification was
unavailable because FDR returned HTTP 403.
- Repository pre-commit hooks passed on staged changes.
- The documented allowlist example ran successfully.

Rust, Node.js, and Go APIs are unchanged, so their standalone suites
were not run.

#### Where should the reviewer start?

Start with `BestEffortAnyCodec` in `python/nemo_relay/typed.py` and the
security cases in `python/tests/test_typed.py`. Then review the explicit
result types in the LangChain and LangGraph codecs and the
declared-schema tests in
`python/tests/integrations/langchain_tests/test_middleware.py`.

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

- Closes [RELAY-1071](https://linear.app/nvidia/issue/RELAY-1071).
- Closes [RELAY-1031](https://linear.app/nvidia/issue/RELAY-1031). This
adds hardening to the original fix in #1304. RELAY-1031 is already
marked Done.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Python object decoding can restore tagged dataclass and Pydantic
values when their exact classes are explicitly allowed; other values
remain dictionaries. Restored values are constructed or validated by
their classes.
* LangChain and LangGraph integrations support decoding known
structured-response types and tool results.
* **Documentation**
* Guidance covers type allowlists, JSON tool arguments, schema-specific
codecs, and decoding data across processes.
* **Security**
* Decoding does not import modules. Pickle decoding remains limited to
supported built-in containers, regardless of the allowlist. Legacy
runtime-type tokens do not enable restoration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>
@willkill07
willkill07 deleted the fix/relay-1031-release-0.10 branch October 30, 2026 14:47

This branch was previously deployed

1 inactive deployment
fern — 94a58240 Deployed Oct 13, 2026 by willkill07 via Clean up docs preview #5648
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:python PR changes/introduces Python code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants