Repository navigation
feat(osworld): add taskgen plugins, reward modes, and capture-aligned history - #4896
Merged
yfw merged 10 commits intoNov 6, 2026
Merged
Conversation
7 tasks done
Generated (taskgen) OSWorld tasks may judge with getters/metrics they carry themselves: taskgen_plugins.register_task_plugins registers them before env.reset() so DesktopEnv resolves them by name, and refuses them on the remote Resources Server path. reward_modes.reward_from_score maps the evaluator score and the agent's terminal action to the training reward: binary (default), raw, or signed_v1 (1 on success, -1 for a DONE on an unfinished task, 0 otherwise). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jeff Peng <[email protected]>
With training-token capture on, the agent gets no token arrays, so its output fell back to synthesized msg-step-N messages: thinking stripped, one per environment step, parse retries missing. Capture fingerprints what the model server served, so returned_history selection found no match on the first call. When capture is on and there is no exact per-call evidence, the agent now returns one assistant message per served model call, with the text as served (thinking included), parse retries included; calls with no response or with empty served content (a local context-overflow answer) are skipped. The served Chat id is kept beside each structured response, and the top-level terminal_response_id names the last served call. Behaviour without capture is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jeff Peng <[email protected]>
Document trusted generated-task evaluator plugins, reward mappings, served-call history, and the merged Gym foundations. Distinguish the separate optional compaction and HTTP-lifecycle PRs. Apply repository formatting to this PR only; no runtime behavior change. Signed-off-by: Jeff Peng <[email protected]>
JeffPengCoder
force-pushed
the
jepeng/osworld-taskgen-served-history
branch
from
October 28, 2026 02:47
3116a37 to
bea2281
Compare
JeffPengCoder
marked this pull request as ready for review
October 28, 2026 02:48
yfw
reviewed
Nov 2, 2026
Signed-off-by: Jeff Peng <[email protected]>
yfw
previously approved these changes
Nov 5, 2026
Merge upstream main b625dcc into the branch for PR NVIDIA-NeMo#4896 without rewriting its four signed commits. Resolve _build_response by retaining the served terminal response ID and main's typed admission/sandbox failure fields. Keep accepted history, task-scoped plugin cleanup, reward modes and action parsing unchanged. Migrate served-history tests to the package APIs and renamed ChatCompletionsConverter. Export the two existing completion evidence helpers from the token-capture public API as required by the new layout. Cover captured history together with evaluator/model failure metadata. Signed-off-by: Jeff Peng <[email protected]>
Merge upstream main 273d709, which advanced while the PR NVIDIA-NeMo#4896 synchronization was being validated. The additional upstream change concerns selected-answer reverification; the OSWorld feature, protocol, configuration and test sources are unchanged. Signed-off-by: Jeff Peng <[email protected]>
Contributor
|
/ok to test 9e2e301 |
yfw
previously approved these changes
Nov 5, 2026
yfw
reviewed
Nov 5, 2026
Remove the completion_items and output_item_fingerprint facade exports and import their defining module in the OSWorld served-history test. Resolving all public token-capture names must not load the OpenAI client or httpx through ChatCompletionsConverter. Apply the exact minimal change proposed in Yi-Fu's review: NVIDIA-NeMo#4896 (comment) The token-capture facade now matches the main base byte for byte. Completion helpers, parser, model output handling and test assertions are unchanged. Token-capture, public-API/facade and OSWorld agent tests: 1584 passed. Signed-off-by: Jeff Peng <[email protected]>
Contributor
|
/ok to test faffcd6 |
yfw
approved these changes
Nov 5, 2026
Collaborator
Author
|
/ok to test 5f782b0 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42141491876 |
6 of 7 tasks
jinglinglingling
pushed a commit
to jinglinglingling/Gym
that referenced
this pull request
Nov 16, 2026
The exact per-call token-evidence path again exports all calls, including parser retries, as the README and NVIDIA-NeMo#4896 describe. Capture-on returned history is unchanged. Signed-off-by: Linglin Jing <[email protected]>
khazic
pushed a commit
to khazic/Gym-lao
that referenced
this pull request
Nov 20, 2026
* feat(osworld): add NeMo RL runtime profiles Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): forward Gym config to Ray rollout task Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): sanitize setup cleanup commands Signed-off-by: Linglin Jing <[email protected]> * fix(model): re-read endpoint file after polling interval Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): restore 3-10-3 training compaction Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): replace fixed compaction params Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): align sandbox create budget with readiness Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): isolate OpenSandbox transport loop Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): replay accepted served calls and keep Code in history Replay the served completion inside the live window so prefixes stay continuous, keep the policy's original Code in compacted turns (raw_full), expose only accepted calls as loss membership, and carry served response_id through exact traces. Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): optional stop-on-context-overflow policy with prompt token limit Under the shrink policy a trajectory near the window overflows on every later turn, and each shrink re-prefills the prompt and starts a new captured row. The stop policy ends the rollout at the first overflow and scores it as a policy stop, so the evaluated trajectory stays trainable. context_prompt_token_limit rejects served calls whose prompt left less than the reserved output room, since the server clamps max_tokens. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): fail unterminated episodes like the reference agent The adapter scored an episode on its final state when the policy never returned computer.terminate: at the step horizon, after exhausting parse retries, or at the context-limit stop. Training under that rule stopped rewarding termination, and the policy drifted to printing a completion message instead, which the reference Nemotron evaluator scores 0. unterminated_episode_policy=fail executes FAIL in those three cases, as the reference agent does. Transport failures remain runtime facts for admission. The default keeps the published contract unchanged; the NeMo RL OpenSandbox profile opts in. Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): report how each episode ended Classify every evaluated episode as done, agent_fail, forced_fail or unterminated, print one OSWORLD_EPISODE_END line per episode, and expose one-hot episode_end_* scalars on the verify response so trainers can log them per step. Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): opt-in options that reproduce pre-rebase cc_app training Each option defaults to the current behavior and is enabled through an OSWORLD_* environment variable in osworld_nemo_rl_opensandbox.yaml. - cc_chunk_turns_as_generated / cc_prompt_token_guard: inside a context chunk, continue from the tokens the model generated and start a new chunk before the prompt exceeds the guard, as cc_app did. - legacy_response_parser: parse actions with the pre-rebase OSWorld parser, including its Action header completion. - rollout_timeout_s: agent-loop budget counted from the first step; reaching it ends the rollout as a timeout, which is not trained. cc_app trained with 1200s and evaluated with 7200s. - mask_unterminated / mask_context_limit: do not train rollouts that end without a terminal action or at the context limit. - Loss membership follows a loss_member flag so a rejected terminal call can be trained when train_invalid_terminal_call is set. Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): let training keep partial OSWorld scores Expose reward_mode through OSWORLD_REWARD_MODE (default binary). The pre-rebase resources server trained on the raw evaluator score. Signed-off-by: Linglin Jing <[email protected]> * style(osworld): apply ruff format after rebase onto main Signed-off-by: Linglin Jing <[email protected]> * docs(osworld): name the legacy nemotron_osworld agent instead of pre-rebase Signed-off-by: Linglin Jing <[email protected]> * docs(osworld): describe training options by behavior Signed-off-by: Linglin Jing <[email protected]> * test(osworld): import ChatCompletionsConverter from the public API The core public-API facade test rejects imports from nemo_gym.models submodules. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): emit ng_trajectory as a typed TrajectoryRecord Gym's collector validates ng_trajectory as a TrajectoryRecord and drops a hand-built dict. Build one TrajectoryTurn per accepted call with ModelCallRef(model_ref, response_id), and pass the policy server reference into _build_response. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): name the last accepted call when the prompt-token guard stops a rollout A reply that context_prompt_token_limit rejects was named as terminal_response_id while accepted history excluded it, so returned-history selection raised. Skip it, as the server's local overflow reply is skipped, so a context-limit stop names the last accepted call like a step-horizon FAIL. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): restore exact-trace output of every model call The exact per-call token-evidence path again exports all calls, including parser retries, as the README and NVIDIA-NeMo#4896 describe. Capture-on returned history is unchanged. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): stop forwarding NEMO_GYM_CONFIG_DICT to Ray rollout tasks Ray logs a task's runtime_env env_vars at INFO, which exposed literal keys in the Gym config. Since NVIDIA-NeMo#5093 the child builds its HTTP client without parsing argv, so the dict is not needed. NEMO_GYM_CONFIG_PATH is still forwarded for sandbox attribution. Signed-off-by: Linglin Jing <[email protected]> * feat(osworld): report infrastructure-stopped episodes as aborted A row with no terminal action and an infrastructure_failure_reason (reset failure, policy transport failure, rollout timeout) now reports episode_end=aborted instead of unterminated. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): require cc_keep_last_groups >= 1 With 0, a chunk re-base dropped the current screenshot from the prompt. Signed-off-by: Linglin Jing <[email protected]> * fix(osworld): propagate context-overflow errors in the NeMo RL profile Without propagate_context_overflow_errors, vllm_model turns an engine context refusal into an empty length reply, so context_overflow_policy and mask_context_limit never see it. Signed-off-by: Linglin Jing <[email protected]> * docs(osworld): cite the source of the copied OSWorld parser The parser functions come from mm_agents/nvidia/nemotron_agent.py in terrykong/OSWorld at 5d8c93592be588ab8e9909bed82f3b480fd4f533 (Apache-2.0). Signed-off-by: Linglin Jing <[email protected]> * revert(vllm_model): drop the endpoint_file polling change No OSWorld configuration sets endpoint_file; Gym NVIDIA-NeMo#3532 carries this fix with a test. Signed-off-by: Linglin Jing <[email protected]> --------- Signed-off-by: Linglin Jing <[email protected]> Signed-off-by: Linglin Jing <[email protected]> Co-authored-by: Linglin Jing <[email protected]>
This branch was previously deployed
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
Based on
mainat273d709ccc9dcbf0b95e5092bc1d7fa3f232fba8. The required foundations are merged; this is no longer a stacked integration branch. The final diff is limited to ten files underresponses_api_agents/osworld_agent/. The served-history tests import internal completion helpers from their defining module; the token-capture public API matches main byte for byte.This PR adds two capabilities:
DesktopEnv.reset(), check the declared module digest, and refuse replacement of OSWorld built-ins. Registrations are task-scoped and cleared on success, errors, and cancellation during environment cleanup. The remote Resources Server path rejects these plugins. Keepbinaryas the default reward, preserveraw, and add opt-insigned_v1: success earns 1; unsuccessfulDONEearns -1; other evaluated outcomes earn 0.This is a follow-up integration feature and a captured-history bug fix; no separate issue is required. The README documents the contracts, trusted-plugin boundary, selection behavior, and dependency provenance.
Review follow-up
Commit
629d61c7cf463250da2441f956cffa93fd00a2eaaddresses the two review threads:finally, including partial registration, reset, rollout, evaluator, environment-close errors, and cancellation while closing. Cleanup compares callable object identity, so aliases/partials are removed without deleting built-ins or later replacements. Registration ownership is keyed by module/name so registering a getter cannot authorize replacement of a same-named metric built-in. Sequential tasks on a reused Ray worker can reuse names with different implementations or share a getter with different metrics.terminal_response_idstill names the last observed non-empty served response, even when rejected; it is never silently reassigned to an earlier accepted call. A rejected terminal without a served ID fails response construction rather than enabling false fallback attribution.For RL selection,
returned_historyconsumes accepted output;all_capturedexplicitly permits rejected captured attempts, subject to completion/evidence checks. The paired RL selector rejects a rejected terminal absent from accepted history, and its metadata planner rejects selected continuations whose captured parent was omitted. This PR does not add those parents to the loss, rewrite prompts, fabricate roots, or change Gym runtime admission/reward to bypass those checks. Consumers must choose an explicit compatible selection policy for those cases.Dependencies and provenance
The required foundations are already in
main, and their merge commits are ancestors of this branch's base:8af4df7ef11c874b226416352bfThe existing OSWorld source dependency is unchanged from this main base: both the agent's
pyproject.tomland the Resources Server'spyproject.tomlreference the public JeffPengCoder/OSWorld fork atf32ab2b74. A fresh managed CI environment installs that source archive; it does not require access to a private repository or private VM assets. Plugin/reward/history unit tests use stand-ins rather than a live desktop; an actual rollout still requires the OSWorld runtime and desktop assets.The original experimental integration also carried #3368, the separate optional simple-agent compaction migration, and #4823, shared HTTP-client shutdown and wildcard-host fixes. #4823 subsequently merged as
9d6e0c282; #3368 remains separate. Neither is bundled here or required to merge these taskgen/reward/served-history changes. OSWorld's own history policy does not depend on the optional simple-agent compaction package.The two original changes are preserved as
df6c3741aand37b2eb59c;bea228184adds documentation and format-only cleanup, and629d61c7ccontains this review follow-up. The four original commits remain intact and have DCO sign-off. Two additional signed merge commits synchronize main without rewriting those commits. The leaf-package review fix removes the temporary completion-helper exports, so the final diff contains no Gym core changes. This additional signed follow-up isfaffcd6c27ef254f0fa5db7cb2a6cfca0ea4cf1e. This branch does not modify Gym core, sandbox providers, model servers, dependencies, lockfiles, or deployment scripts.Compatibility and scope
taskgen_pluginsare unaffected.signed_v1is opt-in and does not penalize reaching the horizon withoutDONE; it is not a recommended benchmark default. Reported success/raw-score metrics remain separate from this reward mapping.returned_historyloss membership intentionally changes for rejected attempts. Full capture evidence and explicitall_capturedselection remain available. Do not compare training recipes without recording the selection policy.Leaf-package review fix (2026-11-06)
Current head:
faffcd6c27ef254f0fa5db7cb2a6cfca0ea4cf1e.Apply the exact minimal patch proposed by Yi-Fu in review: remove the added
TYPE_CHECKINGimport and the two facade exports fromnemo_gym/models/token_capture/__init__.py, and import those internal helpers directly fromnemo_gym.models.token_capture.completionin the OSWorld served-history test. The public-API facade checker governs already-exported names; a test-only helper does not need a public export. The token-capture public API is now byte-identical to main, and the final PR diff returns to the ten OSWorld-agent files.The previous synchronization introduced a real regression. Resolving every public token-capture name loaded
ChatCompletionsConverter, OpenAI and httpx;test_package_is_dependency_free_leaffailed. The original local selection omitted that invariant. The authorized CI run on9e2e3016a5141000a275a8f6d38299fe77cd786ereported 1 failed, 5469 passed, 67 skipped, 33 warnings and 24 passed subtests in 337.88 seconds in Core shard 2. Its sole failing test was the leaf-package check (leaf package pulled in: httpx,openai); the two aggregate gates then failed. All eight server-suite shards passed.Validation of this fix:
pre-commit run --all-files --show-diff-on-failureandgit diff --check: passed on the PR branch before commit. No unrelated hook changes remained. DCO sign-off is included./ok to testauthorization named9e2e3016a5141000a275a8f6d38299fe77cd786e; repository rules require authorization of an unverified new head separately.Main synchronization (2026-11-05; historical synchronization head)
Synchronization head:
9e2e3016a5141000a275a8f6d38299fe77cd786e. Main:273d709ccc9dcbf0b95e5092bc1d7fa3f232fba8. Main is an ancestor of the branch (0 commits behind). The original four signed feature/review commits are preserved; the update uses two normal merge commits and no force push. Main advanced by one commit during validation, so that increment was included as well._build_response. Keep both the servedterminal_response_idand main's typed admission/sandbox failure fields.ChatCompletionsConverterand current package imports. This synchronization head temporarily exported two completion helpers throughnemo_gym.models.token_capture; the later leaf-package review correctly identified that the export violates the dependency boundary. The follow-up below removes those exports without changing the helper implementations.action_parser.py,adapter_agents.py,history_policy.py, androllout_outcome.py. Plugin and reward modules match the original PR byte for byte. Eight function AST comparisons preserve accepted-history/terminal handling, existing normalization/recovery, and main's failure-reporting helpers.Validation:
pre-commit run --all-files --show-diff-on-failureandgit diff --check main...HEADpassed.5193f9c3b2eca06e444acd430ad2c86824aff85e): 1655 passed, 6 failed, covering OSWorld agent, Resources Server, benchmark, completion/served-ID/ledger/external-capture, public API/facade, layering and import-migration checks. Four failures were localhost bind restrictions; all 4 passed when repeated with localhost permissions. This resolves the same 1661 test identities to 1659 passed, 2 remaining failures; it is not a claim that the first full command exited successfully.benchmarks/osworld/tests/test_run_scripts.py::test_managed_osworld_agent_installs_opensandbox_sdk: it expectsnemo-gym[dev]but the base declaresnemo-gym[dev,ray]. The same assertion was freshly reproduced on unmodified mainb625dcc8b4ff274b1855548e118c84487ba406cd; the relevant source remains unchanged in the last main increment.resources_servers/osworld/tests/test_import_runtime.py::test_desktop_runtime_imports_with_cpu_torch: this local test environment does not installdesktop_env, so the runtime-import check cannot pass here. It is not counted as passed or silently skipped.Earlier review-fix validation (
629d61c7cf463250da2441f956cffa93fd00a2ea)Local checks on that earlier review-fix source, Python 3.13.14:
benchmarks/osworld/tests/test_run_scripts.py::test_managed_osworld_agent_installs_opensandbox_sdk: it expectsnemo-gym[dev], but the unchanged base declaresnemo-gym[dev,ray]. The same failure was previously reproduced in a clean worktree at the main base. The test and installation inputs remain unchanged; no unrelated fix is included.bea228184in an isolated Python process makes all 13 selected behavioral regression cases fail, covering cross-task leakage and rejected/synthetic history. Current source passes those cases.6e68b1791, the revision cited in review, executed its actual call selectors and unchanged CPU metadata-planner function with current Gym schemas. Six cases passed: normalreturned_history; normalall_captured; rejected-terminal rejection underreturned_history; rejected-terminal acceptance underall_captured; missing-rejected-parent rejection underreturned_history; and valid ancestry underall_captured. This is a metadata/selection check, not tensor reconstruction or optimizer validation.pre-commit run --all-files, focused Ruff checks, andgit diff --check: passed; no unrelated hook changes remained.Historical real-model evidence: the original integration tree completed 31 optimizer steps of OSWorld GRPO training with Nano Omni, NeMo-RL #4124 + #4200,
all_capturedselection, 200-step episodes, and 32 rollouts per step. This predates the review fix and is not a fresh qualification of this head. A fresh live-model/VM rollout and GPU training were not run for this follow-up; the new checks do not establish score equivalence or end-to-end training throughput.There are no outstanding prerequisite PRs for this scope. Normal review and required CI still apply; upstream CI for the new head must be checked independently of local validation.