Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- NeMo Gym now scores native multi-step tasks once using the task's `mean` or
`final` strategy. The live case grid and finished report use the same verdict.
A failed or ungraded step leaves the attempt unscored. With `final`, the last
step determines which metrics apply, even if an earlier step scored one.
Each step keeps its own verifier output and trajectory after job cleanup,
including steps completed before a failure. Gym masks configured credential
values in trajectory text, verifier output, and step failure messages.
- Reject unsafe paths in SkillSpector scope exclusions and clarify incomplete
supply-chain scans when work counters disagree with the ledger.

Expand Down
27 changes: 26 additions & 1 deletion docs/nemo-gym.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,30 @@ Its help must describe a standalone positional `TARGET`, `tasks`, `task_dir`,
be collected. The Gym implementation must execute inside Docker and resolve task
environment templates; a host-only agent harness does not meet this contract.

A native multi-step task reports its steps in order in `turns`, each with its own
`verifier_return_code` and `verifier_logs_dir`; Gym leaves the top-level pair unset.
SkillEvaluator keeps each step's rewards, verifier files and trajectory under the step's
name, as for a Harbor multi-step trial, and scores the attempt once by the task's
`multi_step_reward_strategy` as Gym reports it in `turn_reward_strategy`: `final` takes
the last step's rewards, and `mean` averages each reward key over the steps that ran,
counting a key a step did not report as 0. The attempt is unscored when a step was masked,
failed, or produced no verifier result, when Gym marked the episode failed, or when the
strategy is missing or unsupported. For a step with no verifier result, Gym's own `mean`
counts it as 0 and Harbor leaves it out; SkillEvaluator does neither, so a step the
verifier never graded is never part of a score. An episode Gym stopped after a step
missed its `min_reward` is scored over the steps that ran, as on Harbor. Gym exports
each turn's own input and new output even when `turn_sessions` is `continue`, so the
merged trajectory keeps every turn's steps in order and never treats a turn that opens
like the previous one as a repeat. The live case status shown during the run judges
every Gym attempt as the finished run does: an attempt that misses its goal under
standard grading shows as failed, and one the finished run leaves unscored, such as
one whose required judge failed or whose verifier names a different case than the
staged task, shows as an error, also after the staged tasks are removed. Judge
attribution follows `turn_reward_strategy` too, so a `final` attempt names only the last
step's judges. The published trial keeps each step's redacted trajectory and verifier
output under `steps/<name>/` after the run's job folder is removed. Tests cover this with
source-shaped Gym rollouts; a live multi-step Gym run has not been recorded yet.

</Accordion>
<Accordion title="Options, saved configuration, and retained artifacts">

Expand Down Expand Up @@ -296,7 +320,8 @@ Docker sandboxes before you run again. A finished run updates `latest` and recor
the same dataset snapshot and publication target as a Harbor run. As on Harbor
without `--harbor-keep-jobs`, the staged tasks and per-trial files are removed at
the end; Gym's own redacted `gym.log` and its `rollouts.jsonl` stay under
`_nemo-gym/` in the run folder, and the rollouts hold the raw agent responses.
`_nemo-gym/` in the run folder with each arm's `task_case_ids.json`, the case each
staged task ran as, and the rollouts hold the raw agent responses.

</Accordion>
</AccordionGroup>
4 changes: 3 additions & 1 deletion docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,9 @@ completed run directly:
per-trial artifacts: the trial's `reward.json`, Harbor's `trajectory.json`
when available, and redacted, size-capped diagnostic copies such as
`trial.log`, `exception.txt`, and agent logs (`codex.txt`, `opencode.txt`).
With standard grading, `reward.json` records `trajectory_source` (the
A multi-step trial also keeps each named step's redacted `trajectory.json`
and `test-stdout.txt` under `steps/<step>/`, so an attempt that stopped
partway still shows the steps that ran. With standard grading, `reward.json` records `trajectory_source` (the
trajectory or agent log that was graded) and, under each LLM judge's
`details`, an `omitted` record showing whether its evidence was truncated to
fit the [evidence budget](/skills/skillevaluator/tier3-grading#evidence-budgets) or, for
Expand Down
76 changes: 55 additions & 21 deletions src/skillevaluator/tier3/case_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import hashlib
import json
import logging
import os
Expand Down Expand Up @@ -1590,6 +1591,9 @@ def load_case_marks(run_dir: Path) -> dict[str, dict[str, dict[str, list[str]]]]


_LIVE_VARIANTS = {"with": "with_skill", "without": "without_skill"}
# Gym run folder -> mark of each rollout its last poll read, the least recently polled run first.
_GYM_LIVE_MARKS: dict[str, dict[str, str]] = {}
_MAX_GYM_LIVE_MARKS = 65536


def _harbor_job_owner(job_name: str, agents: list[str]) -> tuple[str, str] | None:
Expand Down Expand Up @@ -1617,45 +1621,75 @@ def _live_mark(trial: Path, run_dir: Path, pass_threshold: float) -> str | None:
return ERROR


def _gym_live_mark(
row: dict[str, Any],
task: str,
case_id: str,
pass_threshold: float,
judged: Mapping[str, str],
seen: dict[str, str],
) -> str:
from skillevaluator.tier3.nemo_gym.results import rollout_verdict

# Gym appends a rollout only once its verifier logs are written, so each line is judged once.
key = hashlib.sha256(json.dumps([row, task, case_id, pass_threshold], sort_keys=True).encode()).hexdigest()
mark = seen.get(key) or judged.get(key)
if mark is None:
passed = rollout_verdict(row, task, case_id, pass_threshold)
mark = ERROR if passed is None else PASS if passed else FAIL
seen[key] = mark
return mark


def _keep_gym_live_marks(run: str, seen: dict[str, str]) -> None:
"""Keep the verdicts of the rollouts a Gym run holds now for its next poll.

Past ``_MAX_GYM_LIVE_MARKS`` verdicts, the runs polled longest ago are dropped; the run just polled
keeps all of its verdicts, so a poll judges only the rollouts appended since the last one.
"""
_GYM_LIVE_MARKS.pop(run, None)
_GYM_LIVE_MARKS[run] = seen
kept = sum(len(marks) for marks in list(_GYM_LIVE_MARKS.values()))
for other in [other for other in list(_GYM_LIVE_MARKS) if other != run]:
if kept <= _MAX_GYM_LIVE_MARKS:
break
kept -= len(_GYM_LIVE_MARKS.pop(other, {}))


def _add_gym_live_marks(
run_dir: Path, agents: list[str], marks: dict[str, dict[str, dict[str, list[str]]]], pass_threshold: float
) -> bool:
"""Add the attempts a running NeMo Gym arm has appended to its ``rollouts.jsonl``; False for a non-Gym run.

Each attempt is scored from its verifier logs with the same rules the Gym result normalizer uses.
Each attempt is judged as the finished run judges it, for the case the runner staged its task as.
A task the runner recorded no case for is its own case.
"""
from skillevaluator.tier3.nemo_gym.results import (
read_rollouts,
read_verifier_rewards,
rollout_failure_text,
rollout_task_name,
)
from skillevaluator.tier3.nemo_gym.results import TASK_CASE_IDS_FILE, read_rollouts, rollout_task_name

gym_root = run_dir / "_nemo-gym"
if not gym_root.is_dir() or gym_root.is_symlink():
return False
judged = _GYM_LIVE_MARKS.get(str(gym_root), {})
seen: dict[str, str] = {}
for agent in agents:
for variant, key in _LIVE_VARIANTS.items():
arm = gym_root / f"{agent}-{variant}"
rollouts = arm / "rollouts.jsonl"
if arm.is_symlink() or rollouts.is_symlink() or not rollouts.is_file():
continue
case_ids = _load_json(arm / TASK_CASE_IDS_FILE, root=run_dir)
if not isinstance(case_ids, dict):
case_ids = {}
for row in read_rollouts(rollouts):
case_id = rollout_task_name(row)
if case_id is None or not _SAFE_TRIAL.match(case_id):
task = rollout_task_name(row)
if task is None or not _SAFE_TRIAL.match(task):
continue
logs_dir = row.get("verifier_logs_dir")
rewards = (
read_verifier_rewards(Path(logs_dir))
if not rollout_failure_text(row) and isinstance(logs_dir, str) and logs_dir
else None
)
score = rewards.get("overall", rewards.get("reward")) if rewards else None
if not isinstance(score, int | float) or isinstance(score, bool):
mark = ERROR
else:
mark = PASS if score >= pass_threshold else FAIL
marks.setdefault(agent, {}).setdefault(key, {}).setdefault(case_id, []).append(mark)
case_id = case_ids.get(task)
if not isinstance(case_id, str) or not case_id:
case_id = task
mark = _gym_live_mark(row, task, case_id, pass_threshold, judged, seen)
marks.setdefault(agent, {}).setdefault(key, {}).setdefault(task, []).append(mark)
_keep_gym_live_marks(str(gym_root), seen)
return True


Expand Down
Loading
Loading