Repository navigation
feat(osworld): run exact-trace rollouts on AgentENV through E2B - #3140
Closed
JeffPengCoder wants to merge 60 commits into
Closed
JeffPengCoder wants to merge 60 commits into
JeffPengCoder wants to merge 60 commits into
Conversation
Capture semantic model calls and reconstruct exact multi-turn trajectory evidence for policy training. Add the OSWorld resources server, remote sandbox integration, reproducible runtime dependency checks, and focused coverage needed to exercise the trace contract end to end. Signed-off-by: Jeff Peng <[email protected]>
Carry scheduler-owned rollout purpose through both the run schema and Responses metadata, cross-check the carriers at the OSWorld boundary, and emit payload-free diagnostics. Keep standalone benchmark callers compatible when purpose is absent while bounding complete rollout attempts and sandbox cleanup. Signed-off-by: Jeff Peng <[email protected]>
Reject agent and model servers resolved outside scheduler-approved Gym roots so stale image copies cannot silently serve a mixed source stack. Expose payload-free purpose markers at the final vLLM proxy boundary and cover both accepted and rejected component paths. Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Allocate a fresh execution ID for each Gym /run dispatch, propagate it through OSWorld child/model/sandbox/result evidence, and keep it out of semantic exact-trace digests. Disable hidden transport replay for non-idempotent /run requests while preserving the public BaseRunRequest JSON shape. Signed-off-by: Jeff Peng <[email protected]>
Apply the repository-pinned Ruff 0.9.9 formatter to the execution-trace changes and drop a stale status-poll warning that loses its logging import when merged with current main. Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Capture semantic model calls and reconstruct exact multi-turn trajectory evidence for policy training. Add the OSWorld resources server, remote sandbox integration, reproducible runtime dependency checks, and focused coverage needed to exercise the trace contract end to end. Signed-off-by: Jeff Peng <[email protected]>
Carry scheduler-owned rollout purpose through both the run schema and Responses metadata, cross-check the carriers at the OSWorld boundary, and emit payload-free diagnostics. Keep standalone benchmark callers compatible when purpose is absent while bounding complete rollout attempts and sandbox cleanup. Signed-off-by: Jeff Peng <[email protected]>
Reject agent and model servers resolved outside scheduler-approved Gym roots so stale image copies cannot silently serve a mixed source stack. Expose payload-free purpose markers at the final vLLM proxy boundary and cover both accepted and rejected component paths. Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Allocate a fresh execution ID for each Gym /run dispatch, propagate it through OSWorld child/model/sandbox/result evidence, and keep it out of semantic exact-trace digests. Disable hidden transport replay for non-idempotent /run requests while preserving the public BaseRunRequest JSON shape. Signed-off-by: Jeff Peng <[email protected]>
Apply the repository-pinned Ruff 0.9.9 formatter to the execution-trace changes and drop a stale status-poll warning that loses its logging import when merged with current main. Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
An AgentENV sandbox restores a template that already holds the guest, so the generated env.yaml carried `vm_path: ""`. DesktopEnv reads an empty path as 'ask the VM manager', and DockerVMManager answers by downloading OSWorld's ~11 GB image -- which every one of 361 concurrent tasks then started doing. OpenSandbox already had a sentinel for exactly this reason; AgentENV now has its own. The sentinel is never opened: it exists only so DesktopEnv does not reach for the manager. Two regressions guard it: the resolver returns a sentinel for both server-side backends while leaving Docker and any explicit path alone, and the generated env.yaml is asserted never to contain an empty vm_path for this backend. Signed-off-by: Jeff Peng <[email protected]>
The reusable agent config declares OpenSandbox's provider options, and
OmegaConf merges rather than replaces, so writing `provider_options: {}` into
the generated env.yaml does not clear them. They arrived at the E2B provider,
which rejects any option it does not know:
ValueError: Unknown E2B provider option(s): extensions, skip_health_check.
Supported: template [repeated 359x across cluster]
Every one of 361 rollouts failed on it, and no sandbox was ever created, so
the run looked like a backend outage rather than a config leak.
Filtering in the adapter rather than the config is deliberate: the merge will
keep reintroducing the base defaults, so the branch that knows what E2B
accepts is the one that has to enforce it.
Signed-off-by: Jeff Peng <[email protected]>
The e2b provider swaps httpx's transport for an aiohttp-backed one when the SDK is first required, so httpx_aiohttp is a hard import on that path, not an optional accelerator. It sits in pyproject's sandbox extra, which builds the Gym runtime -- not the managed agent venv, which is built from this file. All 360 rollouts died on ModuleNotFoundError before creating a sandbox. This is the second miss of the same shape after e2b itself, so a test now derives the e2b provider's third-party imports from its source and asserts each one is pinned here. httpx is excluded: it arrives with the SDK. Signed-off-by: Jeff Peng <[email protected]>
A py-spy dump of a wedged rollout showed start_emulator inside its own except block, blocked in Sandbox.stop() -> future.result(). The sync facade waits SYNC_OPERATION_TIMEOUT_S, an hour by default, and the `raise` that carries the diagnosis sits after it -- so a cleanup that cannot finish does not merely delay recovery, it withholds the startup error for that entire hour. 361 concurrent rollouts all sat at 'Initializing...' with no error line anywhere. The failure is now logged before cleanup is attempted, and cleanup runs on a daemon thread with its own bound: if it overruns, the sandbox is left to its TTL and the original exception propagates on time. Losing a sandbox to the TTL is cheap; losing the reason a run failed is not. Signed-off-by: Jeff Peng <[email protected]>
…tion
Sharing Gym's aiohttp pool is a performance integration; the SDK's own httpx
transport works without it. It was wired as a hard prerequisite instead, so
its failure took sandbox creation with it.
Which it did. The setup runs lazily, so the first call landed inside a Ray
worker, where importing nemo_gym.server_utils reaches Hydra's argument parser.
Hydra parsed that worker's argv, did not recognise Ray's flags, and called
sys.exit(2):
default_worker.py: error: unrecognized arguments: --node-ip-address=...
OSWorld sandbox start failed on provider=e2b: SystemExit: 2
All 361 rollouts died before creating a sandbox. OpenSandbox is unaffected
because it configures the same transport at server import, under normal argv.
The catch is BaseException on purpose: SystemExit does not inherit from
Exception, so catching Exception would have let exactly this through.
Signed-off-by: Jeff Peng <[email protected]>
The previous guard covered installing the transport patch. The failure was one
step later: the patch installs fine, and the *first request* calls
get_global_aiohttp_client(), which resolves Gym's global config -- from the
CLI, if this process has none:
get_global_aiohttp_client -> set_global_config_dict -> parse
-> parse_global_config_dict_from_cli -> hydra -> argparse -> sys.exit(2)
In a Ray worker the CLI is Ray's, so Hydra rejects it and the rollout dies at
sandbox creation. The patch is now installed only when the process can already
answer for its own config -- a built client, or the injected-config env var --
and otherwise the SDK keeps its own transport, which needs no Gym config at
all. OpenSandbox is unaffected: it configures this inside a server that has
already established the config.
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
This was referenced Sep 7, 2026
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
Integrate main dbd26a9 while preserving role-local uv policy and sandbox recovery. Honor explicit prebuilt-venv reuse and shared setup locking. Align OSWorld score aggregation with shared masking/coverage semantics and add regression coverage. Signed-off-by: Jeff Peng <[email protected]>
Inherit upstream main and all six previously missing exact-trace fixes through 8d49597. Preserve AgentENV/E2B provider changes and test the configured shared-pool path separately from no-config worker fallback. AgentENV focused suite: 485 passed; pre-commit passed. Signed-off-by: Jeff Peng <[email protected]>
Describe optional dataset metadata without changing session initialization or canonical tasks. Cover legacy and migrated row shapes, preserve task payloads, and allow verify-only rows. Schema and OSWorld resources suite: 330 passed. Signed-off-by: Jeff Peng <[email protected]>
Signed-off-by: Jeff Peng <[email protected]>
This was referenced Sep 22, 2026
bxyu-nvidia
pushed a commit
that referenced
this pull request
Sep 22, 2026
…3592) ## 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: ```bash 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](https://gitlab-master.nvidia.com/jepeng/rl/-/blob/36462b79e257cf054c67228d0942c069af29deee/osworld/recipes/benchmarking/nano-omni-osworld-bench/models/nano-omni-v3/cw-dfw-h100-x86_64/agentenv-canonical-s100/README.md). **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. --------- Signed-off-by: Jeff Peng <[email protected]>
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 <[email protected]> Co-authored-by: Michał Bień <[email protected]>
Collaborator
Author
|
Closing this original combined AgentENV/E2B PR because its implementation and inherited infrastructure changes are now tracked by these focused follow-ups:
The remaining HTTP-lifecycle work continues in #4823. The source branch is retained for provenance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Run the OSWorld exact-trace flow on an AgentENV desktop exposed through an E2B-compatible gateway.
Depends on #2554. The branch is built directly on the exact-trace head and temporarily targets
main, just like #2554; after the parent merges, GitHub will show only this AgentENV/E2B increment. It does not change exact-trace semantics or history policy.Design
gym_agentenvthrough configuration instead of adding an alternate OSWorld agent protocol.Main changes
>=2.46,<3forConnectionConfig.sandbox_headers, with the matching minimal lock update.Validation
uv lock --checkpasses..gitignore, pre-commit configuration, CI workflows, or unrelated repository policy.Scope and non-goals