Skip to content

feat(osworld): isolate exact-trace and AgentENV environment support - #3592

Merged
bxyu-nvidia merged 2 commits into
NVIDIA-NeMo:mainfrom
JeffPengCoder:feature/osworld-runtime-agentenv
Sep 22, 2026
Merged

bxyu-nvidia merged 2 commits into
NVIDIA-NeMo:mainfrom
JeffPengCoder:feature/osworld-runtime-agentenv

Conversation

@JeffPengCoder

@JeffPengCoder JeffPengCoder commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Extract the OSWorld-owned changes from #2554 and #3140 into one environment-focused PR. Both original PRs and their branches remain unchanged. This branch is based on upstream 6bbc05ed9; the implementation comes from the AgentENV benchmark source 360b0df13.

  • Exact multi-turn evidence, logical rollout identity, fixed-window/hysteresis history policies, and explicit train/eval contracts.
  • Runner-owned episode limits and termination facts, evaluator-owned rewards, and separate admission decisions. Canonical OSWorld tasks and evaluator semantics are preserved.
  • Stateful OSWorld resources server, remote environment support, runtime declarations, benchmark preparation, and regression tests.
  • AgentENV desktop adaptation through Gym's E2B provider: prebuilt templates, service-port forwarding, configurable noVNC port, and bounded cleanup after failed startup.

Changes are limited to benchmarks/osworld, the relevant examples config, resources_servers/osworld, and responses_api_agents/osworld_agent. OSWorld-specific dependency-policy tests move into the agent suite.

Companion and merge dependency

The companion Gym Core runtime-contracts PR #3591 owns the generic installer, rollout collection, HTTP lifecycle, sandbox providers, and shared vllm_model changes. E2B gateway/hostname endpoint resolution and SDK transport integration belong there because they serve any E2B consumer, not just OSWorld.

The two diffs have no overlapping files and both target main. This is review/scope separation, not a claim of runtime independence: the complete AgentENV path requires the companion Core PR, particularly E2BProvider.endpoint(). The Core PR should land first for complete AgentENV enablement.

Validation

  • OSWorld agent/resources/benchmark suites: 353 passed.
  • Combined OSWorld + Core tree: 1,425 passed, 2 skipped across both component suites and focused core, sandbox, transport, model, and compaction regressions. This includes local HTTP connection-sharing tests.
  • pre-commit run --all-files, uv lock --check --offline, and git diff --check: passed.
  • Both skips require the optional E2B SDK, absent locally: real-SDK call-shape introspection and E2B/OpenSandbox cross-provider connection sharing. Other local HTTP-sharing fixtures passed. GitHub lint, copyright, DCO and secret detection passed.
  • Commands for the environment suite:
NEMO_GYM_EXTRA_ROOTS="$PWD" PYTHONPATH=. python -m pytest \
  responses_api_agents/osworld_agent/tests resources_servers/osworld/tests \
  benchmarks/osworld/tests --import-mode=importlib -q -o addopts='' -o log_cli=false

An exhaustive Git-object reconstruction audit accounts for all 92 predecessor change paths: 80 byte-identical, six clean upstream/source merges, two E2B transport/test conflict adaptations, three dependency/test-organization updates, and one comment-only false-positive annotation on the golden-prompt SHA256. The hash and assertion are unchanged. No unaccounted paths; unrelated upstream files and original executable modes are preserved. Runtime-policy assertions for vllm_model remain in the companion PR rather than making the OSWorld test suite own them.

Rollouts

The recorded predecessor completed 361/361 canonical OSWorld tasks on AgentENV: 46.9182% raw reward, 159/361 binary successes, no missing/duplicate/masked rows. It used Omni v3, fixed-three-image history, 100 steps, temperature 0.60, and top_p 0.95. Four model-format terminations were evaluator-scored; this is not a claim of zero format failures.

The actual CW-DFW run checkout was rechecked: 360b0df131de7671e2a6e243f21c8150a061c5ce, clean. Recipe and run evidence.

No fresh GPU rollout or full 361-task evaluation was run for this split. These scores belong to the predecessor; they are not a new benchmark claim for the split on newer main. No new environment behavior was intentionally introduced by the split.

Compatibility and benchmark impact

The task definitions, evaluator, prompts, parser, history-policy implementation, and exact-trace implementation are unchanged from the tested source. Training's hysteresis policy remains configurable; the recorded benchmark's fixed-3 setting is not imposed on training. The obsolete httpx-aiohttp requirement is removed because newer upstream owns GymAiohttpTransport; Core preserves the no-config worker guard/fallback. Other agent implementations are not modified here.

The automatic Claude review currently fails while obtaining its OIDC token (ACTIONS_ID_TOKEN_REQUEST_URL is unavailable). This is an upstream workflow permission issue, not a code-review finding; no CI configuration is changed in this PR.

Extract the OSWorld-owned changes from JeffPengCoder/Gym 360b0df onto upstream main 6bbc05e. Shared runtime, sandbox-provider and vLLM-model changes are reviewed separately. Preserve canonical task/evaluator semantics and move environment-only dependency tests into the agent suite.

Signed-off-by: Jeff Peng <jepeng@nvidia.com>
@JeffPengCoder
JeffPengCoder requested a review from a team as a code owner September 22, 2026 04:08
@JeffPengCoder JeffPengCoder added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer labels Sep 22, 2026
@copy-pr-bot

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

Signed-off-by: Jeff Peng <jepeng@nvidia.com>
@yaoyu-33 yaoyu-33 added the complexity:high Cross-component or shared-contract change with a large review surface label Sep 22, 2026
@bxyu-nvidia

Copy link
Copy Markdown
Contributor

/ok to test 1e0985e

@Glorf

Glorf commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

/claude review

@bxyu-nvidia
bxyu-nvidia merged commit 3420baf into NVIDIA-NeMo:main Sep 22, 2026
34 checks passed
@claude

claude Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

SHIP WITH CARE — large (65-file) additive PR: a decoupled Gym-native OSWorld Resources Server + remote-Docker worker, an AgentENV/E2B sandbox backend, deterministic history policies, and supporting tooling. The core scoring and async paths hold up; findings below are minor.

Reviewed against the rubric (verifier/scorer correctness, async HTTP, public-API compat, config conventions, dependency hygiene, test coverage, operability).

What I checked and found solid:

  • Reward/verifier correctness. rollout_outcome.classify_rollout_outcome + RolloutResult/OSWorldVerifyResponse invariants (mask_sample == not runtime_eligible, no runtime-eligibility before evaluation completes) are enforced with fail-closed validators in both the agent and the client. compute_metrics reads osworld_score and the shared aggregator already partitions masked samples out of quality metrics (select_measured/_partition_on_mask), so masked rollouts don't corrupt reported success rates.
  • Async correctness. The agent's Ray dispatch awaits via asyncio.to_thread(ray.get, ...) (never a bare ray.get in async), bounds the attempt with GetTimeoutError + cooperative cancel, and guards the /run semaphore. The Resources Server session manager uses a global lock plus per-session locks correctly and idempotent operation_id step caching. RemoteDesktopEnv and the worker are deliberately sync (requests) and run behind asyncio.to_thread, which is acceptable here (not the high-concurrency httpx footgun the guidance targets).
  • API compatibility. _runtime_admission_fields accepts both legacy (mask_sample-only) and current child results without weakening checks. No public base-class surface changed.
  • Dependency hygiene. OSWorld/opencv/numpy/torch pins are role-local via [tool.uv] override/exclude; heavy imports (desktop_env, mm_agents, easyocr) are gated inside functions or try/except, so the module imports without the runtime installed.
  • Operability. num_workers==1 invariant enforced (live DesktopEnv is process-local), bearer auth uses hmac.compare_digest, orphan cleanup is deployment-scoped, and the sandbox start failure path bounds cleanup so a slow Sandbox.stop() can't hide the root-cause exception.

Findings: one inline NOTE on resources_servers/osworld/app.py verify() (unconditional binary thresholding drops fractional evaluator credit on the direct /verify path; harmless for the agent-driven path). Nothing blocking.

Per repo policy, behavior-changing agent/verifier work should land with real smoke-rollout evidence (a model run inspecting agent + verifier behavior), not green unit tests alone — please confirm that's in the PR description before merge.

JeffPengCoder added a commit to JeffPengCoder/Gym that referenced this pull request Sep 23, 2026
Signed-off-by: Jeff Peng <jepeng@nvidia.com>
cmunley1 pushed a commit that referenced this pull request Sep 23, 2026
## What does this PR do?

Fix the OSWorld agent's Python 3.13 dependency-resolution failure by
correcting the OSWorld package metadata at its source, rather than
adding another NumPy override or changing Gym's shared installer.

- Update both OSWorld consumers to
[JeffPengCoder/OSWorld@f32ab2b7](JeffPengCoder/OSWorld@f32ab2b),
now published on `nv-gym`.
- Remove the redundant NumPy overrides from the agent and resources
server. Their normal `numpy>=2.1,<2.5` requirements remain unchanged.
- Update revision documentation and dependency-policy tests. No Gym
Core, CI workflow, root dependency, or other-agent changes.

The fork commit synchronizes `pyproject.toml`, `requirements.txt`, and
`setup.py`: Python <3.13 retains NumPy 1.26/OpenCV 4.8; Python >=3.13
declares NumPy >=2.1,<3 with headless OpenCV >=4.10.0.84,<5. It adds 18
marker/ABI-pair regression cases. These are compatibility ranges, not
experimental version locks.

## Why is this needed?

The [scheduled server-suite
failure](https://github.com/NVIDIA-NeMo/Gym/actions/runs/35816620013/job/107039403224)
occurs before OSWorld tests run:

```text
osworld==0.1.0 depends on numpy<2
the agent requires numpy>=2.1,<2.5
No solution found
```

#3592 introduced the agent's NumPy 2 requirement while its pinned
OSWorld archive still declared `numpy<2`. `osworld==0.1.0` is the fork
package's metadata version; CI already downloads our explicit GitHub
archive, not an unrelated PyPI package. The later README-only #3631 did
not introduce this regression.

The role's `uv.toml` NumPy override depended on explicit config loading
in the still-open #3591. Current main's generated requirements install
does not load that role config in this checkout layout. Fixing the fork
metadata removes this particular dependency on #3591. Its other
runtime/embedded-Ray changes remain separate and are not claimed fixed
here.

## Validation

- Reproduced the original NumPy resolver conflict on the old archive.
- Real Linux x86_64 / Python 3.13.14 dependency resolution passed for
both agent and resources server using the published new archive, without
NumPy overrides.
- Gym's actual generated agent install command also passed with only
`--dry-run` and a Linux target added, in a fresh temporary venv and
including the parent's Ray 2.56.1/OpenAI 2.44.0 requirements: **350
packages resolved**.
- OSWorld agent, resources-server, and benchmark regression suites:
**353 passed**, run in the existing development venv.
- Fork regression suite: **18 passed**; it failed against the old
metadata. Built the fork wheel and inspected the emitted conditional
`Requires-Dist` entries.
- Isolated CPython 3.13.14 NumPy/OpenCV imports and PNG encode/decode
passed for NumPy 2.1.0 and 2.4.6, both with OpenCV 4.10.0.84, on macOS
ARM64.
- `pre-commit run --all-files` and `git diff --check`: passed.

The full eight-shard server suite and a fresh Linux managed-venv
installation are left to CI; resolver checks are not a claim that those
runs completed locally.

## Compatibility and benchmark impact

The fork's `desktop_env`, `mm_agents`, and `evaluation_examples` Git
tree IDs are byte-identical to the previous pinned revision. Tasks,
evaluators, prompts, parser, history policy, and exact-trace behavior
are unchanged. Existing Gym role runtime ranges are also unchanged; only
their upstream metadata conflict is removed.

Model rollout: **N/A for this metadata-only fix**. No new model score or
training result is claimed. Other stale dependency overrides are
intentionally retained; this is not a general OSWorld packaging
migration.

Signed-off-by: Jeff Peng <jepeng@nvidia.com>
Glorf added a commit that referenced this pull request Sep 28, 2026
## Summary

Add an opt-in `sink_window` history policy to the OSWorld Nemotron
adapter: retain the earliest screenshots alongside a recent-image
window, with intervening turns represented as text in chronological
order.

This branch includes upstream `main` at `d4c0f86c7` through a normal
merge, including the NumPy metadata fix #3649, CI preflight update
#3658, and sandbox lifecycle telemetry #3633. The OSWorld foundation
from #2554/#3140 was consolidated and merged through #3592, so this PR
no longer carries the old exact-trace/Core stack or depends on #2554. It
does not require #3591. No separate issue is needed for this follow-up
policy extension.

## Changes

- Add configurable sink, low-water and high-water counts. Both
watermarks include the sink; equal watermarks slide, while unequal
watermarks provide hysteresis.
- Represent non-contiguous image selections with intervals and render
folded text in chronological order.
- Distinguish context overflow, transport failure, truncated output,
empty output and unparseable output; retain
`agent_outcome_family=model_response_invalid` for compatibility.
- On context overflow, reduce the recent-image window within the
existing retry budget, preserve the sink/current observation, record
actual shrink events, and stop when further reduction is impossible.
- Preserve main's immediate model-timeout propagation. Report the
terminal attempt's completion fact so an earlier malformed sample cannot
hide a subsequent transport failure.

The latest synchronization also annotates six deterministic SHA-256
prompt goldens that the previous secrets-detector run falsely identified
as credentials. Only those literal lines are annotated; the digest
values, assertions, repository scanner configuration, and baseline are
unchanged.

## Design and compatibility

History policy selects image/text turns; the adapter owns model protocol
rendering and parsing. The runner owns horizon and runtime failure
handling, the evaluator owns reward, and runtime admission owns masking.
This PR does not change those ownership boundaries or add a
training/evaluation switch.

Fixed-window and hysteresis policy IDs and normal-path rendered prompts
remain covered by deterministic golden tests, including fixed-3 and
3-10-3. Sink-window is opt-in, not a new default or a claim of improved
benchmark score. Context-overflow recovery and more precise failure
outcomes are intentional behavioral changes and may affect failed-run
outcomes. The legacy scalar `image_window_start` accessor rejects
non-contiguous plans; consumers should use `image_intervals` or per-turn
decisions.

Scope relative to current main remains limited to
`responses_api_agents/osworld_agent/`: two implementation files,
documentation, and tests. No Gym Core, dependency, deployment,
sandbox-provider or model-server changes are included in the PR diff.

## Validation

Re-run on the final main-synchronized tree:

- **440 passed, zero skipped** across OSWorld agent, resource-server and
benchmark tests; one non-failing Starlette deprecation warning.
- `pre-commit run --all-files`: passed.
- `uv lock --check --offline`: passed.
- `git diff --check`: passed.
- The same `detect-secrets==1.5.0` hook and checked-in baseline used by
CI passed on all nine PR-scoped files after the inline false-positive
annotations.
- Existing model-timeout propagation, runner admission, prompt-parity,
sink selection, overflow recovery and policy-identity regressions
passed. The unchanged-overflow retry and mixed parse/transport
completion bugs had been reproduced before their earlier fixes.

Test invocation, using an existing compatible development environment
from this checkout:

```bash
export PYTHONPATH="$PWD"
export NEMO_GYM_EXTRA_ROOTS="$PWD"
python -m pytest \
  responses_api_agents/osworld_agent/tests \
  resources_servers/osworld/tests \
  benchmarks/osworld/tests \
  --import-mode=importlib -o addopts='' -o log_cli=false -q
pre-commit run --all-files
```

The explicit source root prevents an older editable checkout from
shadowing the branch under test; importlib mode avoids the shared
`osworld` test-package name collision. These checks are local evidence,
not a claim that the upstream CI run has completed.

## Score reproduction

OSWorld 361 tasks, Nemotron-3-Nano-Omni v3 (`24e67ea0`), fixed-3
history, 100 steps, one A/B run per arm. Control = main `d4c0f86c7` +
#3591 (needed for the E2B `endpoint()` on AgentEnv); treatment = control
+ this PR. Raw SR 44.61% → 46.62% (Δ +2.01 pp, paired 95% CI [−2.12,
+6.07] pp); binary 154 → 159 of 361 (McNemar p = 0.59); 0 masked and 0
missing in both arms; identical history-policy and agent-contract IDs.
No degradation. The context-overflow shrink path was not triggered in
either run.

---------

Signed-off-by: Jeff Peng <jepeng@nvidia.com>
Co-authored-by: Michał Bień <mbien@nvidia.com>

This branch was previously deployed

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

4 participants