Skip to content

fix(http): build worker clients without parsing unrelated argv - #5093

Merged
AdamRajfer merged 1 commit into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/http-client-worker-config
Oct 26, 2026
Merged

AdamRajfer merged 1 commit into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/http-client-worker-config

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

Building Gym's global HTTP client in a Ray task worker currently parses the worker's unrelated command-line arguments and can exit with SystemExit(2). Read the process's cached or injected Gym configuration instead, and use default client limits when neither exists. Explicit parser configuration or a custom parser class still opts into parsing.

A process without cached/injected configuration no longer implicitly loads env.yaml or +global_aiohttp_* command-line overrides. For example, a per-host limit in env.yaml is not inherited by a Ray worker; inject Gym configuration or explicitly pass a parser when those limits are required. The OpenSandbox configuration comment documents this boundary.

flowchart LR
    A[Build HTTP client] --> B{Cached or injected config?}
    B -->|Yes| C[Use configured limits]
    B -->|No| D{Explicit parser supplied?}
    D -->|Yes| E[Parse explicitly]
    D -->|No| F[Use defaults without parsing argv]
Loading

Extracted from #4815 as requested in review. Related workarounds: #4209 and #3765. This change does not install Ray or change orchestration; the driver-install change remains in #4815. Prefer landing this fix first.

Validation: 253 HTTP/configuration/telemetry tests pass, including explicit parser configuration. An actual Ray worker constructed the client and completed an HTTP request without parsing its worker arguments. The Ray-install change passes 328 tests separately; the two changes together pass 581 tests.

@AdamRajfer AdamRajfer self-assigned this Oct 26, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 26, 2026 19:48
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:core Shared APIs, servers, telemetry, health, and registries bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Oct 26, 2026
@AdamRajfer
AdamRajfer added this pull request to the merge queue Oct 26, 2026
@ananthsub

ananthsub commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

LGTM!

@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/40406800625

Merged via the queue into NVIDIA-NeMo:main with commit 5e07f27 Oct 26, 2026
55 of 58 checks passed
@AdamRajfer
AdamRajfer deleted the fix/http-client-worker-config branch October 26, 2026 22:21
jinglinglingling pushed a commit to jinglinglingling/Gym that referenced this pull request Nov 16, 2026
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]>
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

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

Labels

area:core Shared APIs, servers, telemetry, health, and registries bug Something isn't working 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