Repository navigation
fix(harbor): preserve verifier completion and image startup - #5240
init-nikhil wants to merge 3 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Validation checkpoint for Local checks:
Real-model checks use the original N4 SFT7000 model on HSG, with global sampling overrides unset. Each case asks the agent to write a nonce file and report its directory, then independently checks the file, runs the real SWE verifier, repeats verification to test replay, and audits exact-run cleanup. These checks are infrastructure correctness evidence, not benchmark scores.
Every passing case checked top-p 1, an 8192-token harness ceiling against a 16384-token request, disabled compaction/pruning, successful verifier replay, and zero remaining owned sandboxes. Claude/pi T1 used source Known remaining gates:
The metadata-terminal fallback is cherry-picked from the core commit in #5180, with a separate NOOA adaptation to avoid overriding a child-authored terminal answer. No colleague review is requested while these gates remain open. |
|
Claude capture follow-up for head When automatic compaction is disabled, the CLI now receives an explicit session name. This suppresses its background title-generation model request, which previously could outlive the capture proxy and correctly mask an otherwise successful rollout. Capture safeguards remain enabled. Both real-model reruns passed on original N4 SFT7000 with source
Each case verified top-p 1, the 8192-token harness ceiling against a 16384-token request, disabled compaction, actual file write/read and directory tools, explicit response-ID terminal attribution, real verifier execution, identical verifier replay, and zero remaining owned sandboxes. These are correctness checks, not benchmark scores or learning-parity results. Validation: 62 focused Claude tests passed; |
4c346ec to
de347eb
Compare
15abccc to
d227a9b
Compare
DESCRIPTION FOR AGENTSCodex-generated description; not a completed review or human approval. Starting head:
Bare-shell entrypoints receive a command string through Tests cover measured zero versus incomplete verification, retry bounds, artifact reuse, cleanup failures, completion-metric exclusion, real shell execution, and line endings. Verify the reported 729-test/pre-commit evidence and obtain current-head runtime evidence. Historical comments describe earlier, broader implementations. Process after #5112. Review this layer against its updated immediate parent, and record all evidence against the final remote head. |
Signed-off-by: Nikhil Deshmudre <[email protected]>
Signed-off-by: Nikhil Deshmudre <[email protected]>
d227a9b to
2a1cfad
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
A failed verifier attempt can supply a later retry's reward through downloaded diagnostic files, producing a false completed score. The inline findings also cover bare-CR instruction loss, a deterministically failing endpoint assertion, missing multi-turn completion status, and configuration documentation.
RISK — Supply current-head model/sandbox smoke evidence
The PR description explicitly leaves current-head runtime validation pending. The historical rollout comments concern earlier heads and don't establish that the changed completion/retry path works with a real provider. The reported 729 tests and pre-commit checks don't replace the representative model rollout required by AGENTS.md.
Please attach representative model/sandbox rollout evidence for the final head, inspecting the agent's output and verifier behavior. Exercise the separate-verifier retry path with the completion key enabled: an incomplete first attempt followed by a completed measured zero should return reward 0, mask_sample=False, and evaluation_completed=True, with distinct verifier sandboxes, identical captured artifacts, retained attempt logs, and confirmed cleanup. Also retain a control with the completion key unset: a missing reward remains a measured zero rather than becoming masked. Record the configuration, model/provider, source revision, results, and artifact locations. These are acceptance checks to perform, not results established by this review.
I inspected all eight changed files and their directly affected scoring, lifecycle, deadline, loading, and endpoint paths. All three delegated inspections terminated; I independently covered the retry/lifecycle topic because its detailed report wasn't available. This was a static review: I couldn't execute tests, pre-commit, runtime rollouts, or CI. Suggested code needs verification before adoption.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
environment_servers/harbor/verifier.pyline 685: BLOCKER — Reserve retry logs outside the previous attempt's downloaded outputWith one retry enabled, let the first verifier write an incomplete root reward and a diagnostic
retry-1/reward.jsoncontaining{"reward":1,"evaluation_completed":1}. The optional log download extracts that subdirectory into the first attempt's host logs. This branch then reuses it withexist_ok=True. If the fresh second verifier exits normally without writing a reward, collection leaves the existing reward file untouched and parses the first attempt's diagnostic as the second attempt's result. The episode incorrectly returns reward 1, unmasked and completed. A diagnostic regular file namedretry-1instead makesmkdir()raise and loses the graded result.Each attempt's reward directory must be fresh and outside every previous attempt's extraction root. Both production callers already reserve the initial directory, and attempt records carry each directory explicitly, so replace these two lines with:
attempt_logs = logs_dir if attempt == 0 else self._reserve_logs_dir()This preserves the initial artifact staging directory and archive reuse while giving each retry an independently reserved directory.
Proposed regression: extend the existing fake-verifier setup with the nested diagnostic above, followed by a verifier with no reward. Expect both attempts masked, final reward 0 and completion false—not the planted success. Repeat with a regular diagnostic file named
retry-1; verification must still return a bounded masked result. Retain the existing completed-zero/no-retry assertions and artifact-reuse and cleanup assertions. Source reasoning only; I haven't executed these checks. -
nemo_gym/data/tasks/harbor/task.pyline 388: RISK — Preserve canary stripping for bare-CR instructionsReading bytes preserves CRs, but splitting only on LF stops recognizing bare-CR line boundaries. For example,
b"# HARBOR-CANARY marker\r\rDo the thing.\r"becomes one string._CANARY_LINEmatches the entire heading-prefixed string, soread_instruction()returns an empty prompt. An HTML canary with the same separators instead remains in the prompt. Previously, text-mode newline conversion removed only the canary and separating blank line. This affects both single-step loading and step loading.Recognize LF, CRLF, and bare CR without translating retained terminators. Replace this read with:
with path.open(encoding="utf-8", newline="") as stream: lines = stream.readlines()
Keep the existing removal loops and change the final return to
return "".join(lines).Proposed acceptance: heading and HTML bare-CR canaries followed by
\r\rDo the thing.\rmust return"Do the thing.\r"; multiple leading canaries must still disappear. Retain all existing instruction assertions, including mixed CRLF/CR preservation and leading blank lines when no canary exists. The suggested correction is source-reasoned, not executed. -
environment_servers/harbor/tests/test_app.pyline 298: RISK — Assert terminal attribution where Harbor serializes itThe new
terminal_id="served-response"case supplies the ID under the agent response'smetadata, but these assertions read the episode result's top level. Harbor constructs the result withresponse=agent_response; neither its result model nor the parent contract promotes that metadata field. Consequently, the added case comparesNonewith"served-response"and fails despite a successful endpoint response.Unless a separate top-level API is intended, replace these assertions with:
metadata = payload["result"]["response"].get("metadata") or {} assert metadata.get("terminal_response_id") == terminal_id assert ("terminal_response_id" in metadata) is (terminal_id is not None)Acceptance: both parameter values return HTTP 200 and reward 1; the supplied ID survives under
result.response.metadata, while the absent case doesn't manufacture one. Retain the episode-identity, sandbox-handle exclusion, and cleanup assertions. I haven't executed this test. -
environment_servers/harbor/app.pyline 488: RISK — Propagate completion status through the multi-turn roll-upEnable
verifier_completion_key="evaluation_completed"for two steps. If their verifiers write{"reward":1,"evaluation_completed":1}and{"reward":0,"evaluation_completed":0}, the second turn correctly reports completion false and masks the episode, but this roll-up omits the completion field. The episode constructor leaves the new top-level field atNone, so serialization removes it. Fully completed multi-turn episodes also omitTrue. The mask still protects the scalar score; callers lose the configured completion-status contract.Propagate status in
roll_up_turns()or_run_turns(): completion-gated episodes must report false for an incomplete verifier and true when every executed verification completed. Preserve absence for legacy turns whose status isNone; don't derive their completion solely fromnot mask_sample. Keep the existing measured treatment of later step-preparation failures. Their completion-status meaning needs an explicit decision, so a blanket replacement patch would be premature.Proposed checks, for both
meanandfinal: the incomplete second turn yields top-level completion false, mask true, and reward 0. Two completed turns, including a measured zero, yield top-level completion true with unchanged rewards/components. With the gate disabled, retain absent status and the existing missing-reward scoring and preparation-failure assertions. These checks weren't executed. -
environment_servers/harbor/app.pyline 383: NOTE — Suggest documenting the opt-in completion and retry contractThese switches change whether missing/invalid rewards and timeouts count as measured zeros, but the configuration table lists neither option, and the verifier guide states the measured-zero rule without this exception. Users can't discover the required reward shape or scoring effect there.
Add a minimal configuration example for
verifier_completion_keyandinconclusive_verification_retries, their defaults, and{"reward":0,"evaluation_completed":1}as a completed measured zero. Explain completion-metric exclusion, masking, fresh separate-sandbox retries using captured artifacts, and the lack of shared-sandbox retries. Keep the existing reward-file and timeout rules as the default when the completion key is unset.Acceptance is a documentation inspection: both keys and their limits appear in the configuration guide, and the verifier guide distinguishes completed zero, incomplete verification, and disabled-contract behavior. No documentation build was executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Signed-off-by: Nikhil Deshmudre <[email protected]>
zyzhou5
left a comment
There was a problem hiding this comment.
Pls update the pr description and also the harbor doc for the new settings (verifier_completion_key, inconclusive_verification_retries).
Also during my own test, harbor path requires reproducing the resources server's seed-time init (removing the hidden tests, creating the git baseline commit, the anti-cheat scrub, and setting the git identity) so it is comparable to gym resource server path. Is this sth we want to include here?
| # Optional reward.json metric that must equal 1 before a score is usable. A missing | ||
| # metric/reward or verifier timeout is inconclusive when this contract is enabled. | ||
| # Unset preserves Harbor's measured-zero behavior for missing/invalid rewards. | ||
| verifier_completion_key: str | None = Field(default=None, min_length=1) |
There was a problem hiding this comment.
Should we turn on/off completion check per dataset instead of at server level so that it can work appropriately no matter whether evaluation_completed is there in test.sh?
| extras["verifier_logs_dir"], | ||
| ) | ||
| completion_key = self.config.verifier_completion_key | ||
| if completion_key is not None and ( |
There was a problem hiding this comment.
With the completion check on, any kill at the time limit excludes the attempt, even if the grader had already finished and written evaluation_completed: 1. Could we treat it as a timeout only when no completed result was written?
| "verifier_logs_dir": str(attempt_logs.resolve()), | ||
| } | ||
| ) | ||
| if not outcome.get("mask_sample", False): |
There was a problem hiding this comment.
Retries currently rerun every excluded attempt, including timeouts and missing/invalid result files, which a fresh sandbox won't fix. Could we retry only sandbox/provider failures, as upstream Harbor do?
| # The episode key stays reserved until the episode's final cleanup, which releases it without | ||
| # stopping the agent side again. | ||
| await session.stop_agent_side() | ||
| self._write_cleanup_receipt(logs_dir, "agent", session.sandbox) |
There was a problem hiding this comment.
Nit: this receipt is only written after stop_agent_side() succeeds, so it always reports a confirmed teardown; a failed stop leaves no receipt.
| if _verifier_gets_overlay(task, separate): | ||
| budget += task.config.environment.build_timeout_sec | ||
| retry_budget += task.config.environment.build_timeout_sec | ||
| budget += self.config.inconclusive_verification_retries * retry_budget |
There was a problem hiding this comment.
Nit: retries grow the task budget here, but a single-step episode's overall deadline stays at the default (L878-L879), so with long grading times a retry can run past it and fail the episode. Not sure if this is a problem we need to fix or just document.
| """Retry an inconclusive verdict without recapturing the stopped agent's artifacts.""" | ||
| attempts: list[dict[str, Any]] = [] | ||
| try: | ||
| for attempt in range(self.config.inconclusive_verification_retries + 1): |
There was a problem hiding this comment.
Nit: retries now reach the "previous turn's verifier sandbox could not be stopped" message (L760) for single-step tasks too, where it means the previous attempt.
Depends on #5112.