Skip to content

fix(harbor): clear the previous turn's grading files before the next agent - #4903

Closed
ffrujeri wants to merge 1 commit into
adasif/harbor-m34-multi-turnfrom
ffrujeri/harbor-turn-cleanup
Closed

ffrujeri wants to merge 1 commit into
adasif/harbor-m34-multi-turnfrom
ffrujeri/harbor-turn-cleanup

Conversation

@ffrujeri

Copy link
Copy Markdown
Contributor

What

A multi-step Harbor episode verifies every turn in the agent's own sandbox, and the shared verifier emptied /tests and /logs/verifier only right before it ran. Between two turns, the next turn's fresh agent session therefore worked beside:

  • the previous turn's uploaded tests, hidden ones included (SWE-Interact uploads its root tests/test.patch from the first step on);
  • the previous turn's reward and verifier output;
  • the previous agent's full transcript, which the server writes to /logs/agent/trajectory.json.

Before every turn after the first, the server now empties /tests and /logs/verifier and removes /logs/agent/trajectory.json as root. It uses the command the shared verifier already ran, now a helper (_reset_shared_verifier_dirs). This matches what Harbor's MultiStepTrial does between steps (_reset_shared_step_verifier_dirs, "before any setup or agent code can observe them"). The first turn keeps whatever the image put in /tests, and files the agent wrote itself under /logs/agent stay. A sandbox that can't do the clean-up fails the episode retryably before the next agent session opens.

Why

Reported by Yuhe Zhang in review of #4728 (P1, "Clear the grading files before the next agent turn"). The fix belongs here because the turn loop now lives in M34. Leaving the transcript in place also undoes the "fresh session per step" premise of Harbor's default multi-step trial.

Changes

  • environment_servers/harbor/verifier.py: the shared verifier's directory reset moves into _reset_shared_verifier_dirs, unchanged.
  • environment_servers/harbor/app.py: _prepare_turn calls it for every turn after the first. The comment on the turn loop's failure mapping now covers it.
  • Tests:
    • test_multi_turn.py: the reset runs as root after turn 1's test.sh and before turn 2's activation, and not before turn 1. A sandbox that cannot reset fails the episode (agent stage, retryable) without opening the second agent session.
    • test_verifier_filesystem.py: on a real directory tree, with plain and agent-linked /tests and /logs/verifier, the next agent can read none of the grading files. The agent's own /logs/agent file stays, and a linked root is replaced, never followed.

Validation

  • pytest environment_servers/harbor/tests tests/unit_tests -k "harbor or tb4": 1297 passed, 5 skipped, 4 failed.
    • The 4 failures fail identically on a clean adasif/harbor-m34-multi-turn. They come from this host's umask (test_harbor_build_inputs.py ×3, test_harbor_build_plan.py ×1 expect modes 0644/0755 and get 0640/0750).
    • tests/unit_tests/test_indic_in22.py was ignored: it fails to import benchmarks.indic.in22 on the base too.
  • Mutation check: without the new call in _prepare_turn, both new multi-turn tests fail.
  • pre-commit run on the changed files: passed. DCO sign-off on the commit.

Rollout evidence

A real oracle rollout on Docker, run with gym dataset validate <task> --sandbox docker, on a two-step task built for this check:

  • The top-level tests/ holds a hidden-tests marker.
  • Step 2's reference solution records what it can see in /tests, /logs/verifier and /logs/agent.
  • Step 2's grader writes 1 only if all three were clean.
  • multi_step_reward_strategy = "final", so the episode reward is that check.
Branch What turn 2's agent saw Episode reward
adasif/harbor-m34-multi-turn (6f6c8b0) tests: test.patch test.sh, verifier: .ng-exit reward.txt test-stdout.txt, transcript: present 0.0
this branch (0a261e7) tests: (empty), verifier: (empty), transcript: absent 1.0

Turn 1 scored 1.0 on both. No containers were left behind.

Compatibility

No configuration or data changes. A grader that reads files an earlier turn's verifier left in /tests or /logs/verifier would stop finding them. Harbor's own runtime clears them the same way, so a task that works under Harbor is unaffected.

🤖 Generated with Claude Code

…agent

A multi-step episode verifies every turn in the agent's own sandbox, and the
shared verifier only emptied /tests and /logs/verifier right before it ran.
Between two turns the next agent's fresh session therefore worked beside the
previous turn's uploaded tests (hidden ones included: SWE-Interact uploads
its root tests/test.patch from the first step on), its reward, and the
previous agent's transcript at /logs/agent/trajectory.json.

Before every turn after the first, the server now empties /tests and
/logs/verifier and removes /logs/agent/trajectory.json as root, with the
same command the shared verifier already used, as Harbor's
_reset_shared_step_verifier_dirs does between steps. The first turn keeps
whatever the image put in /tests. Files the agent wrote under /logs/agent
stay. A sandbox that cannot do it fails the episode retryably before the
next agent session opens.

Reported by Yuhe Zhang in review of #4728 (P1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@copy-pr-bot

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

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working labels Oct 22, 2026
@adil-a

adil-a commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Thanks Felipe, this is in the stack now. I ported this commit onto #4819 as its seventh commit, 3c18874, with your authorship kept and the review points folded in: the docstrings, README and the Fern multi-step page now say that Harbor 0.22.0 empties /tests and /logs/verifier only before each step's verifier and that Harbor main does it in step preparation, which this follows, they state the /logs/agent divergence (Harbor empties or moves away the whole directory, here only the server's trajectory.json goes), the failure text names what it was clearing, and the never-runs-beside sentence is scoped to the paths. The three new tests came across unchanged and pass with the rest of the Harbor suites at every commit above. Closing this draft since #4819 carries it.

@adil-a adil-a closed this Oct 22, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants