Skip to content

refactor(tb4): move rollout ownership to the agent server - #3573

Merged
bxyu-nvidia merged 5 commits into
mainfrom
flafrance/tb4-agent-rollout-loop
Sep 22, 2026
Merged

bxyu-nvidia merged 5 commits into
mainfrom
flafrance/tb4-agent-rollout-loop

Conversation

@lafrancef

@lafrancef lafrancef commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Follow up on #3366 to match Gym's agent/resources server pattern: the mini-SWE agent owns setup, model calls, and the rollout loop; TB4 resources provisions /seed_session and grades and cleans up through /verify.

  • Seeded sessions have a resource-owned deadline, defaulting to 10 hours from sandbox readiness. Abandoned sessions are cleaned up and release their concurrency slots; late seed/verify requests receive HTTP 410. /verify atomically transfers ownership to the verifier lifecycle, so the seed deadline cannot interrupt grading. Configure the deadline with seeded_session_timeout_sec or tb4_seeded_session_timeout_sec.
  • Agent shutdown uses one shutdown_timeout_sec budget for completing seeding and requesting cleanup. If the seed response remains blocked, shutdown returns and resource-side expiry provides the cleanup fallback.
  • Output-token truncation is forwarded to mini-SWE 2.4.6 so its native “respond more concisely” reminder reaches the next turn after missing or malformed tool calls.

The split preserves retry deduplication, session ownership, model-call capture, and official grading after agent timeout/failure. Existing top-level TB4 overrides remain supported. Direct model_server, harness, and agent-timeout overrides move to the agent configuration. Agent trajectories remain inside tb4_jobs_dir when configured, with tb4_agent_artifacts_dir available for an explicit override. Persisted session records advance to version 3. Changes are confined to TB4 and its mini-SWE adapter.

Real smoke: gpt-5.4-mini-2026-03-17, interleaved-vigenere, two model turns, 180-second agent cap. Both model calls returned HTTP 200; official grading completed with reward 0 after the step cap, and all resources were cleaned up. A separate real sandbox seeded with a two-second deadline expired without grading, cleaned up its resources, and released its concurrency slot. An earlier html-js-filter smoke completed its agent turns but its browser verifier stalled and was stopped; it is not counted as a completed end-to-end smoke.

Seed task sandboxes through the resources server, execute mini-SWE in the agent,
and submit agent results to resource-owned verification and cleanup.

Signed-off-by: Frederic Lafrance <[email protected]>
Pass the Responses output-limit reason to mini-SWE so its native concise-response
reminder reaches the next model turn after a missing or malformed tool call.

Signed-off-by: Frederic Lafrance <[email protected]>
@lafrancef lafrancef added area:agent Agent harnesses and Responses API agent behavior needs-review PR is ready for code review and waiting on a reviewer labels Sep 21, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 21, 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.

@yaoyu-33 yaoyu-33 added complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work labels Sep 21, 2026
@lafrancef

Copy link
Copy Markdown
Contributor Author

/ok to test 7644576

@bxyu-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 50bd3c2

@bxyu-nvidia
bxyu-nvidia merged commit e86746a into main Sep 22, 2026
41 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the flafrance/tb4-agent-rollout-loop branch September 22, 2026 16:35
cmunley1 pushed a commit to osoblanco/Gym that referenced this pull request Oct 19, 2026
## What does this PR do?

TB4 currently reports an infrastructure outcome when an executing
agent's sandbox dies after exceeding its allocation, so the rollout is
omitted from scoring. Record a completed zero grade for
provider-confirmed memory or ephemeral-storage limit deaths, preserving
diagnostics, cleanup and verification replay. Keep setup, verifier,
node-pressure and ambiguous failures as infrastructure outcomes.

The rollout and trial result expose `sandbox_resource_limit`;
`verifier_result.source` identifies the limit-based grade. A dead agent
sandbox skips the separate verifier, with null test counts.

Pin the mini-SWE host dependency to LiteLLM 1.102.1 for Gym's MCP 1
runtime. Newer LiteLLM releases import MCP 2 response types before
dispatching model calls, breaking fresh installs.

Follow-up to NVIDIA-NeMo#3573; no separate issue is needed for this scoped grading
correction.

## Validation

- `pre-commit run --all-files` passes without modifying files.
- TB4 example-data validation passes.
- Regression coverage checks execution, quiescing, artifact collection,
teardown, cleanup and restart replay. The storage-death regression fails
on the base implementation because `evaluation_completed` remains false.

## Rollouts

Bounded real-model smoke with `gpt-5.4-mini-2026-03-17`:

- Control: one bash call, artifact collection and a separate verifier,
reward **1.0**.
- Limit failure: one bash call writes at most 2 GiB in a 1 GiB sandbox;
OpenSandbox confirms storage-limit eviction, yielding completed reward
**0.0** without launching a verifier.
- Native aggregation retains both outcomes: **2/2 scored, mean reward
0.5**. Both sessions close, and the sandbox API confirms no owned test
sandboxes remain.

## Compatibility and benchmark impact

Applies automatically to new TB4 evaluations. Confirmed agent
resource-limit deaths now contribute zero to the pass-rate denominator.
Existing completed session records replay their saved results unchanged;
provider details and the original agent termination remain available.

## Checklist

- [x] I have read the contributing guidelines.
- [x] The change is focused.
- [x] Tests added or updated and pass locally.
- [x] Documentation updated.
- [x] Pre-commit checks pass locally (`pre-commit run --all-files`).
- [x] New source files include the required Apache-2.0 SPDX header.
- [x] All commits have DCO sign-off.

---------

Signed-off-by: Frederic Lafrance <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 50bd3c26 Deployed Sep 22, 2026 by copy-pr-bot[bot] via release / finalize / notify #3502
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants