Skip to content

feat: workspacebench env - #3089

Merged
cmunley1 merged 13 commits into
mainfrom
cmunley1/workspacebench
Sep 24, 2026
Merged

cmunley1 merged 13 commits into
mainfrom
cmunley1/workspacebench

Conversation

@cmunley1

@cmunley1 cmunley1 commented Sep 4, 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]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
@copy-pr-bot

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

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 6a60856

],
cwd=evaluation_dir,
check=True,
)

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 — judge subprocess can hang the run and fails opaquely. subprocess.run(..., check=True) runs the upstream agent-as-a-judge (an LLM-backed process) with no timeout, no capture_output, and no errors="replace". Two problems:

  1. No timeout. This runs inside asyncio.to_thread in verify(). If the judge hangs (stuck LLM call, network stall), it holds the worker thread indefinitely — the verify never returns and the eval/training run stalls. verify() is on the critical scoring path.
  2. No captured output. On non-zero exit, check=True raises CalledProcessError with no stdout/stderr, so the operator sees an opaque failure. CLAUDE.md requires decoding subprocess output with errors="replace".

FIX: pass timeout=, capture_output=True, text=True, errors="replace", and surface stderr in the raised error.

install_str = (
"mkdir -p $HOME/.opencode/bin && "
f"cp {quote(self.config.remote_opencode_binary_path)} $HOME/.opencode/bin/opencode"
)

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 — copied binary may not be executable. This new branch cps the binary to $HOME/.opencode/bin/opencode but never chmod +x it. If remote_opencode_binary_path points at a file whose executable bit isn't preserved through upload (many sandbox upload paths strip mode bits), the subsequent opencode invocation fails with "permission denied" and the whole rollout errors out. The script-based branches run the binary via bash <installer>, so they don't rely on the bit; this direct-cp path does.

FIX: append && chmod +x $HOME/.opencode/bin/opencode to the copy command.

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — new Workspace-Bench environment (verifier + OpenCode binary-copy path). The scoring math is correct (reward = passed/total, sum(item["passed"])), sandbox lifecycle is cleaned up on both the seed and verify error paths, and there's a real unit test on _judge. No async-HTTP or ray.get() violations. Findings are reliability/operability, not correctness of the score itself:

  • RISK (app.py:146) — judge subprocess.run(check=True) has no timeout, no captured output, no errors="replace". A hung judge stalls verify() on the critical path; a failed judge raises opaquely. Violates the CLAUDE.md subprocess-decoding convention.
  • RISK (app.py:166) — no asyncio.Semaphore bounding concurrent judge subprocesses. CLAUDE.md and sibling servers (scicode, bigcodebench) gate this on num_processes; unbounded fan-out can exhaust the resources-server host.
  • RISK (opencode_sandboxed_agent/app.py:690) — the new cp install branch never chmod +x the copied binary; if the executable bit doesn't survive upload, every rollout fails "permission denied".
  • NOTE (app.py:173) — empty rubrics silently scores 0.0, indistinguishable from a legit all-fail; consider erroring on total == 0.

None block a gated/experimental rollout (verified: false), but the timeout and semaphore should land before this runs at scale.

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

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test da44604

@cmunley1

cmunley1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/claude review

config: WorkspaceBenchConfig

def model_post_init(self, context: Any, /) -> None:
self._sandboxes: dict[str, AsyncSandbox] = {}

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 — leaked sandboxes on abandoned sessions. self._sandboxes accumulates one live OpenSandbox per seed_session, but the server has no shutdown hook and only removes entries in verify() (line 159, .pop(...) with no default). Any session that is seeded but never verified — agent crash, aborted run, or a verify call for a session that was never seeded (KeyError → sandbox never stopped) — leaks a sandbox until its ttl_s (10800s / 3h in the config) expires.

BLAST RADIUS: at eval scale, aborted/failed tasks strand paid OpenSandbox instances for hours; a run that seeds N tasks and dies mid-flight leaks all of them.

FIX: mirror the pattern in resources_servers/swebench_pro/app.py — override setup_webserver() to wrap the lifespan and add a shutdown() that stops every sandbox in self._sandboxes, and use .pop(session_id, None) in verify so a missing session doesn't raise before the finally: stop().

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE

New workspace_bench env (resources server + benchmark + one-line change to the opencode agent's install path). Verifier math is sound: reward = passed / total over upstream judge rubrics, with a guard against zero rubrics. Async paths are clean — the blocking upstream judge subprocess is correctly wrapped in asyncio.to_thread under an asyncio.Semaphore, no httpx, no ray.get. The opencode-agent change (copy a pre-provided binary into $HOME/.opencode/bin when only remote_opencode_binary_path is set) is additive and lands on the PATH used downstream.

Findings (both inline):

  • RISK — sandbox leak. self._sandboxes has no shutdown hook and is only drained in verify(). Seeded-but-never-verified sessions (agent crash, aborted run, or verify for an unseeded session → KeyError before stop()) strand a paid OpenSandbox for up to ttl_s = 3h. Add a lifespan shutdown() that stops all sandboxes and use .pop(session_id, None) in verify, per swebench_pro.
  • NOTE — placeholder rollouts + no end-to-end verifier test. example_rollouts.jsonl is 5 <PLACEHOLDER ROW> lines that pass validation's line-count check; test_app.py mocks the judge subprocess. The real seed→collect→judge→score path is unexercised. verified: false is set correctly, so this is a gate on graduation, not merge.

No blockers. Config defaults (judge_timeout_s, num_processes) as Pydantic field defaults match the peer swebench_pro convention. Not approving; leaving the leak fix to the author's call before this env sees real scale.

Signed-off-by: Christian Munley <[email protected]>
@cmunley1
cmunley1 force-pushed the cmunley1/workspacebench branch from d6f7548 to 0289136 Compare September 4, 2026 22:17
Signed-off-by: Christian Munley <[email protected]>
Signed-off-by: Christian Munley <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 7989b5d

@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 9f053a4

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

provider = create_provider(resolve_provider_config(self.config.sandbox_provider, get_global_config_dict()))
sandbox = AsyncSandbox(provider)
try:
await sandbox.start(SandboxSpec(**self.config.sandbox_config))

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 (attribution asymmetry): seed_session builds its SandboxSpec by merging resolve_provider_metadata(...) (e.g. opensandbox's default_metadata: {sandbox-api: opensandbox-sdk}) plus a task-id label, but the judge sandbox here is SandboxSpec(**self.config.sandbox_config), so it never gets the provider's default_metadata. WHAT: judge sandboxes are missing the attribution labels the task sandboxes carry. BLAST RADIUS: cosmetic — cluster-side sandbox attribution/cleanup filters won't match judge pods; no correctness impact. FIX (optional): mirror the seed path and merge resolve_provider_metadata(self.config.sandbox_provider, get_global_config_dict()) into the judge spec's metadata.

@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — solid new benchmark environment, closely modeled on the merged job_bench server. Reviewed the whole diff against repo conventions.

What I verified (no blockers):

  • Anti-cheat / frozen inputs: judge grades snapshotted originals (data/ from input.tar.gz), not the live /workspace/input; extraction filters to output/ real files only (filter="data" + Path(member.name).parts[:1] == ("output",)), so symlinks into the sandbox and ground-truth left in input/ can not reach the judge. This is the correctness core and it holds.
  • Reward math: sum(item["passed"]) / total with an empty-rubric guard; committed rollout evidence confirms passed is boolean. Parse-failure verdicts score 0 (matching upstream); any other judge error raises JudgeError → routed to the failures sidecar via judge_failsafe, correctly matching nemo_gym.judge semantics (failed call ≠ wrong answer).
  • Async correctness: all sandbox I/O awaited; blocking tar/file work offloaded via asyncio.to_thread; judge concurrency bounded by asyncio.Semaphore(num_processes). No httpx in async paths, no ray.get.
  • Crash-safe artifacts: .partial + atomic replace() + os.fsync for workspace/request/result; replay refuses artifacts lacking frozen inputs ("legacy replay is unsafe"). Good.
  • Credential hygiene: judge receipts strip baseUrl/apiKey, keep only verdict fields; judge.yaml (holding apiKey) is not retained. Tests assert secrets never appear in receipts or retention logs.
  • Cleanup: sandbox .stop() + reference-dir cleanup in finally; server lifespan tears down leaked sandboxes/dirs on shutdown. Seed rolls back its reference dir + sandbox on any BaseException.
  • Tests: unusually thorough — 12 verify modes × cleanup-fail matrix, seed cancellation, judge isolation, path resolution. Assert real behavior, not pass-throughs.
  • Imports resolve against the public sandbox API; new dep huggingface-hub declared in requirements.txt; SPDX headers present; verified: false set.

Minor (author's call): one inline NOTE on judge-sandbox metadata attribution asymmetry vs the task sandbox — cosmetic (cluster attribution/cleanup labels), no correctness impact.

Per repo policy, confirm real smoke-rollout evidence was captured with a live model + judge (the committed example_rollouts.jsonl looks like exactly that) before flipping verified.

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

Copy link
Copy Markdown
Contributor Author

/ok to test bebc749

@cmunley1

Copy link
Copy Markdown
Contributor Author

/claude review

@cmunley1
cmunley1 merged commit 1c82610 into main Sep 24, 2026
41 checks passed
@cmunley1
cmunley1 deleted the cmunley1/workspacebench branch September 24, 2026 00:28
body.artifact_id = body.artifact_id or hashlib.sha256(session_id.encode()).hexdigest()
saved = self.config.artifact_root / body.artifact_id
if replay:
if not (saved / "input.tar.gz").is_file():

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 — replay of a natively-failed artifact crashes with an opaque 500.

The exec_error/download_error path persists input.tar.gz + request.json to saved but never writes workspace.tar.gz (confirmed by the test at test_app.py:176-179). A later artifact_id replay of such an artifact passes this input.tar.gz guard, finds no result.json, then prepare_judge_input (line 264) opens the missing saved/workspace.tar.gz → uncaught FileNotFoundError → 500.

BLAST RADIUS: only manual regrade of an artifact whose original rollout failed natively (the framework doesn't pass artifact_id in normal eval flow), so low. FIX: extend this guard to also require (saved / "workspace.tar.gz").is_file(), raising a clear "artifact has no collected workspace to regrade" message instead of letting the tar open crash.

@claude

claude Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE

New self-contained workspace_bench benchmark environment (resources server + four harness configs + prepare script). No shared library code is touched, and the test suite is unusually thorough — it exercises seed/verify/judge, artifact persistence and idempotent replay, restart recovery, credential-scrubbing of judge receipts, and symlink exclusion during grading.

Verifier correctness looks sound: reward is passed/total over judge rubrics; a genuinely empty rubric set raises rather than silently scoring 0; judge infrastructure failures raise JudgeError (routed to the failures sidecar by judge_failsafe) while only unparseable verdicts fail their rubrics, matching upstream. Async patterns are correct — subprocess-bound work goes through asyncio.to_thread, judge concurrency is bounded by asyncio.Semaphore, and sandbox lifecycle is cleaned up in finally/lifespan with cleanup errors logged not swallowed silently. Inputs are frozen before the agent runs so the judge compares against originals, and grading extracts only real files under output/ (never symlinks into the sandbox).

One low-severity edge case flagged inline: replaying an artifact whose original rollout failed natively (no workspace.tar.gz persisted) passes the input.tar.gz guard and then crashes with an opaque FileNotFoundError/500. Not on the normal eval path (the framework doesn't pass artifact_id), so NOTE-level.

Two minor observations, author's call:

  • task_data.py's TaskData model is defined but unused within the package (matches other servers' convention, so likely intentional as the framework's task-schema hook).
  • _judge builds SandboxSpec(**sandbox_config) directly, omitting the provider default_metadata that seed_session merges in via resolve_provider_metadata. The sandbox-api tag appears cosmetic/attribution-only, so functionally fine, but the judge sandbox will lack that label.

Per the repo quality bar, this is behavior-changing environment work: confirm real smoke rollouts against a live model + judge were run and the agent/verifier behavior inspected (green unit tests alone aren't sufficient here).

This branch was previously deployed

1 inactive deployment
public — bebc7492 Deployed Sep 24, 2026 by copy-pr-bot[bot] via release / finalize / notify #3633
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