Skip to content

fix(tavily_search): parse markdown-emphasized judge verdicts, mask unparseable ones - #6260

Open
qiaochuz-nv wants to merge 3 commits into
mainfrom
qiaochuz/reg-20261113-tavily-judge-verdict
Open

qiaochuz-nv wants to merge 3 commits into
mainfrom
qiaochuz/reg-20261113-tavily-judge-verdict

Conversation

@qiaochuz-nv

@qiaochuz-nv qiaochuz-nv commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

tavily_search's judge grades each answer with a correct: yes|no line. _verify_answer_with_judge parsed it with re.search(r"correct: (yes|no)", ...): case-sensitive, one literal space, no markdown. When the hosted judge (azure/anthropic/claude-sonnet-4-5) wrapped the label in markdown bold, the verdict did not parse:

**extracted_final_answer:** China
**reasoning:** ... "China" is the commonly used short form of "People's Republic of China" ...
**correct:** yes
**confidence:** 100

That correct answer silently scored reward 0.0, with no mask and no failure_kind, so it looked exactly like a wrong answer. The other four rows in the same run used plain correct: yes|no and scored correctly.

This PR:

  • parses the verdict with _JUDGE_VERDICT_RE, which accepts markdown emphasis around the correct label and/or its value (**correct:** yes, **correct**: yes, correct: **yes**, *correct:* yes), case-insensitively. It is anchored to the start of a line, so only a standalone correct field line is the verdict (not a **correct:** yes quoted in the reasoning, incorrect, or extracted_final_answer) and a value of exactly yes or no, and keeps the first-match rule;
  • routes a judge reply with no parseable verdict to a judge failure (JudgeError, so the row goes to the judge_failed sidecar and stays out of aggregates) instead of a silent reward 0. This is a Tavily-specific policy: it explicitly adopts the per-benchmark invalid-verdict exception described in nemo_gym/verification/judge.py. The sibling search servers opencode_search and browsecomp_advanced_harness do not mask this case; they return reward 0.0 for a received but unparseable verdict, and are not changed here. User-facing: a run where the judge returns an unusable reply now reports a judge failure for that row rather than a wrong answer.

Issue

No issue: found by the 2026-11-13 full Gym QA regression (QA case langchain_deepagents_agent, "native DeepAgents searches for all five original Tavily tasks with a live judge and cleanup").

opencode_search (parse_judge_verdict) and browsecomp_advanced_harness (_parse_judge) have their own copies of this parser with the same markdown gap. They are not changed here.

Validation

  • pytest resources_servers/tavily_search/tests/test_app.py: 38 passed. The new tests cover:
    • each markdown variant and the plain form;
    • near-misses that must not parse (**extracted_final_answer:** yes, incorrect: yes, correct: maybe, prose);
    • an end-to-end verify() with the exact bold judge reply above (reward 1.0), and an end-to-end verify() with an unparseable reply (raises JudgeError).
  • pre-commit run --files on the changed files: passed.

Rollout evidence

QA case langchain_deepagents_agent (Tavily part) on h100-207, hosted policy and judge:

Run Gym Result
Before: 20261116T194820732317Z-local-fix-local2 main aacbf7b986 Task 2 judged **correct:** yes, parsed '', reward 0.0: task 2 verify() parsed the judge's verdict: expected 'yes', got ''
After: 20261116T214423592685Z-local-tavily-fix this branch 3/3 cases PASS. In this run the judge wrote plain `correct: yes

@qiaochuz-nv qiaochuz-nv added bug Something isn't working QA_fix Fix implemented by a QA team member area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026
@copy-pr-bot

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

@qiaochuz-nv
qiaochuz-nv requested a review from yaoyu-33 November 16, 2026 21:52
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 34ca104

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 16, 2026 21:53
@yaoyu-33
yaoyu-33 requested a review from wprazuch November 16, 2026 22:05

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP

I found no blocking correctness issues. I reviewed both changed files and traced the new JudgeError path through endpoint wrapping and failure-sidecar routing. One non-blocking NOTE corrects the explanation of the failure policy.

I did not execute tests in this read-only review.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread resources_servers/tavily_search/app.py Outdated
# A judge reply with no parseable ``correct: yes|no`` verdict is an unusable grade, not a
# wrong answer: raising JudgeError routes the row to the judge_failed sidecar (reward excluded
# from aggregate metrics) instead of silently scoring a correct answer 0 with no mask. This
# matches the sibling search-judge servers (opencode_search, browsecomp_advanced_harness),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NOTE (suggestion): Describe this as a Tavily-specific policy change

The sibling-equivalence claim is incorrect. For a received but unparseable verdict, opencode_search returns reward 0.0, and browsecomp_advanced_harness returns reward 0.0 with no error. Neither masks that outcome. The shared judge contract permits an explicit benchmark exception, so Tavily's stated policy is allowed, but the comment gives maintainers the wrong precedent.

Could you replace lines 717–719 with the following and correct the same claim in the PR description?

            # Tavily explicitly adopts the per-benchmark invalid-verdict exception documented in
            # nemo_gym.verification.judge; sibling search servers keep malformed replies as scored zeros.

Keep the parser and JudgeError return unchanged. Static acceptance is that the explanation distinguishes Tavily's new masking policy from the siblings' scored-zero policy. No runtime change is needed; retain the existing assertions that bold yes scores 1.0 and an unparseable Tavily verdict raises JudgeError. This suggestion is source-based, not test-executed.

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I compared the verdict parser on the same judge reply before and after this change.

Comment thread resources_servers/tavily_search/app.py Outdated
# silently scored reward 0. ``\b`` keeps the label the ``correct`` field (not the ``correct``
# inside ``incorrect``); the value stays exactly yes/no. ``re.search`` keeps the first-match
# behavior of the previous parser.
_JUDGE_VERDICT_RE = re.compile(r"\**\bcorrect\**\s*:\s*\**\s*(yes|no)\b", re.IGNORECASE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I checked the same judge reply against base and head. If the reasoning says the candidate claimed **correct:** yes and the next line is correct: no, base gives reward 0 and head gives 1. Could the regex match a standalone correct field line, with Markdown emphasis allowed there, and cover this two-line case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks. The regex is now anchored to the start of a line (^[ \t]*\**correct\**[ \t]*:[ \t]*\**[ \t]*(yes|no)\b with re.MULTILINE), so only a standalone correct field line counts, with Markdown emphasis still allowed on the label and value. Your two-line case (the candidate claimed **correct:** yes then correct: no) now parses as no; I added it plus a reasoning-quote variant to the accepting cases, and a mid-line-only quote to the rejecting cases. Pushed in 55d89c4.

@qiaochuz-nv
qiaochuz-nv force-pushed the qiaochuz/reg-20261113-tavily-judge-verdict branch from 34ca104 to 55d89c4 Compare December 2, 2026 00:09
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 55d89c4

qiaochuz-nv and others added 3 commits December 1, 2026 16:14
…parseable ones

The verify() judge parser used `re.search(r"correct: (yes|no)", ...)`, which
matches only a plain, lowercase `correct: yes|no` on a single literal space.
The hosted judge (azure/anthropic/claude-sonnet-4-5) sometimes emphasizes the
label and/or value in markdown, e.g.

    **extracted_final_answer:** China

    **reasoning:** ...

    **correct:** yes

    **confidence:** 100

For that shape the scan returned no match, so `extracted_final_answer` became
'' and a correct answer silently scored reward 0 — with no mask and no
failure_kind. Observed in the regression case langchain_deepagents_agent on
h100-207 (Gym aacbf7b): task 2 answered "China" against gold "People's
Republic of China", judged `**correct:** yes`, and scored 0; the other four
tasks used plain `correct: yes`/`correct: no` and scored correctly.

Changes (tavily_search only; the parser is duplicated, not shared):
- Accept markdown emphasis around the label and/or value
  (`**correct:** yes`, `**correct**: yes`, `correct: **yes**`, `*correct:* yes`),
  case-insensitively, via a module-level compiled regex. The label must still be
  the `correct` field (`\b` excludes the `correct` inside `incorrect`, so
  `**extracted_final_answer:** yes` is not read as a verdict), the value must
  still be exactly yes/no, and first-match behavior is preserved.
- A judge reply with no parseable verdict now raises JudgeError (routed to the
  judge_failed sidecar, reward excluded from aggregates) instead of a silent
  reward 0 indistinguishable from a wrong answer. This matches the sibling
  search-judge servers opencode_search and browsecomp_advanced_harness, which
  share this judge prompt and already treat an invalid verdict as the documented
  exception in nemo_gym.verification.judge.

Tests: add parametrized parser cases (all bold/italic variants parse to yes/no,
plain form still parses, near-misses like `**extracted_final_answer:** yes`,
`incorrect: yes`, and `correct: maybe` do not), an end-to-end verify() repro of
the task-2 bold shape scoring reward 1, and a verify() case asserting JudgeError
on an unparseable reply.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
…t line

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
…fic policy

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 2d17307

@qiaochuz-nv
qiaochuz-nv force-pushed the qiaochuz/reg-20261113-tavily-judge-verdict branch from 55d89c4 to 2d17307 Compare December 2, 2026 00:14
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:mid Autobot PR risk: mid label Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer QA_fix Fix implemented by a QA team member risk:mid Autobot PR risk: mid sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants