Skip to content

feat(miniswe): episode sessions on the resources server sandbox (M11) - #3745

Merged
adil-a merged 1 commit into
adasif/harbor-m10-separate-verifierfrom
adasif/harbor-m11-miniswe-sessions
Oct 21, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m10-separate-verifierfrom
adasif/harbor-m11-miniswe-sessions

Conversation

@adil-a

@adil-a adil-a commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

M11 of the Harbor tasks RFC: mini-SWE on the resources server's sandbox. Stacked on the M10 PR (#3744).

  • miniswe_sandboxed_agent. Gains /v1/agent_sessions and /v1/agent_sessions/close. It connects to the sandbox the resources server seeded over SandboxAccess and /v1/responses runs mini-SWE 2.4.6 on it with the input messages as the instruction. The harness code is unchanged and shared with the legacy /run path, which still seeds and verifies against a Terminal Bench 4 style resources server when resources_server is set (now optional, and /run without one is a 422).
  • The response carries miniswe_termination, its detail and whether the agent started in metadata. Agent observations return at close.
  • Config. configs/miniswe_sandboxed_agent.yaml with the Terminal Bench 4 profile (500 steps, 30 s per command, 8 h budget) so gym eval run --agent miniswe_sandboxed_agent works. The generated run config pins num_workers: 1.
  • Sandbox transfers run as root (resources_servers/harbor/sandbox_io.py). Uploading tests/ or solution/ and downloading /logs ran as the image's default user, and two Terminal Bench 4 images run as a non-root user that cannot create /solution. Transfers now run as root, unpack without preserving archive ownership and leave the tree world-readable. Images that cannot switch users (no CAP_SETUID) fall back to the default user. Restored artifacts land in a world-writable folder, as Harbor leaves them. The oracle agent reports a transfer it still cannot make as oracle: failed with error type transfer instead of a 500 that drops the episode.

Review fixes (2026-10-04)

  • Seeding refuses a loopback Model Server URL on a remote sandbox provider with a 422. mini-SWE calls the model from inside the container, where loopback is the container itself, so every call would fail silently.
  • An episode turn that ends in infrastructure_error or cancelled fails with a 503, so the episode is recorded as a masked failure instead of an unmasked zero. completed, nonzero_exit and timeout are still verified. A retry of the same turn replays the refusal.
  • The task's own [agent].timeout_sec, carried in the row metadata, bounds the turn budget when it is shorter than the seed's budget or the configured ceiling, matching the Terminus 2 agent.

Validation

  • pytest responses_api_agents/miniswe_sandboxed_agent/tests (server venv): pass. The new test_sessions.py has ten tests: seed connects and the turn runs the harness on that sandbox with the row's instruction and workdir, the plain responses path binds the only session and disables capture, a second different turn on the same session is refused, session identity rules, /run without a resources server is refused, instruction from input, the loopback model URL refused at seed, the task timeout bounding the turn budget, infrastructure outcomes as a 503, and agent outcomes verified rather than masked.
  • pytest resources_servers/harbor/tests responses_api_agents/harbor_oracle_agent/tests: pass. New tests cover the fallback to the default user when root is refused, other root failures propagating, and a transfer failure reported as an oracle failure instead of a 500.
  • pre-commit run --files <changed files> clean.

Rollouts

The 52 Terminal Bench 4 CPU tasks through this agent on the Harbor shape, compared with the same agent on the old terminal_bench_4 server. Numbers in the M12 PR of this stack (#3746). Those runs predate the rebase below.

Rebased onto main

Rebased onto main 128eab4 (2026-10-04).

Compatibility and benchmark impact

The legacy /run path is unchanged apart from the 422 when no resources_server is configured. benchmarks/terminal_bench_4/miniswe.yaml is unchanged. The transfer change affects the harbor server and the oracle agent for images whose default user cannot create /tests, /solution or /logs.

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).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Sep 29, 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
adil-a added this pull request to stack #3733 September 29, 2026 01:01
@adil-a adil-a changed the title adasif/harbor m11 miniswe sessions feat(miniswe): episode sessions on the resources server sandbox (M11) Sep 29, 2026
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch 2 times, most recently from 2893536 to 7b86093 Compare September 29, 2026 01:21
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from 7b86093 to 215f2fe Compare September 30, 2026 03:48
@adil-a
adil-a removed this pull request from stack #3733 September 30, 2026 03:50
@adil-a
adil-a added this pull request to stack #3806 September 30, 2026 03:51
@adil-a
adil-a removed this pull request from stack #3806 September 30, 2026 04:12
@adil-a
adil-a added this pull request to stack #3808 September 30, 2026 04:12
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from 215f2fe to 7ae37a6 Compare October 4, 2026 23:19
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from 7ae37a6 to 2b31d07 Compare October 9, 2026 20:08
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from 2b31d07 to f60d4ea Compare October 9, 2026 20:20

@yuhezhang-ai yuhezhang-ai left a comment

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.

Thanks for wiring mini-SWE into the shared session flow. I found three additional correctness/test issues and two non-blocking follow-ups, detailed inline. Validation used the affected test suites and focused local reproductions; I did not run live model/provider rollouts.

@adil-a

adil-a commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Rebase note: the first commit on this branch, fix(hermes): refuse a loopback model URL on remote sandboxes, is #4582 against main. It sits here only because the miniSWE sandboxed agent imports assert_model_url_reachable_from_sandbox; it drops out on the next rebase once #4582 merges. Review the miniSWE commits above it.

@adil-a
adil-a removed this pull request from stack #3808 October 14, 2026 00:54
@adil-a
adil-a added this pull request to stack #4583 October 14, 2026 00:55
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from f60d4ea to e016350 Compare October 14, 2026 01:07
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from e016350 to f4bdf80 Compare October 14, 2026 01:33
@adil-a
adil-a force-pushed the adasif/harbor-m11-miniswe-sessions branch from 9fd4324 to c58f179 Compare October 16, 2026 04:18
@adil-a

adil-a commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c58f179

@adil-a

adil-a commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c73bf5d

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2319bf0

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a771703

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 00f7c6a

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 2de9768

@adil-a

adil-a commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Status note at the new head 2de9768. All threads from the 9 Oct review are answered inline, and the transfer helpers now live in nemo_gym/sandbox/transfer.py with exec_as_root public, so this harness no longer imports a private name from the server package (the TIMEOUT_WRAPPER_GUARD and resolve_env_templates import is the one known leftover, deferred as the thread says). The rebase puts main's mini-SWE runtime isolation and the litellm pin underneath, which is what unblocked the server-suite shard, and the base class now carries the calls_model_from_sandbox default that this harness declares.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 57ec522

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 82ba698

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 60fa73a

@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks, I rechecked at 60fa73a7, including the relevant paths at the current stack tip 5df89d45. The other 10 reviewed threads on this PR are addressed. In particular, failed task-context reads remain retryable, close drains the active turn before disconnecting and preserves its observations, and the log-directory test now explicitly reaches the intended step. The corresponding regression tests passed.

Your explanation of the oracle change is also correct: the environment now places the solution before the agent session opens, so the earlier extraction command is no longer part of this route.

Only the provider-failure thread still needs a follow-up fix; I added the current reproduction there. The separate networking comment on #4582 remains outside this PR's thread count.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dc182be

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 00c800e

…M11)

M11 of the Harbor tasks RFC. `miniswe_sandboxed_agent` gains episode sessions that borrow the
environment server's sandbox over `SandboxAccess` and disconnect on close, through the base
agent hooks; an unseeded session is a 409, as the base contract says. Infrastructure failures
are masked, loopback model URLs are refused on remote sandboxes (Hermes too), and the task's
`[agent].timeout_sec` bounds the run. Its shipped config no longer requires a resources server:
only the legacy `/run` route uses one.

Harbor-side: sandbox transfers run as root with the default-user fallback, and restored
artifact folders are left world-writable, as Harbor leaves them; the oracle reports a solution
it cannot place as an oracle failure instead of an unhandled error.

Squashed from the previous branch and re-applied onto the environment server.

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

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5c1e6cd

@ffrujeri ffrujeri left a comment

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.

Approving 5c1e6cdb. The exec_as_root fallback now assigns result in the except path and keeps the result-shaped retry in else:, so both go through the error_type check and raise SandboxUnavailableError. test_root_fallback_with_a_provider_error_propagates_as_unavailable covers both shapes.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39683725823

This branch was previously deployed

1 inactive deployment
public — 5c1e6cdb Deployed Oct 21, 2026 by copy-pr-bot[bot] via release / finalize / notify #6386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer QA_verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants