Repository navigation
Harbor: a non-zero agent exit after a graded run is a warning, not a failed rollout - #1566
Open
sergiopaniego wants to merge 1 commit into
Open
sergiopaniego wants to merge 1 commit into
sergiopaniego wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
--harness opencode, most rollouts came back asFAILED (NonZeroAgentExitCodeError)even when the agent finished normally and the verifier scored them. A trial exception now stays a[WARN]finding when it is only a non-zero exit code and the verifier produced a reward. Real agent errors and ungraded runs still fail.Type of Change
What was wrong
In a 500-rollout run with OpenCode, 306 rollouts were reported as
FAILED (NonZeroAgentExitCodeError), solved and unsolved alike, withreward=1.00,atif=matchand full turns. Sinceopenenv harbor rolloutexits with0 if all(r.ok ...) else 1, scripts saw good batches as failures.Root cause
opencode run --format=jsonexits 1 on runs that finished. In hf-sandbox trials (opencode 1.19.5) every completed run exited 1: the stream ends onstep_finishwithreason: "stop", there is noerrorevent and stderr is empty. Harbor runs the command underset -o pipefail(harbor/agents/installed/base.py:1033), turns a non-zero status intoNonZeroAgentExitCodeError(base.py:960-996), records it on the trial and still runs the verifier. In opencode'sruncommand (packages/opencode/src/cli/cmd/run.ts,src/index.ts) exit code 1 is only set on asession.errorevent, a failed prompt call or an uncaught error, and none of those shows up in these logs, so the exact source inside opencode is still unclear and no flag changes it.run_rollouttreated anyexception_infoon the trial result as a failed rollout (src/openenv/harbor/rollout.py:575-579), even when the verifier had already produced the headline reward.Fix
In
run_rollout, a trial exception is kept as a[WARN]finding instead of failing the rollout when all of these hold:NonZeroAgentExitCodeError(subclasses such asApiErrorandApiRateLimitErrorstill fail)Command failed (exit N)(Harbor'sOpenCode emitted error event(s)still fails)"type":"error"event (a run cut short by the provider still fails)The capture gates that run afterwards are unchanged, so a graded rollout with an empty or invalid capture still fails, and a rollout the verifier never graded still fails with
NonZeroAgentExitCodeError.RFC Status
Test Plan
New
tests/envs/test_harbor_agent_exit_code.py(8 tests) drivesrun_rolloutwith a fakeTrialand a fake capture:ok=True, one[WARN]finding, noerrororexception_typeok=FalsewithNonZeroAgentExitCodeErrorApiRateLimitError,OpenCode emitted error event(s), an exit with an opencode error event, andAgentTimeoutError: still fail even with a reward3 of the 8 fail on main and pass with the fix. Across
tests/envs/test_harbor_*.pythe only failure (test_harbor_capture_server.py::test_start_refuses_a_port_held_by_a_non_capture_listener) also fails on main.ruff format,ruff checkandusortare clean.Claude Code Review
N/A
Note
Medium Risk
Changes rollout success semantics for Harbor trials with exceptions, which could mask some edge-case failures if the heuristic misclassifies; mitigated by narrow string/type checks and new tests.
Overview
Harbor rollouts stop failing solely on a spurious non-zero agent exit when the verifier already produced a headline reward.
run_rolloutnow routes that case through new helpers that recognize plainNonZeroAgentExitCodeErrormessages without an opencode"type":"error"event, keepok=True, preserve the reward, and add a single[WARN] agent exited non-zero after a graded runfinding with a trimmed first-line summary. Ungraded trials, API/provider errors, streams that include error events, and subclasses of the exit-code error still mark the rollout failed exactly as before; capture validation and trainability gates remain unchanged.Adds focused pytest coverage that monkeypatches
Trial, capture export, and trace reconciliation to assert the warning path for graded exits, continued failures without rewards or on real errors, and failure when the capture is empty even if graded.Reviewed by Cursor Bugbot for commit 9966d7f. Bugbot is set up for automated code reviews on this repo. Configure here.