Skip to content

fix: preserve explicit errors in manual LLM completion - #1405

Merged
willkill07 merged 1 commit into
NVIDIA:mainfrom
tianx-dev:fix/manual-llm-call-errors
Oct 20, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:mainfrom
tianx-dev:fix/manual-llm-call-errors

Conversation

@tianx-dev

@tianx-dev tianx-dev commented Oct 20, 2026 •

Copy link
Copy Markdown

Overview

Manual LLM completion currently replaces an explicit otel.status_code: "ERROR" with "OK" and drops the failure description. A framework that owns provider execution can report a timeout through call_end() and still emit a successful end event.

Preserve an explicit "ERROR" in end-call metadata, including its description. Calls without that status keep the existing "OK" default. This uses the existing metadata parameter; public signatures and managed execution are unchanged.

  • 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

  • Add success and failure regression coverage in Rust, Python, Node.js, and Go.
  • Document manual failure reporting in the framework integration guide and API docstrings.
  • Confirmed the new Rust error regression fails before the fix and passes with it.

Local validation (repository-pinned toolchains):

  • just test-rust: 6,043 passed, one skipped.
  • just test-python: 1,018 package tests, 24 example tests, and 83 bridge tests passed.
  • just test-node: 499 package tests, 26 example tests, and five bridge tests passed.
  • just ci=true test-go: 423 passed.
  • uv run pre-commit run: all applicable staged hooks passed, including formatting, lint, type checks, and dependency audits.
  • NEMO_RELAY_DOCS_DEPS_READY=1 just docs: generated API references, Fern validation, and strict link checks passed.

Where should the reviewer start?

llm_call_end() in crates/core/src/api/llm.rs, then manual_llm_call_end_preserves_explicit_error_metadata in crates/core/tests/unit/llm_api_tests.rs.

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

Summary by CodeRabbit

  • New Features

    • Manual LLM call completion now consistently reports OK for successful calls and preserves ERROR status metadata for failures.
    • Failure details such as status descriptions, error types, and timeout information are retained across supported SDKs.
  • Documentation

    • Added guidance and examples for reporting failures during manual LLM calls, including supported metadata fields and error handling behavior.

@tianx-dev
tianx-dev requested review from a team as code owners October 20, 2026 03:40
@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:go PR changes/introduces Go code lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code lang:rust PR changes/introduces Rust code labels Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T03:43:53.621120Z b1ec034 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 20, 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: 173fdfec-ee06-4f3d-bacb-cb96066c13d2
📥 Commits

Reviewing files that changed from the base of the PR and between 8be3fa4 and b1ec034.

📒 Files selected for processing: 7
  • crates/core/src/api/llm.rs
  • crates/core/tests/unit/llm_api_tests.rs
  • crates/node/tests/llm_tests.mjs
  • docs/integrate-into-frameworks/wrap-llm-calls.mdx
  • go/nemo_relay/llm_test.go
  • python/nemo_relay/llm.py
  • python/tests/test_llm.py

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

📜 Recent review details
🧰 Additional context used
📚 Code guidelines: 7
.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
CONTRIBUTING.md — configured
.agents/skills/prepare-code-freeze/SKILL.md — configured
.agents/skills/add-binding-feature/SKILL.md — configured
.agents/skills/add-middleware/SKILL.md — configured
.agents/skills/draft-release-notes/SKILL.md — configured
📓 Path-based instructions: 16
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/integrate-into-frameworks/wrap-llm-calls.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:

  • crates/node/tests/llm_tests.mjs
  • python/tests/test_llm.py
  • crates/core/tests/unit/llm_api_tests.rs
  • go/nemo_relay/llm_test.go
Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.

⚙️ CodeRabbit configuration file

Files:

  • crates/core/tests/unit/llm_api_tests.rs
  • crates/core/src/api/llm.rs
Treat binding changes as public API changes.

⚙️ CodeRabbit configuration file

Files:

  • crates/node/tests/llm_tests.mjs
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/llm.py
Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.

⚙️ CodeRabbit configuration file

Files:

  • go/nemo_relay/llm_test.go
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/wrap-llm-calls.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/wrap-llm-calls.mdx
Applicability reference: AGENTS.md: # NeMo Relay Repository Guidance See `CONTRIBUTING.md` and `docs/contribute/testing-and-docs.mdx` for contributor details, and `.agents/skills/README.md` for the maintainer skill boundar...

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • python/nemo_relay/llm.py
  • python/tests/test_llm.py
  • crates/core/tests/unit/llm_api_tests.rs
  • go/nemo_relay/llm_test.go
  • crates/core/src/api/llm.rs
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/wrap-llm-calls.mdx
Applicability reference: AGENTS.md: # NeMo Relay Repository Guidance See `CONTRIBUTING.md` and `docs/contribute/testing-and-docs.mdx` for contributor details, and `.agents/skills/README.md` for the maintainer skill boundary.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • python/nemo_relay/llm.py
  • crates/node/tests/llm_tests.mjs
  • python/tests/test_llm.py
  • crates/core/tests/unit/llm_api_tests.rs
  • go/nemo_relay/llm_test.go
  • crates/core/src/api/llm.rs
Source excerpt: **Core Rust** Implement the behavior first in `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`.

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

Files:

  • crates/core/src/api/llm.rs
Source excerpt: [ ] Core function with doc comment in `crates/core/src/api/`

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

Files:

  • crates/core/src/api/llm.rs
Source excerpt: Add registration and deregistration APIs in `crates/core/src/api/`.

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

Files:

  • crates/core/src/api/llm.rs
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/wrap-llm-calls.mdx
Source excerpt: Update the relevant lifecycle owner to call the new chain method at the appropriate pipeline stage.

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

Files:

  • crates/core/src/api/llm.rs
🔇 Additional comments: 7
crates/core/src/api/llm.rs: 1

1209-1218: Handle the ERROR status check consistently with metadata_with_otel_status.

The ERROR branch returns metadata unchanged. In this branch, the supplied metadata is not normalized at all. This is the intended behavior, and build_llm_end_event receives the caller's fields. The default branch strips a stale otel.status_description, and the test at llm_api_tests.rs covers it.

I found no defect. The status check is a strict string comparison, and a non-string or lowercase "error" value falls to the OK default. This matches the documented contract. Both branches have Rust tests, and the other bindings forward metadata unchanged.

crates/core/tests/unit/llm_api_tests.rs: 1

2468-2549: LGTM!

python/nemo_relay/llm.py: 1

182-185: LGTM!

python/tests/test_llm.py: 1

69-86: LGTM!

crates/node/tests/llm_tests.mjs: 1

116-140: LGTM!

go/nemo_relay/llm_test.go: 1

38-77: LGTM!

docs/integrate-into-frameworks/wrap-llm-calls.mdx: 1

41-72: LGTM!

Walkthrough

Manual LLM completion now preserves caller-supplied ERROR status metadata. Without that status, the end event uses OK. Tests cover Rust, Node.js, Go, and Python behavior, and documentation describes the metadata contract.

Changes

Manual LLM completion status

Layer / File(s) Summary
Core status handling
crates/core/src/api/llm.rs, crates/core/tests/unit/llm_api_tests.rs
llm_call_end preserves metadata when otel.status_code is ERROR. Otherwise, it sets the status to OK. Rust tests cover both outcomes, including stale status-description removal on successful completion.
Binding contract and validation
python/nemo_relay/llm.py, python/tests/test_llm.py, crates/node/tests/llm_tests.mjs, go/nemo_relay/llm_test.go, docs/integrate-into-frameworks/wrap-llm-calls.mdx
Python documentation and framework guidance describe the status metadata contract. Python, Node.js, and Go tests check status values and preservation of supplied error metadata.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b1ec0

The change appears ready to merge after normal checks; no actionable failure is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 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
Description check Passed The description includes all required sections, completed contribution and duplicate-work checks, change details, reviewer starting points, validation results, and a valid related issue entry.
Title check Passed The title follows Conventional Commits format with the lowercase type fix, uses a concise imperative summary, is 54 characters long, and has no trailing period.
Linked Issues check Passed Issue #1404 requires manual LLM completion to preserve explicit otel.status_code: "ERROR" and its failure metadata, while retaining the "OK" default otherwise. llm_call_end now preserves metadat…
Out of Scope Changes check Passed All changed files support issue #1404. The Rust implementation fixes status handling. The Rust, Python, Node.js, and Go tests provide regression coverage. The docstring and framework guide document th…
Full details: Linked Issues check

Explanation

Issue #1404 requires manual LLM completion to preserve explicit otel.status_code: "ERROR" and its failure metadata, while retaining the "OK" default otherwise. llm_call_end now preserves metadata when the status is exactly "ERROR" and otherwise applies the existing OK normalization. Rust tests cover both paths. Python, Node.js, and Go tests cover the binding behavior. API documentation and the framework guide describe the failure contract.

Full details: Out of Scope Changes check

Explanation

All changed files support issue #1404. The Rust implementation fixes status handling. The Rust, Python, Node.js, and Go tests provide regression coverage. The docstring and framework guide document the manual failure-reporting contract. No unrelated production behavior or unrelated tests appear in the pull request diff.

Full details: Docstring Coverage

Explanation

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

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

@willkill07 willkill07 self-assigned this Oct 20, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 20, 2026
@willkill07

Copy link
Copy Markdown
Member

/ok to test b1ec034

@github-actions

Copy link
Copy Markdown

@willkill07 willkill07 modified the milestones: 0.10, 0.11 Oct 20, 2026
@willkill07
willkill07 merged commit 938562e into NVIDIA:main Oct 20, 2026
86 checks passed

This branch was previously deployed

1 inactive deployment
fern — b1ec034e Deployed Oct 20, 2026 by copy-pr-bot[bot] via Preview docs #6024
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:go PR changes/introduces Go code lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Manual LLM completion overwrites an explicit error status

2 participants