Skip to content

fix(eval): report unparseable tunable RAG judge replies as errors - #2641

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:developfrom
YusefSyed:fix/tunable-rag-judge-parse-error
Nov 23, 2026
Merged

rapids-bot[bot] merged 1 commit into
NVIDIA:developfrom
YusefSyed:fix/tunable-rag-judge-parse-error

Conversation

@YusefSyed

@YusefSyed YusefSyed commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closes #2640

When the judge's reply cannot be parsed (it is not JSON, or the JSON is missing a required key), TunableRagEvaluator._evaluate_item_core scores the item 0.0 and writes "Error in evaluator from parsing judge LLM response." into reasoning, but leaves EvalOutputItem.error unset. The item then reads as an answer the judge scored 0, and num_errors and the Errors column of the nat eval summary do not count it. #2479 set error on items that fail inside BaseEvaluator for this reason, and the trajectory evaluator sets it for a judge reply it cannot read (and, since #2612, for a score outside the judge's 1 to 5 scale). This evaluator catches its parse error itself, so BaseEvaluator never sees it.

Fix: the parse-failure branch now sets error to Error in evaluator from parsing judge LLM response: <parser message>. The score stays 0.0, so average_score does not change, and reasoning is unchanged.

Tests in packages/nvidia_nat_langchain/tests/eval/test_tunable_rag_evaluate.py:

  • test_evaluate_partial_failure now also checks that the failed item has error set, the successful item does not, and num_errors is 1.
  • test_unparseable_judge_reply_is_an_error sends four items (a readable reply, a readable reply that scores 0, a reply that is not JSON, and JSON missing a required key) with default and with custom scoring, through evaluate and through evaluate_atif_fn. The two unreadable replies get error set, the two readable ones keep their scores (0.9 and 0.0) with no error, and num_errors is 2.

Both tests fail on develop (the new one in all four cases) with assert None is not None. With the fix, test_tunable_rag_evaluate.py: 20 passed. The full packages/nvidia_nat_langchain suite (pytest packages/nvidia_nat_langchain --run_slow in the package's uv sync --all-groups --all-extras environment, Python 3.12 on macOS arm64) passes on this branch and on develop.

With nat eval --skip_workflow on a three-item dataset whose judge (a local OpenAI-compatible stub) answers two items in prose, the summary shows Errors 0/3 on develop and 2/3 with this change; Avg Score is 0.27 on both. The yapf and ruff check pre-commit hooks pass on the changed files. Not run: the CI test legs on Linux (amd64 and arm64) and on Python 3.11 and 3.13, and the simple_web_query_eval and simple_calculator_eval example integration tests, which use this evaluator and need an NVIDIA API key for their hosted judge.

Not changed here: a reply that parses but whose score is not a number. With custom scoring it keeps that score and gets no error; with default scoring the item raises, which evaluate turns into an error item but evaluate_atif_fn does not catch, so this evaluator's whole ATIF-lane output is lost. That is the missing per-item catch reported in #2638, which also loses the output when a judge call fails.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • Bug Fixes
    • Evaluation results now include an error for responses that can’t be parsed, while preserving the existing zero score and failure reasoning.
    • Successful evaluations, including valid zero scores, remain error-free. Aggregate error counts now reflect failed items consistently across evaluation modes.

When the judge's reply cannot be parsed, `TunableRagEvaluator` scored the
item 0.0 but left `EvalOutputItem.error` unset, so the item looked like a
real score of 0 and `nat eval` counted no errors for it. Set `error` with
the parser's message, as `BaseEvaluator` does for failed items.

Signed-off-by: YusefSyed <[email protected]>
@YusefSyed
YusefSyed requested a review from a team as a code owner November 21, 2026 03:44
@copy-pr-bot

copy-pr-bot Bot commented Nov 21, 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

Copy link
Copy Markdown

Warning

⚠️ Deprecation Notice: NVIDIA NeMo Agent Toolkit has been deprecated as of October 2026 and will reach end of life (EOL) by end of year 2026. Depending on your needs, migrate to: NeMo Relay for observability, middleware, and governance. NeMo Helix for a unified CLI with evaluation, optimization, and hardening capabilities. NeMo Fabric for a consistent interface to run agent harnesses and custom agents.
We recommend completing your migration before the EOL date.

Pull request policy: Only bug fixes may be opened as pull requests.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The tunable RAG evaluator now records judge-response parsing failures in EvalOutputItem.error while retaining a score of 0.0. Tests cover successful scores, parsing failures, and aggregate error counts across scoring modes and evaluation lanes.

Changes

Tunable RAG error reporting

Layer / File(s) Summary
Record and validate parsing errors
packages/nvidia_nat_langchain/src/nat/plugins/langchain/eval/tunable_rag_evaluator.py, packages/nvidia_nat_langchain/tests/eval/test_tunable_rag_evaluate.py
The evaluator records parsing exceptions in the item’s error field and retains the zero score and generic reasoning. Tests check that successful items have no error and that failed items contribute to the aggregate error count across default and custom scoring in legacy and ATIF lanes.

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to de6bb

Judge replies that cannot be parsed now count as evaluation errors instead of looking like successful low scores. Valid scores, including a genuine zero, are unaffected. No actionable merge risk remains; the failing label check is a process matter, not a code issue.

Security architecture risk: Minimal · up to de6bb

Unreadable judge replies now populate an existing diagnostic field and count as evaluation errors. Scores and reasoning retain their previous behavior. No introduced or worsened risk affecting security, failure containment, rollback, or ownership was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(eval): report unparseable tunable RAG judge replies as errors" matches the main change. The PR makes TunableRagEvaluator set EvalOutputItem.error when a judge reply is not JSON or lacks…
Linked Issues check Passed Issue #2640 requires that an unparseable judge reply keep score 0.0 and set EvalOutputItem.error. The reviewed diff for tunable_rag_evaluator.py (base 6a30e1f to head de6bba4) adds error = None be…
Out of Scope Changes check Passed The source change is limited to the parse-failure branch and the EvalOutputItem construction in TunableRagEvaluator._evaluate_item_core. Every changed line serves the #2640 objective. The test changes…
Full details: Title check

Explanation

The title "fix(eval): report unparseable tunable RAG judge replies as errors" matches the main change. The PR makes TunableRagEvaluator set EvalOutputItem.error when a judge reply is not JSON or lacks the required score key, while keeping the 0.0 score. The title is 65 characters, within the roughly 72-character limit. It uses a conventional-commit prefix rather than a strict imperative-mood sentence, but the verb "report" is imperative and the title is concise and descriptive.

Full details: Linked Issues check

Explanation

Issue #2640 requires that an unparseable judge reply keep score 0.0 and set EvalOutputItem.error. The reviewed diff for tunable_rag_evaluator.py (base 6a30e1f to head de6bba4) adds error = None before the parse attempt. The parse-failure except branch now sets error = f"Error in evaluator from parsing judge LLM response: {e}", keeps score = 0.0 and the original reasoning text, and passes error=error into EvalOutputItem. Successful parses leave error as None. The change applies to the shared _evaluate_item_core path, so both default and custom scoring and both lanes reach it. The PR tests (test_evaluate_partial_failure and test_unparseable_judge_reply_is_an_error) cover these cases per the PR description and change summary. I did not execute the tests. The source diff alone establishes the required behavior.

Full details: Out of Scope Changes check

Explanation

The source change is limited to the parse-failure branch and the EvalOutputItem construction in TunableRagEvaluator._evaluate_item_core. Every changed line serves the #2640 objective. The test changes in test_tunable_rag_evaluate.py support that objective. The PR explicitly leaves out nonnumeric-score replies and judge-call failures (#2638), and the diff does not change those paths. No unrelated changes are visible in the reviewed source diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6a30e1f and de6bba4.

Files selected for processing: 2

  • packages/nvidia_nat_langchain/src/nat/plugins/langchain/eval/tunable_rag_evaluator.py
  • packages/nvidia_nat_langchain/tests/eval/test_tunable_rag_evaluate.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.

@willkill07 willkill07 added bug Something isn't working non-breaking Non-breaking change labels Nov 23, 2026
@willkill07

Copy link
Copy Markdown
Member

/ok to test de6bba4

@willkill07

Copy link
Copy Markdown
Member

/merge

@rapids-bot
rapids-bot Bot merged commit d39390b into NVIDIA:develop Nov 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: tunable RAG evaluator scores an unparseable judge reply as 0.0 without setting error, so nat eval counts no errors

2 participants