Skip to content

build: bound huggingface-hub below 2 in the dev extra - #4362

Merged
linj-glitch merged 1 commit into
mainfrom
alexandery/build-bound-huggingface-hub
Oct 12, 2026
Merged

linj-glitch merged 1 commit into
mainfrom
alexandery/build-bound-huggingface-hub

Conversation

@alexandery-nvidia

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds huggingface-hub<2 to the dev extra. huggingface-hub 2.x installs httpx2, which Starlette's TestClient prefers over httpx when both are present; the OpenAI client's http_client and Gym's httpx cookie helpers then fail in the server test suites.

The committed uv.lock already resolves huggingface-hub to 1.33.0, so this bound changes no installed version today; it keeps a future re-resolution from crossing into 2.x. uv lock --check passes.

Why a separate PR

The same bound was carried as a commit on the branches of #3973, #3976, and #3978 while they were validated against main (the maintainer's "build: bound server test dependencies for SDK compatibility"). Review on those PRs asked for the dependency change to live in its own PR that the feature PRs rebase on; those branches no longer carry it.

Tests

uv lock --offline --check passes. No code change.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes.
  • Pre-commit checks pass locally (pre-commit run --all-files).
  • All commits have DCO sign-off (git commit -s).

🤖 Generated with Claude Code

@alexandery-nvidia
alexandery-nvidia requested a review from a team as a code owner October 10, 2026 03:00
@copy-pr-bot

copy-pr-bot Bot commented Oct 10, 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.

huggingface-hub 2.x installs httpx2, which Starlette's TestClient prefers over
httpx when both are present; the OpenAI client's http_client and Gym's httpx
cookie helpers then fail in the server test suites. The committed lock already
resolves huggingface-hub to 1.33.0, so this bound only keeps a future
re-resolution from crossing into 2.x. It was first carried as a commit on the
branches of #3973, #3976, and #3978 while they were validated against main;
review asked for it to live in its own pull request, and those branches no
longer carry it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
@alexandery-nvidia
alexandery-nvidia force-pushed the alexandery/build-bound-huggingface-hub branch from ad96fb4 to 37537bd Compare October 10, 2026 03:02
@yaoyu-33 yaoyu-33 added area:build Packaging, dependencies, containers, and releases bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 10, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 12, 2026

@zyzhou5 zyzhou5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zyzhou5

zyzhou5 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

/ok to test 37537bd

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 12, 2026 18:58
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 12, 2026

@linj-glitch linj-glitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the dev-only huggingface-hub bound and matching lock metadata. The locked versions do not change, and the HF 2.x/httpx2 incompatibility with the OpenAI test client was reproduced. No blocking issue introduced by this PR.

Validation: uv 0.11.29 lock --offline --check passed; 265 focused server/client tests passed; full pre-commit passed. The failed Harness conformance P0 check has the same OpenCode/Pi/Codex failures as the base commit (head check https://github.com/NVIDIA-NeMo/Gym/runs/114964846084; base check https://github.com/NVIDIA-NeMo/Gym/runs/114132510755). Core CI and all eight server shards passed. Model rollout is N/A for this dependency-only constraint.

Reviewed with Codex, including an independent source/history pass.

@linj-glitch
linj-glitch added this pull request to the merge queue Oct 12, 2026
@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/38321648673

Merged via the queue into main with commit 76c2b10 Oct 12, 2026
52 of 54 checks passed
@linj-glitch
linj-glitch deleted the alexandery/build-bound-huggingface-hub branch October 12, 2026 23:36
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 14, 2026
…o#3976)

## What does this PR do?

Adds `drop_unrepresentable_request_fields` to `VLLMModelConfig` (default
`false`, today's behavior). It decides what the
Responses-to-Chat-Completions conversion does with a request field that
has no Chat Completions representation.

Today `ResponsesConverter.responses_to_chat_completion_create_params`
refuses such a request with `NotImplementedError`, so a caller can route
it to a server that serves Responses natively. For a model server that
has no such route, the refusal ends the rollout over a field the backend
never needed. With the setting on, the reporting-only fields are dropped
(logged at debug level) and the conversion proceeds:

- a non-empty `include`, whatever its values; it names extra fields to
report on the response object (an empty `include` is already treated as
absent on `main` since NVIDIA-NeMo#3314);
- `reasoning.summary` and its deprecated name
`reasoning.generate_summary`, which ask for a summary of the reasoning
on the response object; `reasoning.effort` still travels as
`reasoning_effort`;
- a message `phase`, which labels the message rather than changing its
content.

An image part in a `function_call_output` is replaced with the text
placeholder `[image omitted from tool output]` in the tool message, so
the surrounding text parts keep their positions and the conversion
proceeds; this one does change the prompt the model sees, which is why
the placeholder says only what happened to the tool's output. Every
other unrepresentable field is still refused, `reasoning.context`
included: it tells the provider which earlier reasoning items to render
back to the model, which the conversion cannot honor (it renders every
reasoning item the request carries and leaves the rest to the chat
template).

`VLLMModel.responses` and
`VLLMModelWithCompaction._context_compaction_chat_params` pass the
setting to the converter; the setting has no effect when
`is_responses_native` is on, because that path skips the conversion. The
vLLM model-server configuration reference documents it.

Concrete trigger: the Codex CLI sends `include:
["reasoning.encrypted_content"]` and `reasoning.summary` on every
request, and some of its tools return an image part in their output;
each of those ended a session against a vLLM chat backend.

## Issue

No issue filed; the refusals were observed in training transcripts of
the Codex CLI harness against a vLLM chat backend.

## Validation

- `tests/unit_tests/test_responses_converter.py`,
`responses_api_models/vllm_model/tests/test_app.py`,
`responses_api_models/vllm_model_with_compaction/tests/test_app.py`: 420
passed. New tests: an interleaved tool output (text, image, text)
becomes the exact three-part message with the placeholder in place and
the drop logged at debug; other part types are still refused; a message
`phase` is refused by default and dropped when configured; `include` is
dropped on the plain and the streaming path; `reasoning.summary` and
`reasoning.generate_summary` are dropped while the effort travels; every
`reasoning.context` value is still refused; the compaction server
refuses `include` with the setting off and serves the request with it
on, with the exact prefix still reaching the backend.
- Full `tests/unit_tests` and every `responses_api_models/*/tests` suite
on this branch: the only failures (opensandbox, telemetry, and the two
servers that import `vllm`) are the same as on `main` f128d43 in the
same environment.
- `ruff check` and `ruff format --check` on the changed files: clean.
- Rollout evidence: this setting has run for weeks in a downstream fork
training with the OpenCode and Codex harnesses through this model
server; with it on, no Codex session ends on one of these fields.

### Review follow-up

Rebased onto `main` f128d43. The `huggingface-hub<2` bound that the
validation merges had added to this branch lives in NVIDIA-NeMo#4362 now.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: alexandery <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: yaoyu-33 <[email protected]>
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 15, 2026
…Mo#3978)

## What does this PR do?

With `propagate_context_overflow_errors` on, the vLLM model server lets
the engine's HTTP 400 reach the harness when a request no longer fits
the model's context window. On `main` the harness receives vLLM's raw
body, whose `code` is the integer 400. An OpenAI-compatible harness
(Codex, OpenCode) classifies a context overflow by the string code
`context_length_exceeded` inside OpenAI's `error` envelope, so it cannot
recognize the refusal and compact its history; on a streaming
`/v1/chat/completions` request that has passed its keepalive, the error
event carries the same integer code.

1. **OpenAI's error envelope for a propagated refusal.**
`VLLMModel._should_propagate_upstream_http_error` returns false for an
error the server marked as a propagated length refusal, so the shared
error handler (NVIDIA-NeMo#4285) lets it through to the server's own middleware,
which answers `{"error": {"message": <the engine's message, verbatim>,
"type": "invalid_request_error", "param": <the engine's param>, "code":
...}}` with the engine's status. `context_overflow_error_fields` in
`nemo_gym.base_responses_api_model` reads the message and `param` from
vLLM's nested `error` object (0.10.1 and later), from the flat top-level
`message` of older engines, or from the raw text, so no information is
lost. The mark is one attribute, `PROPAGATED_REFUSAL_CODE_ATTRIBUTE`:
its presence marks the error (`is_propagated_refusal`) and its value is
the envelope code. A streaming `/v1/responses` request gets the same
HTTP 400 before the stream, as `main` answers it since NVIDIA-NeMo#4285; nothing
has been sent yet, so an HTTP status is the right answer and the one
OpenAI itself gives.
2. **The code says whether compacting the prompt is the remedy.** A body
that names the context window carries `code: "context_length_exceeded"`:
vLLM 0.29.0's two wordings ("This model's maximum context length is ..."
and "Input length (N) exceeds model's maximum context length (M)."), the
engine's "decoder prompt ... is longer than the maximum model length",
and llama.cpp's `exceed_context_size_error` type and phrases. A body
that only names the output-token parameter ("max_tokens must be at least
1", "max_completion_tokens=N cannot be greater than max_model_len")
carries `code: null`: lowering the parameter fixes those, shortening the
prompt does not, so the harness reports an ordinary invalid request with
the engine's sentence instead of compacting. The classification itself
stays the shared `_is_context_length_error`; it now also recognizes
`max_completion_tokens` and "maximum model length", two length refusals
that the f128d43 base answered with a plain HTTP 400 from the shared
handler. With the setting off they are now absorbed into an empty
completion with `finish_reason: "length"` like every other recognized
refusal (see below); with it on they carry the envelope,
`context_length_exceeded` for the "maximum model length" wording and
`code: null` for the `max_completion_tokens` parameter error.
3. **The chat-SSE error after the keepalive carries the envelope.** Once
a streaming `/v1/chat/completions` request has committed its headers, a
marked refusal is reported as `event: error` with the same message,
`param`, and code, and logged as one warning instead of a traceback.

The default (`propagate_context_overflow_errors: false`) keeps absorbing
a recognized refusal into an empty HTTP 200 completion with
`finish_reason: "length"`. One consequence of the wider classifier: the
`max_completion_tokens` and "maximum model length" phrasings are now
recognized too, so with propagation off they are absorbed the same way,
where before this change they fell through to the shared HTTP 400
handler. With propagation on, a parameter-only error keeps `code: null`
and a context-window error carries `context_length_exceeded`.

### Relation to the model-execution record

`ModelExecutionOutcome` records an absorbed overflow as
`local_response_reason: "context_length_exceeded"` on the observability
model-call record, and that path is unchanged here. This PR concerns the
propagated case only, which is what the client sees.

## Issue

No issue filed; observed while training with the Codex CLI through the
streaming `/v1/responses` route, which could not classify the overflow
and retried the request.

## Validation

- `responses_api_models/vllm_model/tests/test_app.py`,
`tests/unit_tests/test_base_responses_api_model.py`,
`tests/unit_tests/test_responses_api_model_streaming.py`,
`tests/unit_tests/test_chat_completions_streaming.py`: 659 passed. The
propagation test runs six engine bodies (vLLM 0.29.0's two overflow
wordings with their `param`, the engine's "maximum model length"
message, llama.cpp's typed refusal, and the two output-token parameter
errors) on both engine routes and both APIs, with the setting on and
off; new tests cover the HTTP 400 on a streaming `/v1/responses`
request, the envelope in the chat-SSE error after the keepalive, and the
message, `param`, and code extraction from the nested, flat, and raw
bodies.
- Full `tests/unit_tests` and every `responses_api_models/*/tests` suite
on this branch: the only failures (opensandbox, telemetry, and the two
servers that import `vllm`) are the same as on `main` f128d43 in the
same environment.
- `ruff check` and `ruff format --check` on the changed files: clean.
- Rollout evidence: the envelope has run for weeks in a downstream fork
training with OpenCode and Codex harnesses under token-id capture with
`propagate_context_overflow_errors: true`. With it, Codex fails the turn
without an item and OpenCode records the error and exits, so a session
that reaches the window ends cleanly and trains up to its last completed
call instead of retrying the refused request.

### Review follow-up

Rebased onto `main` f128d43 after NVIDIA-NeMo#3371 (the shared
`_is_context_length_error`) and NVIDIA-NeMo#4285 (the shared error handler and the
HTTP 400 before a stream), which changed the shape of this change: the
envelope is produced through the propagation hook, and the terminal
`response.failed` event of the earlier revision is gone. The
`huggingface-hub<2` bound that the validation merges had added to this
branch lives in NVIDIA-NeMo#4362 now.

`main` 4518db9 is merged into the branch (c19c51c, 2026-10-14). The
one conflict was the FastAPI import line of
`responses_api_models/vllm_model/app.py`; both sides are kept, and
`Response` is dropped from the import because the envelope is returned
as a `JSONResponse`, so nothing in the module constructs a bare
`Response` any more.

yaoyu-33's suggestion of 2026-10-12 (00ad0f0): the boolean marker and
the code attribute are one attribute whose presence is the mark and
whose value is the code (`None` for an output-token parameter refusal
stays distinct from an unmarked exception); the marking helper, the
shared-handler hook, the HTTP middleware and the chat-SSE path read it,
and the extraction test covers the unmarked, `None`-code and
overflow-code states.
`tests/unit_tests/test_base_responses_api_model.py` 106 passed,
`responses_api_models/vllm_model/tests` 439 passed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: alexandery <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
linj-glitch added a commit to linj-glitch/Gym that referenced this pull request Oct 15, 2026
…VIDIA-NeMo#3973)

## What does this PR do?

Three related changes in `nemo_gym/token_id_capture`, so that a consumer
of a rollout record can tell a trajectory that ended at the output-token
budget from one that ended on its own.

1. **Each locally captured record carries its call's finish reason.**
`TokenEntry` gains `finish_reason`, usually in the Chat Completions
vocabulary (`stop`, `length`, `tool_calls`, `content_filter`; other
engine values pass through unchanged). `response_finish_reason` in
`records.py` derives it from either served payload shape: a chat payload
states it directly as `choices[0].finish_reason`; a Responses payload
carries no finish reason, so `incomplete_details.reason` is mapped back
through the converter's own mapping (`max_output_tokens` to `length`,
`content_filter` to itself), and a completed Responses payload stopped
at a tool call (`tool_calls`) or at the end of its text (`stop`).
`capture_tokens` in `sink.py` stamps it on every record written by the
local capture path. A record written without the field reads as `None`,
so existing stores stay readable, and the conformance kit's entry
carries a non-default finish reason so a store that drops the field
fails the round trip.
2. **The rebuilt response reports a cut terminal as incomplete.**
`project_main_chain_response` in `builder.py` sets `status:
"incomplete"` with `incomplete_details.reason: "max_output_tokens"` when
the delivered chain's terminal call stopped for `length`, and
`incomplete_details.reason: "content_filter"` when it stopped for
`content_filter`: the verdicts the Responses converter already gives a
served chat completion that ended the same way. Only the terminal call
decides: an earlier `length` stop was extended by a later call and does
not end the chain. Any other finish reason leaves the status unset, as
before. When terminal attribution chose the terminal call among
token-identical retries by call-id order alone and those twins recorded
different finish reasons, the verdict is withheld too
(`TerminalAttribution.finish_reason_resolved`, passed to
`project_main_chain_response`): the delivered tokens are the same either
way, but the status would otherwise depend on which twin drew the
smaller id. A witness that singles out one serving (an explicit id, or a
response id, item id or content fingerprint matching exactly one entry)
keeps that serving's verdict.
3. **Delivery carries that verdict onto the rollout record.**
`finalize_rollout_token_capture` in `delivery.py` replaced only
`response.output`, so the builder's verdict never reached the record. It
now also sets the harness response's `status` and `incomplete_details`
from the rebuilt response when the harness reported `completed` or no
status; a harness that already reported `incomplete` or `failed` keeps
its own, more specific, verdict. The readers that see it without any
change are Gym's own aggregate-metrics path, which reads
`response.incomplete_details`, and the downstream NeMo RL fork, whose
agent harness finalizes the capture in-process and reads the verdict
there. Upstream NeMo RL does not see this verdict yet: at
NVIDIA-NeMo/RL#4449's head, `NemoGym` runs capture in receipt mode
(`external_staging: true`, `rebuild_response: false`) and collects
through `run_examples`, so `finalize_rollout_token_capture` never runs
for it and NVIDIA-NeMo#4449 counts only a status the harness set itself. Upstream
RL gets the verdict once NVIDIA-NeMo#4366 carries the finish reason through
worker-custody staging and RL's receipt consumer applies it.

### Scope

The finish reason is recorded on the local capture path only. Under
external staging (worker custody) `capture_tokens` returns before
building a record, and the staged `CallRecord`, the ledger, and
`staging/rebuild.py` carry no finish reason, so a chain rebuilt from
staged records reports no verdict. Carrying the finish reason through
the staging record is the follow-up NVIDIA-NeMo#4366, stacked on this branch.

## Issue

No issue filed; the missing status was found while training with agent
harnesses under token-id capture, where a session cut at the output
budget was indistinguishable from a completed one in the rebuilt
response.

## Validation

- `tests/unit_tests/test_terminal_attribution.py`,
`tests/unit_tests/test_trajectory_builder.py`: 97 passed, including the
new tests for the `content_filter` verdict and for delivery with a
harness status that is absent, `completed`, `failed` (left untouched),
and `incomplete` for the harness's own reason (left untouched); the
earlier tests for `response_finish_reason` on both payload shapes, the
recorded reason on the `/v1/responses` and `/v1/chat/completions`
capture routes, the store round trip with an older record lacking the
field, and the terminal-versus-earlier `length` rule stay.
- Full `tests/unit_tests` and every `responses_api_models/*/tests` suite
on this branch: the only failures (opensandbox, telemetry, and the two
servers that import `vllm`) are the same as on `main` f128d43 in the
same environment.
- `ruff check` and `ruff format --check` on the changed files: clean.
- Rollout evidence: these changes have run for several weeks in a
downstream fork training with OpenCode and Codex harnesses under
token-id capture; the rebuilt responses of sessions cut at the output
budget carry `status: "incomplete"`, and the trainer's truncation count
reflects them.

### Review follow-up

Rebased onto `main` f128d43. The dependency edits that the validation
merges had added to this branch live in NVIDIA-NeMo#4362 now.

yaoyu-33's follow-up of 2026-10-12 (744e198): the finish-reason rule
for token-identical retries described in item 2, with regression tests
at the attribution level (both id orders; the explicit and response-id
witnesses), through `_assemble` (both orders; twins that agree keep the
verdict), and on the builder.
`tests/unit_tests/test_terminal_attribution.py`,
`test_trajectory_builder.py`, `test_token_id_capture.py`: 290 passed.

ananthsub's notes of 2026-10-15 (5ed1608): item 3 now names the
readers that see the delivered verdict and the one that does not
(upstream NeMo RL's receipt mode, which needs NVIDIA-NeMo#4366 plus a
receipt-consumer change on the RL side), the Scope section links NVIDIA-NeMo#4366,
and a delivery test where the harness reports `incomplete` for its own
reason (`result_missing`) pins the second half of the guard.
`tests/unit_tests/test_terminal_attribution.py`: 65 passed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: alexandery <[email protected]>
Signed-off-by: Lin Jia <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Lin Jia <[email protected]>

This branch was previously deployed

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

Labels

area:build Packaging, dependencies, containers, and releases bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface 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.

5 participants