Skip to content

feat: jobbench environment - #3070

Merged
cmunley1 merged 21 commits into
mainfrom
cmunley1/jobbench
Sep 23, 2026
Merged

cmunley1 merged 21 commits into
mainfrom
cmunley1/jobbench

Conversation

@cmunley1

@cmunley1 cmunley1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

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).
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format/copyright pass).
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

Signed-off-by: Christian Munley <[email protected]>
@copy-pr-bot

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

@cmunley1
cmunley1 marked this pull request as draft September 3, 2026 22:44
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7920ae3

Signed-off-by: Christian Munley <[email protected]>
@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — one correctness blocker on judge-failure handling; the rest is solid.

BLOCKER

Judge-API failures silently score reward=0.0 instead of routing to the failures sidecar (resources_servers/job_bench/app.py:154, inline). The vendored judge_rubric swallows every exception and returns score:0 after retries rather than raising; _judge discards the debug dict that would reveal the failure. nemo_gym/judge.py exists precisely to prevent this: a failed judge call must raise JudgeError so the row is tagged _ng_failure_class="judge_failed", excluded from aggregate metrics, and retried on resume. As written, a Grok/x.ai outage or a bad JOB_BENCH_JUDGE_API_KEY mid-run records genuine 0-reward rows — corrupting eval reports and injecting false-negative training signal. Fix in the inline comment. verified: false limits blast radius today, but this must be fixed before baselining.

RISK

  • Sandbox leak on partial seed failure (app.py:240-265). If sandbox.start() or sandbox.upload() throws, the sandbox is never stopped (only the exec non-zero path calls stop()). At scale this leaks provider sandboxes (ttl 3h) until TTL reclaims them. Wrap the post-start body in try/except that calls sandbox.stop() on any failure.
  • verify pops session state with no default (app.py:158). self._sandboxes.pop(session_id) raises KeyError if seed failed or verify is retried after the entry was already popped; judge_failsafe only catches JudgeError, so this surfaces as an opaque 500 rather than a clean failure row.

NOTE

  • opencode_max_output_tokens defaults to 1_000_000_000 in the Pydantic config (opencode_sandboxed_agent/app.py:394) and is not set in the exemplar YAML. This preserves prior hardcoded behavior, so it is a sensible backward-compat default — flagging only because YAML is meant to be the source of truth for defaults; consider surfacing it in opencode_sandboxed_agent.yaml.
  • Coverage exercises _judge scoring and the empty-output short-circuit well, but there is no test for the judge-call-failure path — add one once the BLOCKER fix lands so a regression re-introducing silent 0-reward is caught.

Async paths look correct (asyncio.to_thread for the blocking judge pool, sandbox calls awaited, no httpx/ray.get). tarfile extraction uses filter="data". License/SPDX headers and vendored attribution are in order.

Comment thread resources_servers/job_bench/app.py Outdated
)
for index, rubric in enumerate(rubrics)
]
results = [future.result()[0] for future in futures]

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.

BLOCKER — judge-API failure silently scores reward=0.0 instead of routing to the failures sidecar.

WHAT BREAKS: judge.judge_rubric catches every exception (transport/timeout/auth/HTTP) and, after max_retries, returns a result with passed=False, score=0 rather than raising (vendor/judge.py:1427-1468). Here future.result()[0] takes that result and discards the debug dict that carries api_exit_code, so a total judge outage is indistinguishable from a genuinely-failing task: build_scorecard computes normalized_score=0.0 and verify() returns reward=0.0.

BLAST RADIUS: This is exactly the anti-pattern nemo_gym/judge.py exists to prevent. A JudgeError is supposed to tag the row _ng_failure_class="judge_failed" so rollout_collection routes it to <output>_failures.jsonl, excludes it from aggregate metrics, and retries it on resume. Because job_bench never raises JudgeError, an x.ai/Grok outage or bad JOB_BENCH_JUDGE_API_KEY mid-run silently records real 0-reward rows — corrupting eval reports and, if used for training, injecting false negative reward signal. Every task judged during the outage is affected.

FIX: Detect judge-call failure and raise JudgeError so judge_failsafe (already wrapping verify) routes the row. Inspect the discarded debug dict — judge_rubric returns (result, debug) and sets debug["api_exit_code"] to 1/2 on failure — and raise when a rubric never got a parsed response, e.g.:

results = []
for future in futures:
    result, debug = future.result()
    if debug.get("api_exit_code", 0) != 0:
        raise JudgeError(f"Job-Bench judge call failed: {debug.get('error') or 'no response'}")
    results.append(result)

Import JudgeError from nemo_gym.judge. Without this, verified: false is the only thing standing between this env and silently corrupted numbers.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7b33310

@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

Comment thread resources_servers/job_bench/app.py Outdated
for index, rubric in enumerate(rubrics)
]
judged = [future.result() for future in futures]
errors = [debug["error"] for _, debug in judged if debug["api_exit_code"]]

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 — verify() misroutes unparseable-but-received judge responses to the failure sidecar.

if debug["api_exit_code"] is truthy for both api_exit_code == 2 (no response after retries: transport/timeout/auth — a genuine call failure) and api_exit_code == 1 (the judge did respond, but its JSON couldn't be parsed after all retries — see vendor/judge.py:1535, api_exit_code = 1 if raw_response else 2).

nemo_gym/judge.py's documented boundary is explicit: "a failed call (transport/timeout/auth/HTTP) → JudgeError → sidecar; a received-but-unparseable response is a legitimate wrong answer (let the parser score it, don't raise)." This code raises JudgeError for the unparseable case too.

WHAT BREAKS: a rubric where the judge returned malformed JSON already carries a valid result (passed=False, score=0). Instead of scoring that rubric as failed, the whole task is raised as JudgeError — routed to <output>_failures.jsonl, excluded from aggregate metrics, and retried on resume. BLAST RADIUS: a single persistently-malformed judge response on any one of N rubrics discards the N−1 correctly-judged rubrics for that task and pulls it out of the reported metric, biasing scores by dropping (rather than penalizing) tasks the judge struggled to grade.

FIX: gate on genuine call failures only — if debug["api_exit_code"] == 2 — so exit code 1 falls through to build_scorecard and is scored as a failed rubric.

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE

New JobBench benchmark: OpenCode-sandboxed agent config + a resources server that runs tasks in a sandbox and scores deliverables with the official vendored weighted-rubric judge. The opencode_max_output_tokens change (replacing the hard-coded 1000000000 with a config field, default preserving old behavior) is clean and API-compatible. Scoring logic is otherwise sound — weighted rubrics, empty-output short-circuit before any judge call, and _judge runs synchronously via asyncio.to_thread so its blocking ThreadPoolExecutor/OpenAI client doesn't stall the event loop.

One RISK, inline on app.py:158:

  • Judge-failure boundary too broad. verify() raises JudgeError for any non-zero api_exit_code, but the vendored judge distinguishes exit code 2 (no response — a real call failure) from 1 (judge responded, JSON unparseable — a legitimate wrong answer per nemo_gym/judge.py's documented contract). Treating code 1 as a JudgeError discards correctly-judged rubrics for the task and pulls it out of aggregate metrics. Gate on == 2.

Note (non-blocking): tests cover _judge scoring, empty-output, and the JudgeError path well; the exit-code-1 case is exactly the boundary the fix above should add a test for. Vendored judge.py is properly attributed with its Apache-2.0 LICENSE and README.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1ebb0f8

@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — new Job-Bench benchmark: resources server + vendored judge + four harness configs + arm64 Node fixes.

Reviewed the scoring path with the hardest scrutiny since wrong rewards corrupt reports/training. It holds up:

  • build_scorecard weights correctly (total_score / max_score), and the _judge receipt separates transport failures (api_exit_code == 2 → raises JudgeError, routed to the failure sidecar via judge_failsafe) from malformed replies (scored 0). The retry classification in judge_rubric uses the terminal attempt, so an early malformed reply can't mask a later API failure — tests cover this.
  • Judge failures are not silently scored as zero — good, this is the correct correctness posture for reward integrity.
  • extract_all_file_contents byte budget is deterministic and UTF-8-safe (no � from mid-codepoint splits), and receipts strip api_base/api_key before retention. Both are tested.
  • Artifact replay (artifact_id) regrades from the frozen request.json/rubrics.json/output.tar.gz rather than re-running the agent, and tar extraction uses filter="data" + a runtime-dir denylist to keep agent-created symlinks/venv out of the grade view.
  • seed_session cleans up its sandbox on any BaseException (incl. CancelledError) while preserving the original error; tests parametrize cancellation and cleanup failure.

Async/dependency conventions check out: the OpenAI judge client is sync and driven off the event loop via asyncio.to_thread + a ThreadPoolExecutor (no httpx-in-async, no ray.get); new deps are declared in requirements.txt; SPDX headers and vendored-judge provenance/LICENSE are present; config carries verified: false as expected for a new server.

Findings:

  • One inline NOTE on _sandboxes eviction only happening in verify() (in-process reference leak on pre-verify failures; no leaked cloud resource).
  • NOTE: pyarrow>=15.0.0 in resources_servers/job_bench/requirements.txt has no importer in the added code (prepare.py uses huggingface_hub + json; the judge reads xlsx via pandas/openpyxl). If it's not a transitive runtime need, drop it; otherwise it's harmless.

Per repo policy, behavior-changing environment work needs real smoke-rollout evidence (not just green unit tests) — confirm that's recorded in the PR body before merge. No blocking correctness or async issues found.

raise

session_id = request.session[SESSION_ID_KEY]
self._sandboxes[session_id] = sandbox

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.

NOTE — self._sandboxes[session_id] is only evicted inside verify() (line 216). If a rollout fails before /verify is reached (e.g. the agent's responses() raises, and HarnessAgent.run() closes the sandbox via _close_run_sandbox and re-raises without calling verify), this entry is never popped and the AsyncSandbox reference is retained for the life of the process.

WHAT BREAKS: _sandboxes grows without bound across failed rollouts; the cloud sandbox itself is freed by the agent's cleanup (and by ttl_s), so this is an in-process memory/reference leak, not a leaked cloud resource.

BLAST RADIUS: negligible for a 65-task eval; accumulates over long/high-failure training runs that reuse one resources-server process.

FIX: register a /close_session route (as osworld/tales do) that pops and stops any stored sandbox, or evict + stop the entry in a finally on the seed→verify lifecycle.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 5987b47

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test db6ac6f

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

SHIP — LGTM, no reliability concerns.

Reviewed the new job_bench benchmark (resources server + vendored judge + harness wiring) and the agent setup_* changes.

Verifier/scoring — reward is the weighted-pass fraction (total_score/max_score, zero-guarded). Judge API failures (terminal transport errors / api_exit_code == 2) correctly raise JudgeError instead of being scored as silent zeros, and the retry classification that keeps a later terminal failure from being masked by an earlier malformed reply is genuinely valuable — both are backed by real behavioral tests (test_judge_failure_is_not_scored, test_judge_retry_classification_uses_terminal_attempt).

Async — the synchronous judge (OpenAI sync client + ThreadPoolExecutor) is offloaded via asyncio.to_thread, so it never blocks the event loop; no httpx.AsyncClient in an async path, no ray.get(). Sandbox cleanup runs under finally/except BaseException and preserves the original error (tested, including cleanup-fails and CancelledError cases).

Extraction safety — filter="data" plus runtime-dir filtering; path traversal raises OutsideDestinationError (tested). Artifact replay uses atomic .partial→final renames and frozen rubrics, and is idempotent.

Agent setup — the npm bin -g→npm prefix -g fix (removed in npm ≥9) and arm64 arch detection are applied consistently across claude_code/codex/pi; HarnessAgent.run return type narrowed to the existing HarnessAgentVerifyResponse.

New imports are declared in requirements.txt, YAML defaults use env-var indirection, and verified: false is set as expected for a new server. Test coverage is strong and asserts real behavior. No blockers or risks.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 351281d

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

@cmunley1
cmunley1 merged commit e035785 into main Sep 23, 2026
41 checks passed
@cmunley1
cmunley1 deleted the cmunley1/jobbench branch September 23, 2026 22:18
@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — new Job-Bench benchmark (resources server + vendored LLM judge + benchmark configs) plus cross-arch fixes to the Node-based agent setup scripts. No blockers found; the verifier logic is sound and the tests are genuinely rigorous.

What I verified

  • Scoring correctness (highest scrutiny): reward == normalized_score == total_score / max_score; max_score == 0 guarded to 0.0. Judge transport failures (api_exit_code == 2) raise JudgeError instead of being scored as zero — this is the right call, it avoids silently corrupting eval numbers, and it's asserted by test_judge_failure_is_not_scored / test_judge_retry_classification_uses_terminal_attempt. Unparseable-but-received responses (api_exit_code == 1) correctly score as a legitimate failure.
  • Async correctness: the heavy synchronous work (_judge, file extraction/conversion, the ThreadPoolExecutor judge fan-out) and resolve_task_path are offloaded via asyncio.to_thread. No httpx.AsyncClient, no ray.get() in async paths. The judge uses the OpenAI SDK from within worker threads, which is acceptable here.
  • Path safety: tar.extractall(..., filter='data') plus explicit runtime-dir filtering; test_verify_collects_regular_outputs_without_runtime_links asserts traversal (../escape.txt) raises and that symlink/hardlink members under venv/ are excluded.
  • Crash-safety / replay: partial-then-rename writes for request.json/result.json/output.tar.gz with os.fsync, artifact_id pinned to ^[0-9a-f]{64}$, replay regrades from the frozen rubrics.json (not the live task dir). Idempotent-replay and mid-judge-restart paths are both covered by tests.
  • API compatibility: narrowing HarnessAgent.run's return annotation to HarnessAgentVerifyResponse (a BaseVerifyResponse subclass) is source/behavior compatible.
  • Dependency hygiene: new deps (huggingface-hub, mammoth, pandas, pdfplumber, python-pptx, openpyxl, openai) are declared in the server's requirements.txt; heavy converters in vendor/judge.py are lazily imported and degrade to an [ERROR: ... not available] string rather than crashing grading. verified: false correctly set on the new config.
  • Judge secret hygiene: the retained judge-receipt.json whitelists debug keys (parse_status, api_exit_code, raw_response, error, vision_used, attached_images) and deliberately drops api_base/api_key; test_judge_failure_is_not_scored asserts secrets don't leak into the receipt.

Non-blocking

  • One inline NOTE: tarball extraction + artifact writes in verify() run inline on the event loop while the rest of the heavy work is offloaded; at concurrency: 32 this can throttle verify throughput on large outputs. Optional asyncio.to_thread wrap. Does not affect scores.

Rollout evidence / smoke results are the human author's to confirm per the repo's behavior-changing-work bar (green unit tests alone aren't sufficient for a new scoring env); I can't run model compute here.

Comment on lines +225 to +254
if saved is not None:
rubrics_source = await asyncio.to_thread(resolve_task_path, body.rubrics_file)
shutil.copyfile(rubrics_source, saved / "rubrics.json")
pending = saved / "request.partial"
pending.write_text(body.model_dump_json())
pending.replace(saved / "request.json")
result = await sandbox.exec("tar -czf /tmp/output.tar.gz -C /workspace/output .")
if result.return_code != 0:
raise RuntimeError(
f"Failed to collect Job-Bench output: {result.stderr}; output={(result.stdout or '')[-4000:]}"
)
partial = archive.with_suffix(".partial")
await sandbox.download("/tmp/output.tar.gz", partial)
with partial.open("rb") as stream:
os.fsync(stream.fileno())
partial.replace(archive)
output_dir = local_dir / "output"
output_dir.mkdir()
with tarfile.open(archive, "r:gz") as tar:
# Agent-created environments may contain links outside the output tree.
runtime_dirs = {"venv", ".venv", "node_modules", ".git", ".cache", "__pycache__"}
members = (
member
for member in tar
if (member.isfile() or member.isdir())
and not runtime_dirs.intersection(
Path(member.name).parts if member.isdir() else Path(member.name).parts[:-1]
)
)
tar.extractall(output_dir, members=members, filter="data")

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.

NOTE (operability): the tarball extraction (tar.extractall, line 254) and the artifact writes (shutil.copyfile/write_text, lines 227-230) run inline on the event loop, unlike the heavy judge work which is correctly offloaded via asyncio.to_thread. WHAT: at concurrency: 32, extracting/writing a large /workspace/output archive blocks all other verify coroutines on this server for the duration. BLAST RADIUS: reduced verify throughput, not incorrect scores. FIX (optional): wrap the extraction+copy block in asyncio.to_thread, consistent with _judge and resolve_task_path. Minor — author's call.

This branch was previously deployed

1 inactive deployment
public — 351281d4 Deployed Sep 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #3627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant