Skip to content

fix(harbor): apply agent outcome policy before verification - #4950

Closed
ffrujeri wants to merge 1 commit into
mainfrom
ffrujeri/harbor-agent-outcome-policy
Closed

ffrujeri wants to merge 1 commit into
mainfrom
ffrujeri/harbor-agent-outcome-policy

Conversation

@ffrujeri

@ffrujeri ffrujeri commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

The Harbor environment server graded every agent response, including failed ones whose harness had reported the
cause in response.metadata.ng_agent_outcome. A Codex response that failed with a stream error reported as
unknown was handed to test.sh on the half-finished sandbox and recorded as a real 0. single_agent_turn
already routes these responses through agent_outcome_policy; Harbor ignored it.

  • Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy from
    environment_servers/single_agent_turn/app.py into nemo_gym/agent_outcome.py, next to AgentOutcome, so both
    environment servers share one implementation. No behavior change for single_agent_turn.
  • Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it after the agent session closes and
    before verification. retry and fail become a stage: agent episode failure (non-terminal and terminal
    respectively) that keeps the partial response and the agent's observations; verify runs test.sh as before.
  • Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import location.
  • Docs: the harness guide now says the policy applies to harbor too; the Harbor README and the module docstring
    describe the rule.

No issue: found while pipecleaning Terminal-Bench 4 through the Harbor environment server.

Compatibility and result impact

Harbor runs whose harnesses report ng_agent_outcome (Codex, OpenCode, Pi, Hermes) now exclude retryable or
malformed failed responses from grading instead of scoring them 0. Scores on affected tasks can go up because fake
zeros leave the denominator; those rollouts appear in rollouts_failures.jsonl and are retried on resume up to
NEMO_GYM_MAX_ROLLOUT_ATTEMPTS. Responses without the metadata, and completed or incomplete responses, are
verified exactly as before. The default policy can be overridden with agent_outcome_policy in the Harbor
environment server config, the same schema single_agent_turn uses.

Validation

  • pre-commit run --all-files: passes.
  • environment_servers/harbor/tests: 303 passed, including new episode-level tests for unknown and
    model_transport_error (retried, not verified), malformed metadata (terminal, not verified), agent_limit
    (verified) and a configured override (unknown: verify).
  • environment_servers/single_agent_turn/tests: 96 passed. tests/unit_tests/test_agent_outcome.py: 40 passed.
  • Codex, OpenCode and Pi sandbox tests: 178, 170 and 201 passed. Hermes tests need the hermes-agent package
    from that agent's venv and were not run locally.
  • tests/unit_tests: 21 failures in OpenSandbox, sandbox transfer and benchmark listing tests, identical to the
    set failing on origin/main (cac55a5fc) in the same local environment; none touch this change.

Rollout evidence

Terminal-Bench 4 on the Harbor environment server, Codex agent, n35-super-ga on vLLM (4×GB300), OpenSandbox,
1 repeat, this commit cherry-picked onto the parity branch. 10 tasks: the 6 tasks whose Codex rollouts failed with
ng_agent_outcome: {"failure_kind": "unknown"} in the baseline run, plus 4 controls.

Tasks Baseline (without this change) With this change
freecad-platform-drawing, layout-config-recreation, layout-config-recreation2, cad-model, legacy-utility-triage, music-harmony test.sh ran on the partial sandbox; 18 of 18 rollouts scored 0 6 of 6 rollouts recorded as non-terminal stage: agent failures; test.sh not run; partial response and observations kept
bun-sourcemap-leak, mvcc-lsm-compaction (completed), atrx-vep-crispr, cargo-flight-dispatch (incomplete) verified, reward 0 verified, reward 0

The failing tasks fail deterministically: Codex's image tool returns an input_image in a function_call_output,
which the Responses-to-Chat Completions converter refuses by default. That is the documented
drop_unrepresentable_request_fields: false default on vllm_model, not a bug: runs that want a text placeholder
for tool images set it to true. Without it these tasks are retried and stay ungraded rather than counting as zeros.

Harbor graded failed agent responses as real zeros even when the harness
reported a retryable cause in ng_agent_outcome (for example Codex stream
disconnects reported as unknown). Move the policy from single_agent_turn
into nemo_gym.agent_outcome and apply it in the Harbor environment server
after the agent session closes and before test.sh runs.

Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri ffrujeri added bug Something isn't working area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation labels Oct 22, 2026
@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.

adil-a pushed a commit that referenced this pull request Oct 23, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Ported onto the stack as commit 9 of #4819 (9dceeb6), authorship kept: the policy sits in the shared turn helper so it applies to every turn of a [[steps]] task as well as single-step tasks, with a multi-turn test (a classified failure on step 2 ends the episode ungraded, test.sh not run). The PR body of #4819 carries the description and your TB4 evidence. Closing this draft as superseded.

🤖 Generated with Claude Code

@adil-a adil-a closed this Oct 23, 2026
adil-a pushed a commit that referenced this pull request Oct 24, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 25, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 25, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 25, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 25, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 25, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
adil-a pushed a commit that referenced this pull request Oct 26, 2026
The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from #4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
yaoyu-33 pushed a commit to yaoyu-33/Gym that referenced this pull request Oct 26, 2026
…IA-NeMo#4819)

* feat(harbor): run [[steps]] tasks as turns and grant task MCP servers

Harbor multi-step tasks now load and run on the harbor environment server
instead of being rejected. Each [[steps]] entry is one Gym turn in the same
sandbox, as Harbor runs them without resume_trajectory: a fresh agent session
per turn, the step's own instruction and agent budget, then the shared verifier
with the task's tests/ and steps/<name>/tests/ on top. A turn that is masked,
writes no valid reward file, or misses its min_reward ends the episode, and
multi_step_reward_strategy (mean or final) rolls the turns up. Multi-step rows
never carry the top-level instruction.md, which SWE-Interact uses for the hidden
spec its simulated user holds.

task_mcp_grants (off by default) grants the task's streamable-http
[[environment.mcp_servers]] entries to the agent as MCP tool accesses, so a
harness can reach a Compose sidecar such as SWE-Interact's ask_user server.

Per-step workdir/, setup.sh, healthchecks, artifacts and separate verification
are refused by name for now.

Port note (round 13 layout, PR NVIDIA-NeMo#4728 commit 59545d8): VerifierSettings and
_turn_verifier_settings live in environment_servers/harbor/verifier.py beside
_run_shared_verifier (HarborVerificationMixin); VerifierSettings carries the
task's [[verifier.collect]] hooks, which the mixin runs for every turn; a
step's user overrides the verifier user; the single-turn path still uploads
the task's tests/ unconditionally (only step and multi-step folders may be
absent). The conftest episode() helper builds a HarborEpisodeRequest.

Port note (round 14, rebased onto the round-14 M24): the base now forwards the
harness's own trajectory from the session close as ng_trajectory on the result
(M7 round-14 fix), so _agent_turn returns it with the response and observations,
HarborTurnResult carries it per turn as `trajectory` (left out when None, as
ng_trajectory is) and a multi-turn episode forwards the last turn's, beside the
last turn's observations; test_multi_turn covers it. The base's rewritten
README rows (artifacts and hooks, image ENTRYPOINT), its verifier_image_config
docstring and its _refuse_verifier_group seed check are kept as they are.

Port note (round 20, rebased onto M33 1dd755f): the base's run() now bounds
the episode with the task deadline (enforce_task_timeouts), seeds the harness
with agent_timeout_sec, tolerates a timed-out session close and hands the
verifier an ATIF export of the turn, so _agent_turn carries all four per turn
(the step's own agent budget as agent_timeout_sec) and run() wraps both the
single-turn path and _run_turns in one deadline, _post_seed_budget_s summing
every turn's setup allowance, agent budget, hooks and verifier time for a
multi-step task; a _TurnProgress holder gives the deadline failure the running
turn's stage, response and observations. _verified_outcome exports each turn's
transcript from that turn's own request (_export_trajectory takes it as a
third argument) before _run_shared_verifier, which keeps its trajectory
argument. VerifierSettings carries network_mode, which _score reports as
verifier_network, and HarborTurnResult carries verifier_network. A multi-step
task is refused at seed when separate_verifier_for_artifacts would force it
into separate mode. materialize_task keeps the base's dataset_digest keyword on
multi-turn rows. test_multi_turn covers the per-turn budget and transcript, the
summed deadline and the seed refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

* feat(harbor): let the deployment fill a task's Compose variables

A Harbor task's Compose file may leave a variable to the deployment, as
SWE-Interact's simulated user does with ${LITELLM_BASE_URL}, ${LITELLM_API_KEY}
and ${SIM_USER_MODEL}. Prepare used to fail on any unresolved name. It now
leaves a name used only in a service's environment to the deployment, since an
environment value cannot change which images run; elsewhere it still fails.

The harbor server's compose_variables fill those names at seed from a literal
value, a process environment variable, or a Gym model server. A model_server
value is that server's sandbox-reachable URL with the episode's rollout prefix,
so a sidecar's model calls are recorded with the rollout and never become
training tokens. A name still unset at seed fails the episode terminally before
provisioning. A document holding these values goes to a private folder removed
after the group starts, never under artifacts_dir.

Port note (round 13 layout, PR NVIDIA-NeMo#4728 commit 95804b3): the stack's loader
already follows docker compose for every unset name at prepare (an empty
string with one warning, M19), which covers the environment-only deferral, so
_blank_deployment_values is not carried; with operator_variables the loader
substitutes strictly, keeping the seed-time refusal. _compose_variable_values
and the episode-keyed _compose_document live in sandboxes.py
(HarborSandboxMixin); the per-digest cached document stays for servers without
compose_variables, and the private per-episode folder is used when they are
set. The seed pre-check reads the document through load_compose_document, so
it does not touch the provider block.

Port note (round 20, rebased onto M33 1dd755f): _create_compose on this base
routes sidecars per provider block, plans volumes and starts the group through
_start_with_pull_retries (M13/M22/M28), so the private per-episode document is
removed in a finally around that call, after the last pull attempt has read it;
_compose_document keeps the base's field check and volume planning around the
operator_variables load. The test's recording Compose stub takes the adapter's
extra keywords. Everything else applied unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

* feat(harbor): build Compose sidecars and force-build declared images

SWE-Interact's tasks cannot prepare without two things Harbor does at run time.

Every task's simulated user is a Compose sidecar with a build: section. Prepare
now builds each sidecar context once, from that context's own Dockerfile, keyed
by Harbor's content hash like main's build, and records it; the recorded image
then stands in for the build: section everywhere the Compose file is read. A
sidecar build takes only a context inside environment/, and its section passes
the same host-safety checks as main's. With docker, the compose build of main
then names main alone.

The tasks' declared docker_image lacks the helper their Dockerfiles copy in,
which is why their run configs pass Harbor's --force-build. builds.force builds
the Dockerfile of a task that declares an image, and the loader then prefers the
recorded build of the task's own Dockerfile, as Harbor does.

Validating the main compose build also leaves environment values that only the
deployment can fill blank, since they cannot change what is built.

Port note (round 13 layout, PR NVIDIA-NeMo#4728 commit df0a130): on this stack M24
(Compose service builds) already builds every service with a build: section,
records it by service name under the context's digest and substitutes it at
load (sidecar_build_services, ImageBuilder.build_many, with_built_images), and
the M19 loader already leaves every unset Compose name blank at prepare, so the
sidecar-build and blank_unresolved_environment parts are not carried. What is
carried is builds.force: BuildOptions.force and BUILD_SETTINGS
(build_options.py), plan_builds/build_images/_build_dockerfiles force
(build_plan.py, image_build.py, prepare_builds.py) and the loader's preference
(task.py). To keep the stack's rule that a recorded main is never substituted
for a task pinned to a prebuilt image, the record names the tasks whose
declared image a forced prepare built over (forced_tasks, written on build and
on reuse) and the loader prefers the build for those tasks only.

Port note (round 14, rebased onto the round-14 M24): the base's
_build_dockerfiles now plans a second time without the tasks
refused_before_build names (20 Oct review fix); that replan passes
builds.force too, or a forced main would drop out of the plan whenever
another task of the dataset is refused (test_harbor_compose_prepare covers
it). Everything else applied unchanged.

Port note (round 20, rebased onto M33 1dd755f): the loader on this base
reads built-images.json from the dataset root (nested task folders, M27), so
the forced_tasks record is read from the same root and _build_required keeps
its root argument. The base's pre-build screen now reads keys only (a value
such as featurebench's `count: all` is refused after the build), so the
forced-replan test refuses its other task through a main.build.args key
instead. Everything else applied unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

* docs(harbor): add a SWE-Interact run recipe on the Harbor task shape

A config overlay and README for running the published SWE-Interact dataset
through the harbor environment server with Codex: force-built images and
sidecars, the user-server MCP grant on every turn, the simulated user's model
bound to a Gym model server, and an episode budget that fits the Atlas tasks.
The overlay validates against the server's config model; native Codex sessions
still need to accept MCP tool grants before a run can start.

Port note (round 13 layout, PR NVIDIA-NeMo#4728 commit 5c33771): unchanged apart from
one README sentence, since on this stack the user-server sidecar is built as a
second service of each task's context (M24 Compose service builds), not as a
context of its own.

Port note (round 14, rebased onto the round-14 M24): the recipe lives under
environments/harbor/swe_interact/ (the stack moved benchmarks/harbor/ to
environments/harbor/ beside terminal_bench_4), and the --config paths in the
README and the overlay's header follow; the files are otherwise unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

* feat(harbor): refuse step verifier groups at seed, read legacy multi_step_reward_mode (M34 follow-ups)

Two follow-ups to M34 (Harbor [[steps]] tasks as turns), to be squashed into it.

A step's `[steps.verifier].user = "name:group"` was dispatched as written by
`_turn_verifier_settings` on every provider, while the task-level `[verifier].user`
pair was refused at seed on providers that switch user by name only. Every step's
pair is now refused in `_refuse_verifier_group` the same way: a terminal seed failure
with no sandbox, session or exec, instead of a verification failure after the earlier
turns were paid for; on Docker the pair passes and grades that turn alone. The refusal
names the step that carries the pair (`<task_id> step 'build': user ...`), as the loader
names the step in its per-step refusals; the task-level message is unchanged.

The agent-side sibling, `[steps.agent].user`, was read by the model and applied by
nothing: every turn runs as the task's user, where Harbor 0.22.0 switches to the
step's own user per step (`multi_step.py` `_step_agent_user`). The loader now refuses a
step that sets one, by step name, like the other per-step features it does not run
yet, so the task fails at load (and at seed, through the server's snapshot) instead of
running as the wrong user.

The memory team's MemoryArenaBundledShopping tasks carry the pre-1.3 keys
`version = "1.0"` and `multi_step_reward_mode = "aggregate"`. Harbor 0.22.0 maps
`version` to `schema_version` and has no `multi_step_reward_mode` field: the key is
dropped as unknown and the task rolls up with the default `mean`. The mirror accepts
the key as a known legacy spelling and drops it the same way: "aggregate" is dropped and
the task rolls up with the default `mean` (an explicit `multi_step_reward_strategy`
beside it is the one read), any other value is dropped with a warning naming it, and
the loader no longer reports the key as unknown. The shape of one task
of that dataset is a unit-test fixture (its task.toml, Dockerfile and Compose file with
a placeholder sidecar image, and per step a one-line instruction with stub solve.sh and
test.sh in place of the dataset's own scripts) and loads as six turns with per-step
budgets, a streamable-http MCP sidecar from a Compose file and per-step instruction,
solution and tests, with no top-level instruction, tests or solution.

Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* feat(harbor): per-step solutions and users, prepare registry auth, sidecar sizing, long-task budget (M34 follow-ups)

Six follow-ups on the M34 multi-turn work (NVIDIA-NeMo#4819), found running the memory team's MemoryArenaBundledShopping
task end to end on OpenSandbox (round-24 G7_M34 and G4_M30).

1. Per-step solution for the oracle: the server places each turn's steps/<name>/solution/ at /solution (falling
   back to the task's top-level solution/), gym dataset validate counts a multi-step task validatable when every
   step has a solution, and the oracle is unchanged. Removes the need for G7's dispatcher.
2. Registry credentials at prepare: record_image_configs reads the sandbox block's images.auth
   (credentials_for_image_prefixes, registry_credentials_from_overrides) so a private Compose sidecar records
   without an anonymous HTTP 403; no new config key.
3. Sidecar sizing and diagnostics: the seed warns once per task which sidecars run at the provider's default
   size, and an unhealthy-service failure carries a bounded tail of the service's command log.
4. Episode timeout for a long multi-step task: a new BaseEnvironmentServer.episode_timeout_seconds hook; the
   Harbor server raises the deadline and sandbox lifetime to the task's own budget when the steps exceed
   default_episode_timeout_seconds, and refuses at seed naming the setting when enforcement is off.
5. Step-level agent user: [steps.agent].user is applied per turn (sandbox default user, workdir owner, harness
   user switch and switch back), a name:group pair refused at seed by step on name-only providers.
6. Docs: new fern page data/multi-step-tasks.mdx and the harbor README updated.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

* fix(harbor): clear the previous turn's grading files before the next 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 NVIDIA-NeMo#4728 (P1).

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

* fix(harbor): let required MCP grants satisfy a task's MCP servers

The harbor server refuses a task that declares [[environment.mcp_servers]]
or skills_dir to a harness that does not declare supports_task_tool_context,
so the run cannot score a silent zero without its tools. The check only knew
the task.json channel: with task_mcp_grants it still refused every harness
that does not read task.json, even one that took every server as a grant.
Hermes and Pi, which accept required MCP grants in the agent's sandbox, could
therefore not run SWE-Interact or the Harbor Cookbook's simulated-user recipe.

A declared MCP server now counts as reached when it was granted as required:
by the tool-access contract, a harness that cannot establish a required
server fails its seed. Optional grants may be skipped, SSE and other
non-streamable-http servers cannot be granted, and skills_dir has no grant,
so those still need supports_task_tool_context. The refusal now names what
would not reach the harness and points at task_mcp_grants: required.

Codex, Claude Code, OpenCode, Kilo Code and OpenClaw still reject required
grants in sandbox mode; with this change such a task fails loudly at their
seed instead of being refused up front.

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

* fix(harbor): apply agent outcome policy before verification

The Harbor environment server graded every agent response, including
failed ones whose harness had reported the cause in
response.metadata.ng_agent_outcome. A Codex response that failed with a
stream error reported as `unknown` was handed to test.sh on the
half-finished sandbox and recorded as a real 0. single_agent_turn already
routes these responses through agent_outcome_policy; Harbor ignored it.

- Move OutcomeAction, AgentOutcomePolicyConfig and agent_outcome_policy
  from environment_servers/single_agent_turn/app.py into
  nemo_gym/agent_outcome.py, next to AgentOutcome, so both environment
  servers share one implementation. No behavior change for
  single_agent_turn.
- Add agent_outcome_policy to HarborEnvironmentServerConfig and apply it
  after the agent session closes and before verification. retry and fail
  become a stage: agent episode failure (non-terminal and terminal
  respectively) that keeps the partial response, the agent's observations
  and its trajectory; verify runs test.sh as before.
- Point the agent tests (Codex, OpenCode, Pi, Hermes) at the new import
  location.
- Docs: the harness guide now says the policy applies to harbor too; the
  Harbor README and the module docstring describe the rule.

Ported from NVIDIA-NeMo#4950 onto the multi-turn server: the policy sits in the
shared turn helper, so it applies to every turn of a [[steps]] task as
well as to a single-step task. A retry or fail cause on a later step ends
the episode at that turn, ungraded, with the partial response and
observations attached; a new multi-turn test covers it.

(cherry picked from commit d8a25d9)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>

---------

Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
Co-authored-by: Felipe Vieira Frujeri <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants