Skip to content

fix(ns_tools): keep a masked judge failure from the delegated verifier - #5677

Open
yaoyu-33 wants to merge 3 commits into
mainfrom
yuya/ns-tools-carry-judge-mask
Open

yaoyu-33 wants to merge 3 commits into
mainfrom
yuya/ns-tools-carry-judge-mask

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What

ns_tools scores a rollout by sending /verify to its delegated verifier (math_with_judge by default) and building NSToolsVerifyResponse from the result. It copied only reward. It now also carries mask_sample, failure_kind and failure_reason from the delegated result. Everything else in the response is unchanged, and a delegated result without these fields still gives mask_sample=False, failure_kind=None.

The verify request allows extra fields, so a request can already carry any of these three names. The delegated values are merged into the dumped request before it is expanded, so the verifier's verdict always wins and the constructor never gets the same keyword twice. Other request fields still pass through unchanged.

Why

When the judge call fails, math_with_judge's judge_failsafe returns reward: 0.0 with mask_sample: true, failure_kind: "judge_failed" and the judge error in failure_reason. ns_tools dropped those three fields, so the outage came back as an unmasked reward: 0 with failure_kind: None. Downstream metrics then counted a judge outage as a wrong answer. An outage is not a wrong answer: the sample must stay masked so it is left out of scores, as it is when math_with_judge is used directly.

No issue: this is a small pre-existing bug found while reviewing #5479, kept out of that PR to keep it focused. #5479 edits the same verify() return statement, so whichever merges second needs a trivial rebase.

Validation

  • New test test_verify_takes_verdict_fields_from_delegated_result, 15 cases: 3 delegated results × 5 requests.
    • Delegated results: scored {"reward": 1.0}; the masked judge_failed row that judge_failsafe returns; and an unmasked row that still names a failure (judge_unparseable).
    • Requests: one with none of the three fields, then one each carrying mask_sample=True, mask_sample=False, failure_kind, or failure_reason.
    • Each case must return the delegated reward, mask_sample, failure_kind and failure_reason, keep delegated_response, and keep an unrelated request field (question).
    • Against main, 13 of 15 cases fail. Only the two scored cases whose request agrees with the expected answer pass: the one with no conflicting field and the one carrying mask_sample=False. main drops the delegated fields, and it returns whatever values the request carried for them. For example, a request carrying mask_sample=True comes back masked even though its verdict scored 1.0.
    • Against the first commit of this PR, all 12 cases with a conflicting field fail with TypeError: ... got multiple values for keyword argument.
    • All 15 pass with this change.
  • test_verify_delegates_to_math_with_judge (delegated reward 1.0) and test_verify_uses_default_verifier (delegated reward 0.0) now also assert that an unmasked delegated result stays mask_sample=False, failure_kind=None.
  • pytest resources_servers/ns_tools/tests/ in an ns_tools venv with nemo_skills: 40 passed.
  • pre-commit run --files resources_servers/ns_tools/app.py resources_servers/ns_tools/tests/test_app.py: all hooks passed.

Rollout evidence

N/A for a model rollout: the change only copies three fields from the verifier's reply, and the path it fixes runs only when the judge call fails, which a model rollout does not exercise on demand. Instead, an A/B through ns_tools' real /verify route (FastAPI TestClient, with its judge_failsafe and observability wrappers) fed the row that the real nemo_gym.verification.judge.judge_failsafe builds when a judge call raises:

ns_tools app.py reward mask_sample failure_kind failure_reason
delegated row (input) 0.0 True judge_failed judge request timed out
main 0.0 False None None
this PR 0.0 True judge_failed judge request timed out

Compatibility

Rows from ns_tools runs whose judge failed are now masked instead of scored 0, so reported ns_tools accuracy may rise slightly on runs that had judge outages. Runs without judge failures are unaffected.

🤖 Generated with Claude Code

ns_tools scores by delegating /verify to math_with_judge and copied only
`reward` from the result. When math_with_judge's judge_failsafe masks a
judge outage (mask_sample, failure_kind="judge_failed", failure_reason),
ns_tools returned an unmasked reward of 0, so the outage was scored as a
wrong answer. Carry mask_sample, failure_kind and failure_reason from the
delegated result into NSToolsVerifyResponse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33 yaoyu-33 added bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 5, 2026
@copy-pr-bot

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

@yaoyu-33

yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9897715

@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

I found one accepted-input regression and one required validation gap. The delegated fields otherwise match the shared response contract, and the scoring consumers honor the forwarded mask. I inspected both changed files and the affected producer, transport, and aggregation paths. I didn't execute tests or rollouts in this read-only review.

RISK — Record a representative real smoke rollout

The PR explicitly reports no real model rollout. Its injected TestClient A/B exercises the outage branch, but the protected AGENTS.md quality bar requires representative real model smoke rollouts for behavior-changing environment work. This change to verification changes score eligibility, so that requirement applies. The supplied experiment does not establish that the configured agent, tool server, and delegated verifier still work together with real model output. This is an evidence gap, not a demonstrated runtime failure.

Could you run a representative tool-using model rollout through the existing ns_tools pairing, inspect the agent and verifier output, and record the model/configuration, exact commands, completion count, reward, and mask status in the PR? No production-code change or naturally occurring judge outage is needed for this check.

Acceptance and preservation: The real rollout should complete tool use and delegated verification, with a reward consistent with the inspected answer and a valid grade remaining unmasked. Retain the deterministic masked-outage assertions, the successful delegation/default assertions, and exception-path cleanup check. A wrong answer must remain gradable; an unavailable judge must remain masked.

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

Comment thread resources_servers/ns_tools/app.py Outdated
**body.model_dump(),
reward=result["reward"],
# Keep a failure the verifier masked (such as a judge outage) masked: it is not a wrong answer.
mask_sample=result.get("mask_sample", False),

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 — Accepted request extras now crash response construction.

The request model permits extra fields, so adding mask_sample=False to the existing successful test's request is accepted. If the delegate returns {"reward": 1.0}, body.model_dump() already contains mask_sample; the new explicit keyword then raises TypeError: ... got multiple values for keyword argument 'mask_sample' instead of returning a score. Either diagnostic field independently causes the same collision. These inputs reached a response in the base implementation.

Could you merge the three delegated values into the request dictionary before expanding it? Suggested replacement for the constructor at lines 449–458:

return NSToolsVerifyResponse(
    **{
        **body.model_dump(),
        "mask_sample": result.get("mask_sample", False),
        "failure_kind": result.get("failure_kind"),
        "failure_reason": result.get("failure_reason"),
    },
    reward=result["reward"],
    delegated_response=result,
    **metrics,
)

This preserves the invariant that the current delegated result determines these response fields without duplicate constructor keywords. Keep unrelated request extras, the delegated response, timing metrics, and finally-based session cleanup unchanged. The mask must remain independent of the diagnostic fields.

Proposed checks, not executed: Parameterize requests containing each conflicting field separately. With delegated {"reward": 1.0}, each should return reward 1.0, mask False, and both diagnostics None, without raising. With the existing masked judge-failure fixture, each should return mask True, JUDGE_FAILED, and the delegated timeout reason, even when the request contains conflicting values. Also retain an ordinary delegated zero as unmasked, and check that an explicitly unmasked delegated result preserves diagnostic text without becoming masked. Keep the existing success/error cleanup assertions and confirm an unrelated sample extra survives. Please verify the suggested code before adopting it.

…fields

The verify request allows extra fields, so a request that already carried
mask_sample, failure_kind or failure_reason made NSToolsVerifyResponse
raise "got multiple values for keyword argument". Merge the delegated
values into the dumped request before expanding it, so the verifier's
verdict always wins. Parametrize the delegated-verdict test over each
conflicting request field and over scored, masked and unmasked-diagnostic
delegated results.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d9983b8

This branch was previously deployed

1 inactive (outdated) deployment
public — d9983b80 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10515
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants