Skip to content

fix(opencode_search,browsecomp_advanced_harness): parse markdown-emphasized judge verdicts - #6263

Open
qiaochuz-nv wants to merge 1 commit into
mainfrom
qiaochuz/reg-20261113-search-judge-markdown
Open

qiaochuz-nv wants to merge 1 commit into
mainfrom
qiaochuz/reg-20261113-search-judge-markdown

Conversation

@qiaochuz-nv

Copy link
Copy Markdown
Contributor

What changed and why

opencode_search and browsecomp_advanced_harness grade with the same judge prompt (browsecomp_advanced_harness/judge_prompt.py). Each server parses the reply with its own copy of re.finditer(r"correct:\s*(yes|no)\b", ..., re.IGNORECASE), and the last match wins. A hosted judge (azure/anthropic/claude-sonnet-4-5) sometimes wraps the label and/or value in markdown emphasis. It did this for tavily_search in the 2026-11-13 QA regression (fixed there by #6260):

**extracted_final_answer:** China

**reasoning:** ... "China" is the commonly used short form of "People's Republic of China" ...

**correct:** yes

**confidence:** 100

The scan does not match **correct:** yes, **correct**: yes, correct: **yes** or *correct:* yes. On main this causes two wrong outcomes:

  • A correct answer scores 0.0. No judge attempt parses, so browsecomp_advanced_harness spends all 15 judge calls at temperature 1.0, and opencode_search spends 4 attempts with a 30 s delay between them. Both then score the row 0.0, so it counts as a wrong answer.
  • A wrong answer scores 1.0. Sometimes a reasoning judge first echoes the rubric in an inline think block, writing a plain correct: yes, and then gives a bold **correct:** no verdict. The last-match rule exists for this case, but the bold verdict does not match, so the last plain match is the echo and the row gets reward 1.0.

This PR:

  • moves the verdict pattern and the answer-line pattern next to the prompt they parse. They become JUDGE_VERDICT_RE and JUDGE_EXTRACTED_ANSWER_RE in browsecomp_advanced_harness/judge_prompt.py, which opencode_search already imports its template from. _parse_judge and parse_judge_verdict use them, so the two parsers cannot drift apart;
  • uses fix(tavily_search): parse markdown-emphasized judge verdicts, mask unparseable ones #6260's tavily_search pattern for JUDGE_VERDICT_RE. It allows emphasis around the label and the value. \b keeps the label to the correct field, so it cannot match inside incorrect, and the value must be exactly yes or no;
  • lets the answer line take the same emphasis and leaves the emphasis out of the captured value. extracted_final_answer then reads China, not ** China, and the template-echo guard still catches a bold echo.

Unchanged: the last-match rule, case-insensitivity, the retry loops, and how each server handles a reply with no verdict at all (the row scores 0.0 after the retries).

User-facing / benchmark impact:

  • Rows whose judge used markdown emphasis are now scored by the judge's verdict. Before, they were 0.0 (or took the earlier echoed verdict).
  • incorrect: yes is no longer read as a yes verdict. On main it was, because the old pattern had no word boundary before correct.
  • Plain replies parse exactly as before. In the live probe below, main and this branch agree on all 48 real judge replies.

Issue

No issue: a follow-up to #6260. The 2026-11-13 full Gym QA regression found the gap in tavily_search, and its triage found the same parser copied into these two servers.

Validation

  • pytest resources_servers/opencode_search/tests resources_servers/browsecomp_advanced_harness/tests: 491 passed.
  • I ran the new tests against main's parser code (main's app.py and judge_prompt.py with this branch's tests): 20 failed. On this branch they all pass. The new tests cover:
    • each bold or italic variant, plus the plain form, with the extracted answer;
    • near-misses that must stay unparsed: **extracted_final_answer:** yes, incorrect: yes, **incorrect:** yes, [correct_answer]: yes, **correct:** maybe, correct: **yesterday**;
    • a plain think-block echo followed by a bold no verdict, which must stay no;
    • a bold template echo, which must stay unparsed;
    • one end-to-end grade per server with the regression reply shape: browsecomp verify() and opencode _judge_answer() return reward 1.0 on the first judge call.
  • pre-commit run --files <changed files>: passed.

Rollout evidence

Replay through each server's own grading path. The judge reply is the only stubbed part (Mac, Gym main d04b6bb294 vs this branch):

Judge reply Server main this PR
plain correct: yes both reward 1.0, China reward 1.0, China (unchanged)
bold **correct:** yes (regression shape) browsecomp verify() reward 0.0, 15 judge calls, answer '' reward 1.0, 1 call, China
bold **correct:** yes (regression shape) opencode _judge_answer() reward 0.0, judge_parsed: false, 4 attempts reward 1.0, judge_parsed: true, 1 attempt, China
think echo correct: yes, then **correct:** no browsecomp verify() reward 1.0 (wrong answer passes), answer ** Lyon reward 0.0, Lyon
think echo correct: yes, then **correct:** no opencode _judge_answer() reward 1.0, answer ** Lyon reward 0.0, Lyon

Live judge probe (h100-207, azure/anthropic/claude-sonnet-4-5, temperature 1.0). I sent 6 question/answer pairs × 4 samples with this servers' prompt, and the same with tavily_search's prompt as a control, then parsed every reply with main's patterns and this branch's.

Prompt Replies Bold verdict line Unparsed (main / PR) Verdict differs
browsecomp/opencode prompt 24 0 0 / 0 0
tavily_search prompt (control) 24 0 0 / 0 0

The judge used emphasis in none of the 48 live replies. The one bold reply on record is from the 2026-11-13 regression (1 of 5 tasks). So the live probe shows that plain replies are not affected; it does not exercise the bold path. The replay and the unit tests above cover the bold path.

No full rollout. browsecomp_advanced_harness needs a Tavily or Exa key plus a sandbox, and opencode_search needs a sandbox plus Exa. The change touches only the reply parser, and the replay runs it through each server's own grading function. Since the live judge did not use emphasis in 48 calls, a rollout would most likely not reach the changed path either.

Replay log, before and after
### BEFORE (main d04b6bb294)
== plain yes
  opencode_search parse_judge_verdict -> (True, 'China', True)
  browsecomp _parse_judge             -> (True, 'China', True)
== bold yes (regression shape)
  opencode_search parse_judge_verdict -> (False, '', False)
  browsecomp _parse_judge             -> (False, '', False)
== think echo + bold no
  opencode_search parse_judge_verdict -> (True, '** Lyon', True)
  browsecomp _parse_judge             -> (True, '** Lyon', True)
== bold yes through the graders
  browsecomp verify()       -> {"reward": 0.0, "extracted_final_answer": "", "judge_calls": 15}
  opencode _judge_answer()  -> {"reward": 0.0, "extracted_final_answer": "", "judge_parsed": false, "judge_attempts": 4, "judge_calls": 4}
== think echo + bold no through the graders
  browsecomp verify()       -> {"reward": 1.0, "extracted_final_answer": "** Lyon", "judge_calls": 1}
  opencode _judge_answer()  -> {"reward": 1.0, "extracted_final_answer": "** Lyon", "judge_parsed": true, "judge_attempts": 1, "judge_calls": 1}

### AFTER (branch 53566c33bc)
== plain yes
  opencode_search parse_judge_verdict -> (True, 'China', True)
  browsecomp _parse_judge             -> (True, 'China', True)
== bold yes (regression shape)
  opencode_search parse_judge_verdict -> (True, 'China', True)
  browsecomp _parse_judge             -> (True, 'China', True)
== think echo + bold no
  opencode_search parse_judge_verdict -> (False, 'Lyon', True)
  browsecomp _parse_judge             -> (False, 'Lyon', True)
== bold yes through the graders
  browsecomp verify()       -> {"reward": 1.0, "extracted_final_answer": "China", "judge_calls": 1}
  opencode _judge_answer()  -> {"reward": 1.0, "extracted_final_answer": "China", "judge_parsed": true, "judge_attempts": 1, "judge_calls": 1}
== think echo + bold no through the graders
  browsecomp verify()       -> {"reward": 0.0, "extracted_final_answer": "Lyon", "judge_calls": 1}
  opencode _judge_answer()  -> {"reward": 0.0, "extracted_final_answer": "Lyon", "judge_parsed": true, "judge_attempts": 1, "judge_calls": 1}

…asized judge verdicts

Both servers grade with the same judge prompt (browsecomp_advanced_harness
judge_prompt.py) and parse the reply with their own copy of
`re.finditer(r"correct:\s*(yes|no)\b", ..., re.IGNORECASE)`, last match wins.
A hosted judge (azure/anthropic/claude-sonnet-4-5) sometimes wraps the label
and/or value in markdown emphasis, as it did for tavily_search in the
2026-11-13 QA regression:

    **extracted_final_answer:** China

    **correct:** yes

The scan does not match `**correct:** yes`, `**correct**: yes`,
`correct: **yes**` or `*correct:* yes`. On such a reply both servers burn
every judge attempt (browsecomp 15 calls at temperature 1.0, opencode 4 calls
with a 30 s delay) and then score the row 0.0, so a correct answer counts as
wrong. When a reasoning judge also echoes a plain `correct: yes` inside its
think block, the last plain match is the echo, so a bold `**correct:** no`
verdict is overridden and a wrong answer scores 1.0.

Changes:
- Move the verdict and answer-line patterns next to the prompt they parse, as
  JUDGE_VERDICT_RE and JUDGE_EXTRACTED_ANSWER_RE in
  browsecomp_advanced_harness/judge_prompt.py (opencode_search already imports
  its template from there), and use them in `_parse_judge` and
  `parse_judge_verdict`.
- JUDGE_VERDICT_RE is the tavily_search pattern from #6260: emphasis is
  allowed around the label and value, `\b` keeps the label the `correct`
  field (not `incorrect`), and the value is exactly yes/no.
- The answer line accepts the same emphasis and leaves it out of the capture,
  so `extracted_final_answer` reads `China`, not `** China`, and the
  template-echo check still catches a bold echo.

Unchanged: last-match rule, case-insensitivity, retries, and each server's
handling of a reply with no verdict (scored 0.0 after the retries).

Tests: parametrized bold/italic variants and the plain form, near-misses that
must stay unparsed (`**extracted_final_answer:** yes`, `incorrect: yes`,
`[correct_answer]: yes`, `**correct:** maybe`, `correct: **yesterday**`),
a plain think echo before a bold `no` verdict, a bold template echo, and one
end-to-end grade per server (verify() / _judge_answer()) asserting reward 1.0
on the first judge call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
@qiaochuz-nv qiaochuz-nv added the QA_fix Fix implemented by a QA team member label 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

Copy link
Copy Markdown
Contributor Author

/ok to test 53566c3

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 16, 2026 22:34

@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 WITH CARE

RISK: Add the required representative rollout and reward-comparison evidence

Both changed parsers determine fixed BrowseComp benchmark rewards through BrowseComp grading and OpenCode grading. The supplied validation includes stubbed grader replays and agreement on 48 live judge replies, but no representative model rollout or paired benchmark reward profile. The probe supports plain-reply compatibility; it does not show the reward distribution on representative benchmark outputs. The pinned rubric requires that comparison, and repository guidance requires representative real smoke rollouts for behavior-changing environment work. This is a validation gap, not a demonstrated scoring defect.

Could you add representative real smoke evidence for the affected pairings and inspect the final answers and verifier results? Compare base/head grading on the same saved benchmark answers and judge replies, reporting sample count, aggregate reward, unparsed counts, and the cause of each changed grade. Keeping the replies fixed isolates the parser change without requiring two full agent evaluations.

Acceptance should show unchanged grades for ordinary replies and explain changes caused by emphasized verdicts or rejected incorrect labels. Keep the existing first-call bold-yes assertions in the BrowseComp test and OpenCode test, including reward 1.0, answer China, and one judge call. Also retain the echoed-yes followed by bold-no result of reward 0.0.

I inspected all five changed files and traced both grading paths. I did not execute tests or rollouts; the checks requested above are proposed acceptance checks.

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

# yes/no. The answer line accepts the same emphasis and leaves it out of the captured answer, so
# the field reads `China`, not `** China`, and the template-echo check still sees a bold echo.
JUDGE_VERDICT_RE = re.compile(r"\**\bcorrect\**\s*:\s*\**\s*(yes|no)\b", re.IGNORECASE)
JUDGE_EXTRACTED_ANSWER_RE = re.compile(r"extracted_final_answer\**\s*:\s*\**\s*(.+?)[ \t]*\**[ \t]*(?:\n|$)")

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.

RISK: Preserve literal asterisks in extracted answers

With extracted_final_answer: A*\ncorrect: yes, this pattern captures A; a plain *NSYNC similarly becomes NSYNC. The base parser kept those characters. These are unpaired literal asterisks, not emphasis, and the prompt requests the exact answer. Both BrowseComp and OpenCode now return the altered extracted_final_answer. Rewards still follow the verdict, so the defect affects the recorded answer rather than the score.

Could you separate label-closing markers from value formatting and unwrap value emphasis only when its outer markers are paired? The invariant is that accepting markdown must not remove unmatched characters from an otherwise plain answer. I cannot give a reliable one-line replacement because stars after the colon can close label emphasis or open value emphasis; blanket trimming would repeat this defect.

Proposed checks for both parsers: the inputs above must return (True, "A*", True) and (True, "*NSYNC", True). Also preserve A* with the label **extracted_final_answer:**. Retain the existing cases where **extracted_final_answer:** Paris, extracted_final_answer: **Paris**, and italic labels extract Paris. Keep bold template echoes unparsed and the plain think-block yes followed by a bold no verdict returning (False, "Lyon", True). These expectations are based on source inspection, not executed tests.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026
@yaoyu-33
yaoyu-33 requested a review from adil-a November 16, 2026 23:35
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 18, 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 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 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.

2 participants