Repository navigation
feat(agentic_turn_simulation_judge): train the policy to be the agentic_turn_simulation judge - #6320
Conversation
…ns the agentic_turn_simulation judge The policy plays the agentic_turn_simulation judge: each row holds the judge's exact prompt (rubrics, tool definitions, the recorded agent turn) and a reference label, and the policy writes the JSON verdict. The reward is 1 when the verdict's correctness ladder (`addresses_concern`, then `correct`) matches the label. Verdicts are parsed strictly and checked against the agentic_turn_simulation evaluation schema by default; a softer reward, a field bonus and an analysis word cap are optional. Metrics include accuracy, balanced accuracy, kappa, parse failures and the leniency gap, sliced by row provenance. Ships five synthetic example rows rendered with the agentic_turn_simulation judge prompt builder, hand-written example rollouts scored by the server, a row validator, and tests that check the verdict parser and ladder against the agentic_turn_simulation judge. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
|
/review |
|
/ok to test 69b3201 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
The schema-disabled scoring path can reward an output that never decides steerability. I also found three RISK defects in field metrics and dataset validation, detailed inline.
RISK: Supply representative real-model smoke-rollout evidence
The supplied PR description includes no model-run evidence, and the component README explicitly identifies the committed rollouts as hand-written. These fixtures exercise verification but do not validate the configured agent, model adapter and verifier together. The repository quality bar requires representative real smoke rollouts for environment behavior changes.
Could you run the documented example with a real model and attach the command, model/configuration, reviewed commit, rollout artifact and inspection results? A full reward profile is optional for this training environment. Keep the synthetic fixtures accurately labeled, including correcting the contradictory “real policy's outputs” description in the fixture test.
Acceptance: show representative rows completing through the configured agent, actual assistant verdicts reaching /verify, and inspected rewards agreeing with the documented ladder. Report parse failures rather than requiring perfect model accuracy. Keep malformed-verdict tests asserting zero reward without masking.
NOTE, suggestion: Add a discoverable user-doc entry
This introduces a user-facing training environment, but the changed files contain no Fern documentation. The existing LLM-as-Judge guide describes verifier-side judges, not training the policy to produce verdicts.
Could you add a short, linked section or page explaining this composition, reference-label inputs and the example command? Link to the component README for detailed fields and metrics. Preserve the existing guide's description of verifier-side judges. Acceptance is a static documentation check: a published page or navigation entry leads to the feature, its command matches the committed config, and it distinguishes label agreement from direct agent-turn evaluation.
I inspected all 21 changed files and traced the affected parsing, dataset and runtime paths. I completed the parser inspection directly because its delegated report was unavailable. This was a static review; I did not execute tests or model rollouts. All checks proposed below are unexecuted.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| return None | ||
| if verdict.get("addresses_concern") == "no": | ||
| return "no" | ||
| value = verdict.get("correct") |
There was a problem hiding this comment.
BLOCKER: Require a valid steerability decision before passing the ladder
With validate_schema=False, read_verdict('{"correct":"yes"}', validate_schema=False) returns a passing ladder with no error. {"addresses_concern":"maybe","correct":"yes"} does too. Scoring then awards reward 1 against a yes label. Neither output decides the documented ladder: an absent or invalid addresses_concern cannot establish engagement. This corrupts rewards in runs using the supported schema-disabled option.
Could you distinguish addresses_concern == "yes" from missing/invalid values before reading correct? Replace the final branch of correct_ladder with:
if verdict.get("addresses_concern") == "no":
return "no"
if verdict.get("addresses_concern") != "yes":
return None
value = verdict.get("correct")
return value if value in ("yes", "no") else NoneAlso update the undecided-ladder error classification to recognize missing addresses_concern, not only missing correct:
error = "missing_keys" if any(k not in verdict for k in ("addresses_concern", "correct")) else "bad_enum"Preserve the short-circuit distinction: with schema validation disabled, {"addresses_concern":"no"} already determines ladder no without correct; addresses_concern="yes" needs a valid correct. Full-schema validation must still require every schema field.
Proposed acceptance: assert the two failing examples above produce no ladder and zero reward, with missing_keys and bad_enum respectively in strict mode. Retain valid yes/yes, yes/no, and no/yes outcomes; add the schema-disabled no-without-correct case. Keep the existing schema-disabled and forced-no tests. Please verify the suggested code before adopting it.
…, field metrics and row validation - Ladder: `addresses_concern` must be "yes" before `correct` is read, so with `validate_schema: false` a verdict that never decides engagement (missing or invalid `addresses_concern`) gets no ladder and scores 0 (`missing_keys` / `bad_enum`). Schema-validated scoring (the default) is unchanged. - `field_acc/*`: a rollout without a prediction (unparsed, or no verifier output) counts as a miss for every known reference field instead of leaving the denominator. - `GoldFields` extras must be strings or null, matching the request model, so `validate_rows.py` rejects rows the server would reject. - `validate_rows.py`: files that share a basename are reported and split-checked by full path. - Test docstring: the committed example rollouts are hand-written, not a policy's outputs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
…a-disabled scoring `validate_schema` is on by default and then every schema field must be valid. With it off, only the ladder is read, as before: `addresses_concern` "no" gives "no", otherwise `correct` decides. Reverts the `correct_ladder` / error-classification change and its tests from 87c4277; the other fixes stay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
|
/ok to test b7ab988 |
|
@prokotg to review tomorrow or Monday |
|
@prokotg follow-up here. Could you PTAL ? Thanks! |
yfw
left a comment
There was a problem hiding this comment.
HOLD. The merge queue cannot pass until you refresh this server's uv.lock for current main (pyproject.toml:20). Apart from the lock, this review is SHIP WITH CARE, because app.py:224 is a rare HTTP 500 with a one-block fix.
Thank you for this server. The parser drops the ATS salvage of cut-off output, and its brace search and JSON decode loop bound their work on adversarial text. The drift tests against the ATS judge import it directly, so they fail instead of skipping. The example rows regenerate byte for byte from the ATS prompt builder. The fixes for three of the automated review's threads are correct, and each one has a test.
Process: please merge main and refresh the lock as described at pyproject.toml:20. DCO sign-off is present on all four commits. The required checks are green, but they ran on 2026-11-18, before #6528 changed main's root pins on 2026-11-20. After you push the new lock, CI needs a new /ok to test comment with the new full head SHA. The title is not in Conventional Commit form. Your first commit's subject already has that form: feat(agentic_turn_simulation_judge): add a resources server that trains the agentic_turn_simulation judge. The PR body does not use the template: it has no Validation, Rollouts or Compatibility section, and no issue link.
You reverted the fix for the automated review's ladder BLOCKER on purpose (thread). That thread applies only with validate_schema: false, and the shipped configuration keeps it on. A verdict that leaves out or garbles addresses_concern never earns more reward than the same verdict with "yes". The automated review's request for a real-model smoke rollout is still open.
Generated by Claude Code
prokotg
left a comment
There was a problem hiding this comment.
Thanks for this. The verifier logic itself reads correct to me. I'm requesting changes for a few things below, mostly around error handling, duplicated declarations and reproducibility.
How does someone get the data?
I can't tell how to get real data for this. The PR ships five synthetic rows, and the README says real rows are "built outside git from stored reference-judge requests and results", but I couldn't find where those are, who can read them, or the code that builds them. make_example_rows.py only makes the synthetic example, and the config has no train or validation dataset. So nobody else can reproduce a run or the baseline.
I also can't see how the labels are derived. I can guess from gold_n and the tier descriptions that tier A means unanimous over several passes, but not how gold_ladder, gold_p_yes and gold_fields are computed, or how ties and unusable passes are handled.
Could you add the builder script (with the label policy) or a link to it, and say where the built files live and who can access them? If the data is meant to be public, a train/validation entry in the config would let gym eval run work end to end.
PR title and description
Could you bring these in line with the repo convention (see AGENTS.md "Pull Requests")? The title should be Conventional Commit style, type(optional-scope): imperative summary, for example feat(agentic-turn-simulation-judge): add judge-training resources server. The description should say what changed and why, link the issue (or say why none is needed), list the exact validation you ran, and include rollout evidence or an explicit N/A with a reason, plus any compatibility notes.
| except Exception: # noqa: BLE001 - the reward boundary: a verifier bug scores 0, it never crashes the server | ||
| LOG.exception("agentic_turn_simulation_judge: verify failed for row %s", body.row_id) | ||
| outcome = {"reward": 0.0, "parse_ok": False, "parse_error": INTERNAL_ERROR} |
There was a problem hiding this comment.
If verify hits a bug, we return reward=0.0, parse_error="internal" and mask_sample stays False. The test pins this. So a verifier bug shows up in training as "the policy got it wrong", and the only trace is a log line. read_verdict does the same one level down (verdict.py:217), turning any exception into bad_json without even logging, so a parser bug would look like the model writing bad JSON.
Can we split these? Unreadable policy output is a legit 0, as it is now. A verifier exception isn't the policy's fault, so I'd raise or mask it with a failure_kind, like other servers do for infra errors. I think you can just drop the catch in read_verdict, since parse_strict and parse_lenient already handle ValueError and RecursionError. If you want to keep one, at least log it.
| try: | ||
| verdict, error = (parse_strict if parse_mode == "strict" else parse_lenient)(text) | ||
| except Exception: # noqa: BLE001 - the reward boundary: no output may crash /verify | ||
| verdict, error = None, "bad_json" |
There was a problem hiding this comment.
Same pattern as the blanket catch in verify (see my comment on app.py:305-307): a parser bug here becomes bad_json with no log, so it looks like a policy format failure.
| class AgenticTurnSimulationJudgeRunRequest(BaseRunRequest): | ||
| """Row fields on the wire (see task_data.py for their meaning).""" | ||
|
|
||
| model_config = ConfigDict(extra="allow") | ||
|
|
||
| task: Literal["verdict"] = "verdict" | ||
| row_id: Optional[str] = None | ||
| group_id: Optional[str] = None | ||
| gold_ladder: Ladder | ||
| gold_p_yes: Optional[float] = Field(default=None, ge=0.0, le=1.0) | ||
| gold_n: Optional[int] = Field(default=None, ge=0) | ||
| gold_fields: Optional[dict[str, Optional[str]]] = None | ||
| label: Optional[dict[str, Any]] = None | ||
| meta: Optional[dict[str, Any]] = None | ||
|
|
||
|
|
||
| class AgenticTurnSimulationJudgeVerifyRequest(AgenticTurnSimulationJudgeRunRequest, BaseVerifyRequest): | ||
| pass |
There was a problem hiding this comment.
We have the row schema twice: RunRequest here and TaskData in task_data.py. The docstring there says they "mirror" each other, but they already don't. The request has loose dicts for label, meta and gold_fields, while TaskData has typed LabelInfo, MetaInfo and GoldFields. For example, a bad meta.hand_ladder gets through /verify and is only caught by validate_rows.py. I couldn't find a test that fails when they diverge.
Could RunRequest just reuse the TaskData types? If it has to stay loose on purpose, a small test comparing field names and required-ness would be enough to catch drift.
| `VERDICT_FIELDS`, `correct_ladder`, the think stripping and the lenient parse are copied from | ||
| `resources_servers/agentic_turn_simulation/judge.py` (not imported: that module pulls in the ATS harnesses and | ||
| jsonschema), minus the ATS salvage of cut-off output: a verdict that broke off is never read here. | ||
| `prompts/evaluation_schema.json` is a copy of the ATS output schema; tests fail when either copy drifts. |
There was a problem hiding this comment.
A good chunk of this file (~100 lines) is copied from ATS judge.py: VERDICT_FIELDS, correct_ladder, _unwrap, strip_think, the lenient parser. The schema JSON is copied too, and test_golden.py (171 lines) exists to catch drift. The docstring says we can't import ATS because it pulls in the harnesses and jsonschema, but make_example_rows.py and the golden tests import it anyway.
The risk is that someone changes the schema or ladder rule in ATS, forgets this server, and the labels and reward quietly stop matching the judge they're supposed to match. The golden tests catch it, but only if they run in the same CI job.
Would it be doable to pull the pure verdict bits (fields, ladder, schema, parser) into a small module with no harness or jsonschema imports, and have both servers use it? That would remove the copies and most of the drift tests. If you'd rather keep the copy, please put the source file and commit in the file header so the link doesn't depend on the tests.
| # 1.0 when pred_ladder == gold_ladder: the accuracy metrics read this, whatever reward_mode pays. | ||
| ladder_match: float = 0.0 | ||
| parse_ok: bool = False | ||
| parse_error: Optional[str] = None | ||
| # Confusion one-hots with POSITIVE = ladder "no" (the judge catches a failed turn); all 0 when unparsed. | ||
| tp: float = 0.0 | ||
| fp: float = 0.0 | ||
| fn: float = 0.0 | ||
| tn: float = 0.0 | ||
| analysis_words: int = 0 | ||
| output_chars: int = 0 | ||
| # The parsed verdict's enum fields (no analysis/reason text); None when nothing parsed. | ||
| pred_fields: Optional[dict[str, Any]] = None | ||
| # Per gold_fields key: whether the prediction gives the same value (an unparsed output matches nothing). | ||
| field_matches: dict[str, bool] = Field(default_factory=dict) | ||
| field_match_share: Optional[float] = None |
There was a problem hiding this comment.
The verify response carries a lot of fields that are derivable from the others: tp/fp/fn/tn from pred_ladder and gold_ladder, ladder_match from the same pair, field_match_share from field_matches, and pred_fields from the verdict. Looking at compute_metrics, it rebuilds the confusion stats from (pred_ladder, gold_ladder) pairs in classification_stats and never reads tp/fp/fn/tn, field_match_share, pred_fields, analysis_words or output_chars. Only ladder_match, pred_ladder, parse_ok, parse_error and field_matches are used.
That means about ten extra fields on every rollout line, times num_repeats. It also means two places compute the same confusion counts, and nothing checks that they agree (for example on unparsed outputs). Once they're in the response schema, removing them is a breaking change for anyone who reads them.
Does something downstream read these? If not, I'd drop them and keep pred_ladder, parse_error and field_matches. If something does, could we compute them in one place that the metrics use too?
| if error is None and ladder is None: | ||
| # Only reachable without schema validation: the verdict does not decide the ladder. | ||
| error = "missing_keys" if "correct" not in verdict else "bad_enum" |
There was a problem hiding this comment.
parse_error is the thing we'd look at to see what the policy is doing wrong, so I'd like each code to mean one thing. Right now missing_keys is used for three cases:
- lenient parse found a JSON object but none contains
addresses_concern(line 175), - a key the schema requires is absent (line 185),
- with
validate_schemaoff,correctis absent when the ladder is undecided (here).
bad_enum is used for a value outside the enum, but also for a non-string where the schema says string (lines 190-191, for example discard: true), and for the no-validation fallback when correct is present but isn't yes/no (here).
The practical problem is the metrics: parse_fail/bad_enum could mean "wrong enum value" in one run and "emitted a boolean" in another, and the numbers change meaning with parse_mode and validate_schema. Someone seeing "bad_enum 8%" might go and tweak the enum wording when the model is producing booleans.
Could we give each case its own code (for example bad_type for non-strings, and undecided_ladder for the no-validation fallback)? Also, the codes are string literals spread over several lines, with PARSE_ERRORS as a separate tuple. A StrEnum or Literal would make a typo a type error instead of a silent missing bucket in parse_fail/<kind>.
Signed-off-by: Junkeun Yi <[email protected]>
…rors and parser speed - Refresh uv.lock for current main (root pins moved in #6528 and after). - Mask a verifier exception (mask_sample, failure_kind verifier_error) instead of scoring it 0; read_verdict no longer turns parser exceptions into bad_json. - pred_fields returns strings only, with lone surrogates replaced, so /verify never answers 500. - Remove reward_mode soft (unused); the reward is the gold_ladder match. gold_p_yes is provenance. - Strip the strict-mode fence by slicing and run the think regex only up to the last closing tag (both were quadratic on adversarial text; same results). - Name the ATS source file and commit of the copied code; add a RunRequest/TaskData drift test. - README: how labels are built, what each parse_error code covers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
|
/ok to test b70afb1 |
…blic nemo_gym.core API Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
Signed-off-by: Junkeun Yi <[email protected]>
|
/ok to test 7a76ad1 |
prokotg
left a comment
There was a problem hiding this comment.
Thanks for addressing my comments, looks good
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46604758893 |
matches the reference label, else 0. The ladder is
"no"ifaddresses_concern == "no", elsecorrect. Verification is deterministic: no LLM is called at verify time.Why
To train and measure judging of agent turns (did the agent do the right thing in its turn) against reference judge labels.
Issue
None: this is a new environment with no open issue.
Validation
pytest resources_servers/agentic_turn_simulation_judge/tests tests/unit_tests/test_public_api_facades.py: all passed (1 skipped).scripts/component_locks.pywith uv 0.13.4 after merging main: 343 projects checked, 0 failed.Rollouts
Real-model smoke: GLM-5.3 as the policy, served by self-hosted vLLM with its reasoning parser. The 5 example rows were run with 4 repeats each, at temperature 1.0 and a 32,768-token output cap, using
gym env startandgym eval runas in the README.bad_json: prose before the JSON, which strict mode scores 0)Per row: fix_typo 4/4, refuse_credentials 4/4, partial_rename 4/4, missing_log_file 4/4, claims_tests_pass 3/4.
data/example_rollouts.jsonlis synthetic: hand-written verdicts scored by this server's verify.Compatibility
New server only. No core Gym changes.
🤖 Generated with Claude Code