Repository navigation
fix(tavily_search): parse markdown-emphasized judge verdicts, mask unparseable ones - #6260
qiaochuz-nv wants to merge 3 commits into
Conversation
|
/ok to test 34ca104 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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.
| # 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), |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
I compared the verdict parser on the same judge reply before and after this change.
| # 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
34ca104 to
55d89c4
Compare
|
/ok to test 55d89c4 |
…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]>
|
/ok to test 2d17307 |
55d89c4 to
2d17307
Compare
What changed and why
tavily_search's judge grades each answer with a
correct: yes|noline._verify_answer_with_judgeparsed it withre.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: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|noand scored correctly.This PR:
_JUDGE_VERDICT_RE, which accepts markdown emphasis around thecorrectlabel 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 standalonecorrectfield line is the verdict (not a**correct:** yesquoted in the reasoning,incorrect, orextracted_final_answer) and a value of exactly yes or no, and keeps the first-match rule;JudgeError, so the row goes to thejudge_failedsidecar 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 innemo_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:**extracted_final_answer:** yes,incorrect: yes,correct: maybe, prose);verify()with the exact bold judge reply above (reward 1.0), and an end-to-endverify()with an unparseable reply (raisesJudgeError).pre-commit run --fileson the changed files: passed.Rollout evidence
QA case
langchain_deepagents_agent(Tavily part) on h100-207, hosted policy and judge:20261116T194820732317Z-local-fix-local2aacbf7b986**correct:** yes, parsed'', reward 0.0:task 2 verify() parsed the judge's verdict: expected 'yes', got ''20261116T214423592685Z-local-tavily-fix