Skip to content

feat(legal-agent-bench): refresh Harvey tasks, runtime, and grading - #5791

Merged
athitten merged 28 commits into
NVIDIA-NeMo:mainfrom
rystewart-nvidia:lab-refresh/source
Nov 21, 2026
Merged

athitten merged 28 commits into
NVIDIA-NeMo:mainfrom
rystewart-nvidia:lab-refresh/source

Conversation

@rystewart-nvidia

@rystewart-nvidia rystewart-nvidia commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Refresh LAB to Harvey LABs revision 9e9fa7fe126103de1fceb2227b7c70bf59b67f73, with 2,010 tasks (up from 1,749) and update gym LAB benchmark version 0.2.0. Update tools, prompts, document processing, and grading together so the new tasks can be evaluated correctly.

  • Load skills from lab_core/harness/skills. Preserve existing task IDs, shared-document caching, and task selection.
  • Match Harvey’s finish behavior: reject missing output files twice, then allow completion even if files are still missing.
  • Update document extraction, including DOCX comments, and pin Pandoc to version 3.11.
  • Require at least one configured judge. Support the official Claude Sonnet 4.6 and GPT-5.5 pair, average their scores, and retain separate grading reports.
  • Also, fix document-label matching in categorize-document-production-set-by-relevance-and-privilege using the 22 ID-to-filename mappings from its pinned rubric. Apply this correction only to that task and revision.

Depends on #5788, which provides the Harbor Environment Server integration. This PR will be rebased onto main after #5788 merges. Shared runtime changes are in separate prerequisites; this PR changes LAB components only, with matching guide, catalog, and attribution updates.

Validation

All 202 LAB, native-agent, benchmark, and docs-link tests passed. All-files pre-commit and import checks passed.

uv sync --locked --project resources_servers/legal_agent_bench
source resources_servers/legal_agent_bench/.venv/bin/activate
PYTHONPATH=. LITELLM_LOCAL_MODEL_COST_MAP=True uv run --active --no-sync python -m pytest \
  resources_servers/legal_agent_bench/tests \
  responses_api_agents/legal_agent_bench_native/tests \
  benchmarks/legal_agent_bench/tests \
  tests/unit_tests/test_fern_docs_links.py --import-mode=importlib -q

LITELLM_LOCAL_MODEL_COST_MAP=True avoids downloading model prices during imports; --active --no-sync uses the activated environment.

pre-commit run --all-files
git diff --check

Verified source archive SHA-256 333223f7bd293e075ba3d3444f0752b210d52ff2b4f961e888b20afe771c8261 and the 2,010-task inventory.

Rollouts

Ran two example tasks (trust-document comparison and transition services agreement markup) in Docker with the LAB nativ harness with GPT-5.6-sol and produced the requested DOCX files. Both judges (Sonnet 4.6 and GPT-5.5) completed without errors.

Task Claude Sonnet 4.6 criteria passed GPT-5.5 criteria passed Reward
Trust-document review 21/23 22/23 0
Transition services agreement review 63/75 64/75 0

Both rewards were 0 because neither judge passed all criteria for either task.

A focused Docker rerun also confirmed Pandoc 3.11 document extraction, an accepted finish call, complete reports from both judges, and sandbox cleanup. Each judge passed 21/23 criteria (reward 0).

With Docker running, add policy_base_url, policy_api_key, and policy_model_name to the gitignored root env.yaml, plus the judge settings below. Use the model IDs accepted by your endpoints. Set default_host in env.yaml to the host address that the sandboxes can reach.

judge_base_url: https://your-judge-gateway.example/v1
judge_api_key: your-judge-key
lab_judges:
  - model_name: claude-sonnet-4-6
  - model_name: gpt-5.5

Alternatively, configure each judge’s model, base URL, and API key separately in env.yaml:

lab_judges:
  - model_name: claude-sonnet-4-6
    base_url: https://your-claude-gateway.example/v1
    api_key: your-claude-key
  - model_name: gpt-5.5
    base_url: https://your-openai-gateway.example/v1
    api_key: your-openai-key

Per-judge settings override shared defaults. Keep only one entry for single judging.

Using the activated environment from the Validation section above, prepare and run those same two tasks from resources_servers/legal_agent_bench/data/example.jsonl:

mkdir -p results/lab-smoke
cat > results/lab-smoke/selected.jsonl <<'JSONL'
{"instance_id": "legal_agent_bench::trusts-estates-private-client__compare-trust-documents-against-client-instructions", "responses_create_params": {"input": []}}
{"instance_id": "legal_agent_bench::corporate-ma__analyze-transition-services-agreement-markup", "responses_create_params": {"input": []}}
JSONL
cat > results/lab-smoke/config.yaml <<'YAML'
config_paths:
  - benchmarks/legal_agent_bench/config_native.yaml
  - responses_api_models/openai_model/configs/openai_model.yaml
  - benchmarks/legal_agent_bench/model_sampling_openai.yaml
  - nemo_gym/sandbox/providers/docker/configs/docker.yaml
use_absolute_ip: true
num_samples_in_parallel: 1
prepare_script_args:
  input: results/lab-smoke/selected.jsonl
  output: results/lab-smoke/prepared.jsonl
lab:
  agent_timeout_seconds: 1200
  verifier_timeout_seconds: 900
  judge_parallelism: 2
legal_agent_bench_environment_server:
  environment_servers:
    harbor:
      artifacts_dir: results/lab-smoke/artifacts
YAML
uv run --active --no-sync gym eval prepare --config results/lab-smoke/config.yaml
uv run --active --no-sync gym env start --config results/lab-smoke/config.yaml

In another terminal with the same environment activated:

uv run --active --no-sync gym eval run --no-serve \
  --config results/lab-smoke/config.yaml \
  --input results/lab-smoke/prepared.jsonl \
  --output results/lab-smoke/rollouts.jsonl --limit 2 --concurrency 1

Inspect the rollout rows and the outputs and judge reports under results/lab-smoke/artifacts. Stop the servers after collection. Scores and completion can vary from run to run.

To exercise the document-label correction, select this row instead of the examples before preparing:

{"instance_id":"legal_agent_bench::litigation-dispute-resolution__categorize-document-production-set-by-relevance-and-privilege","responses_create_params":{"input":[]}}

Compatibility and benchmark impact

The task count increases from 1,749 to 2,010 and the benchmark version becomes 0.2.0. Existing task IDs stay stable where the upstream task is unchanged. LAB Native remains the default harness.

Replace judge_model_name: <model> with lab_judges: [{model_name: <model>}] and remove judge_profile. A missing or empty list will cause an error. Shared judge_base_url and judge_api_key still work.

Scoring mode Reward
full_task (default) Average of each judge's all-criteria task score. Two judges produce 0, 0.5, or 1.
criteria_pass_rate Average of each judge's criterion pass rate.

For example, judges passing 2/2 and 1/2 criteria give 0.5 in full-task mode and 0.75 in criterion mode. A failed judge cannot produce a successful aggregate; measured verifier-budget timeouts retain the shared Harbor behavior.

The refreshed tasks, extraction, and judging change score comparability with old runs.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

@copy-pr-bot

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

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Nov 7, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work 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 7, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 9, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Nov 9, 2026
@cmunley1

Copy link
Copy Markdown
Contributor

A few points:

  1. resources_servers/legal_agent_bench/lab_harbor/judge.py L423-428: _normalize_api_model strips a leading anthropic/, nvidia/, vllm/ or trtllm/. With app.py no longer adding the openai-compatible/ prefix, a judge configured as nvidia/foo is now sent as foo. Gateways that expect the full id will return model-not-found. Could the strip apply only to the prefix this code adds?
  2. resources_servers/legal_agent_bench/prepare.py L302 and L978: the cache locks use fcntl.flock. On Lustre or NFS mounted with noflock this raises, and with localflock it only locks within one node, so the cross-node merge race comes back on cluster scratch. A lock file created with O_CREAT | O_EXCL, or a note on the requirement, would help.
  3. resources_servers/legal_agent_bench/verifier.py L249-256: the two official judges run one after the other, roughly doubling verification time against the 3600 s timeout. Running them concurrently would keep the budget.
  4. The document_ids.py alias table changes how one task is graded relative to upstream Harvey. Worth stating in the README results that scores for that task are not directly comparable.

@rystewart-nvidia

Copy link
Copy Markdown
Contributor Author

@cmunley1 fixed the model prefixes and made the judges run concurrently. Also added notes about filesystem locking and how the document-label fix changes grading

cmunley1
cmunley1 previously approved these changes Nov 13, 2026
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 13, 2026
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
Signed-off-by: Ryan Stewart <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 18, 2026
Signed-off-by: Ryan Stewart <[email protected]>

@athitten athitten 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.

Thank you, LGTM! Code changes are fine post @cmunley1 's approval, mostly merging with main and additional safety guards

@athitten
athitten added this pull request to the merge queue Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44852548409

Merged via the queue into NVIDIA-NeMo:main with commit 8fcea07 Nov 21, 2026
81 of 84 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Nov 21, 2026
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 community-request Issue reported or requested by someone from the community feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants