Skip to content

fix(health): preserve provider repetition termination - #5975

Merged
mpatel31415 merged 6 commits into
NVIDIA-NeMo:mainfrom
mpatel31415:fix/provider-repetition-health
Nov 12, 2026
Merged

mpatel31415 merged 6 commits into
NVIDIA-NeMo:mainfrom
mpatel31415:fix/provider-repetition-health

Conversation

@mpatel31415

@mpatel31415 mpatel31415 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

A stock vLLM repetition stop can use finish_reason: "repetition" and stop_reason: "repetition_detected". Gym rejects that finish reason before health can inspect it, and several transport paths lose the optional stop cause.

Normalize only the known repetition finish reason to SDK-compatible stop, retaining native_finish_reason. Preserve stop/finish evidence through conversion, completions translation, terminal Chat SSE and capture reconstruction. Health classifies explicit repetition as runaway and response-faulted even when partial text or tool output was retained.

Preserve the optional native cause through Anthropic Messages JSON, SSE and persisted capture without changing the standard stop category, content or usage. When one call has missing output, retain conclusive runaway findings on other exactly bound calls and keep the missing-output uncertainty. A length limit alone does not prove unseen output was unusable. Update the health catalog to describe both explicit repetition and length-limit cases.

Keep complete-verdict checks effective in False Statement, FrontierScience and Agentic IF. A repetition-stopped judge reply must remain unfinished even when its SDK category is stop and its partial output looks valid. Agentic IF SSE replay retains only the exact repetition signals; ordinary decoded receipts, frozen policy assets, cache identity and retry rules remain unchanged. Add stock-payload regressions for the default vLLM chat path and both API endpoints.

The adapter-specific Messages integration replays live in the VLLM server suite, while generic Messages and zero-value capture checks stay in core. This preserves all route/capture/health assertions and keeps core coverage within its actual test scope. Server tests use the exported models, rollouts and trajectory facades; coverage thresholds and exclusions are unchanged.

The provider contract is documented in vLLM#35451, commit 25e02647c272eeb0ec076884d046816bdb86159e. This independently implemented, directly reproduced compatibility defect needs no separate issue.

Validation

2,906 relevant tests passed on the final source, with component source hashes bound to the reviewed patch.

The model, types, converters, Messages transport, streaming, health and public API contract group passed 2,444:

python -m pytest tests/unit_tests/core/test_responses_api_types.py responses_api_models/vllm_model/tests/test_app.py tests/unit_tests/rollouts/test_rollout_health.py tests/unit_tests/models/test_chat_completions_converter.py tests/unit_tests/models/test_chat_completions_streaming.py tests/unit_tests/models/test_anthropic_converter.py tests/unit_tests/models/test_responses_api_model_messages.py tests/unit_tests/test_public_api_facades.py -q

The separate component runs passed:

  • python -m pytest resources_servers/false_statement_judge/tests/test_app.py -q: 55.
  • python -m pytest resources_servers/frontierscience_judge/tests/test_app.py -q: 102.
  • python -m pytest resources_servers/agentic_if_realworld/tests -q: 305.

pre-commit run --all-files and git diff --check passed on the final test-ownership followup. make docs-check passed on the unchanged docs/source (zero errors and one warning). The final 2,444-test run includes 865 public API contract checks and all 1,579 runtime cases. The 25 adapter cases also passed independently; the other 462 component cases retain their exact source bindings. The direct CLI group validates process-pool cases without the initial stdin launcher's serial fallback.

Retained negative controls reproduce rejected stock payloads, default-chat failures (4 cases), lost metadata and accepted incomplete judge replies. Agentic IF produced 12 genuine failures while all 13 ordinary metadata/cache controls passed. Additional retained negative controls expose lost Messages metadata (20 failures with 4 absent-metadata controls) and masked conclusive health findings (3 failures with 1 usable-output control). Tests exercise real SDK validation, endpoints, HTTP streaming/capture, SSE replay, raw-receipt binding and completion checks; mocking stays at external provider/config boundaries. Test-quality and independent source reviews passed.

Native CI and actual independent approval remain required before merge.

Rollouts

N/A: this is a provider-type, metadata and completion-check compatibility correction. No environment, agent or generation configuration changes are introduced. Controlled provider replays exercise the explicit termination branches.

Compatibility and benchmark impact

Retain text, usage and ordinary provider completion status. Unknown finish reasons remain invalid. Preserve the length/refusal/answered-overflow behavior from #4921. Consumers requiring complete verdicts must inspect the retained repetition cause in addition to the SDK category.

No repetition detector is enabled. Sampling, budgets, grading criteria, retry policies and health thresholds are unchanged. This does not prevent or repair model reasoning loops; it makes explicit provider stops observable and keeps unfinished verdicts out of scoring.

Review and CI can proceed. Hold merge until the dependent downstream consumer compatibility update is confirmed landed.

Checklist

  • I have read the contributing guidelines.
  • The change is focused.
  • Tests added or updated and pass locally.
  • Documentation updated.
  • Pre-commit checks pass locally.
  • No new source files require additional SPDX headers.
  • All commits have DCO sign-off.

Accept the known vLLM repetition finish reason using the SDK stop category and retain the native termination cause across conversion, streaming and capture. Explicit repetition remains unhealthy even with partial usable output, while ordinary completion status and unknown-reason validation stay intact.

Validate the public-tree patch with 1491 affected tests, all-files pre-commit and Fern docs checks. This passive correction enables no detector and changes no sampling, budgets, grading, retries or health threshold.

Signed-off-by: Martyna Patelka <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 10, 2026 22:56
@mpatel31415 mpatel31415 added bug Something isn't working area:model Model servers, inference providers, and model adapters needs-review PR is ready for code review and waiting on a reviewer complexity:high Cross-component or shared-contract change with a large review surface labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

@mpatel31415
mpatel31415 marked this pull request as draft November 10, 2026 23:02
@mpatel31415 mpatel31415 removed the needs-review PR is ready for code review and waiting on a reviewer label Nov 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE — two RISK findings and one documentation NOTE.

Repetition evidence is still lost through the supported Messages endpoint, and an unrelated call with a missing response can suppress an otherwise conclusive repetition finding. The check catalog also needs to describe the new condition.

I inspected all 13 changed files and their directly affected conversion, streaming, capture, and health paths, then consolidated the three delegated reviews. This was a static review; I couldn't independently execute the reported tests.


Inline comments (escaped v1):

  • nemo_gym/models/anthropic_converter.py line 535: RISK — Preserve repetition evidence through the Messages endpoint.

    The new normalization lets a stock choice with finish_reason="repetition", stop_reason="repetition_detected", and partial answer text reach the supported /v1/messages route. However, the shared Messages handler passes the converted Responses reply through this fixed mapping, which drops both native fields. The served and captured message has only stop_reason="end_turn"; the adapter's execution record also records the normalized stop. Consequently, an exactly bound call with usable partial output produces neither a runaway finding nor a response fault. Chat and Responses retain the cause, but Messages clients lose it in both render modes.

    Could you preserve the optional native fields without replacing the ordinary Anthropic stop reason? A small correction at this return is:

    payload = message.model_dump(mode="json", exclude_none=True)
    for field in ("native_stop_reason", "native_finish_reason"):
        value = getattr(response, field, None)
        if value is not None:
            payload[field] = value
    return payload

    The required dependent change is to retain those same fields in the Messages SSE reconstructor's allowlist:

    message = {
        k: msg[k]
        for k in ("id", "type", "role", "model", "stop_reason", "native_stop_reason", "native_finish_reason")
        if msg.get(k) is not None
    }

    The Messages SSE synthesizer already copies the complete message shell. These changes would therefore keep the evidence in both JSON capture and reconstructed SSE capture, where the health helper already recognizes top-level native fields. Preserve output, usage, and the existing end_turn/tool_use/max_tokens/refusal mapping; don't substitute a Chat stop cause into Anthropic's stop_reason.

    Proposed acceptance, not executed: use a fake vLLM backend returning the stock choice above, request the correlated /v1/messages route with stream=false and stream=true, and inspect CaptureStore. Both captures should retain the two native causes and partial text; after binding the call in a saved rollout, expect one runaway finding and that call in responses.faulted. Also cover repetition finish evidence without a stop cause and a repetition stop with ordinary finish_reason="stop". For ordinary stops, preserve integer 0, omit absent native fields, and produce no repetition finding. Retain the existing mapping assertions: tool output maps to tool_use, output limits to max_tokens, and content-filter refusals to refusal. Verify the suggested code before adopting it.

  • nemo_gym/rollouts/rollout_health.py line 259: RISK — Don't let an unrelated missing response hide explicit repetition evidence.

    With two exactly bound calls—repeat containing response={"output_text":"kept","native_stop_reason":"repetition_detected"}, and unknown containing finish_reason="length", response=None—this continue skips the entire runaway check. The new repetition branch never runs, so the rollout is unobserved rather than unhealthy despite conclusive evidence for repeat. This affects multi-call saved artifacts; the single-call repetition tests pass because they don't encounter this guard.

    Could you retain the uncertainty marker while evaluating calls with conclusive evidence? The smallest complete correction has two parts:

    1. Here, retain unobserved.append(spec.id) but remove this continue.
    2. In _model_call_runaway_generation, require a saved response only in the length branch:
    if _is_repetition_stop(call)
    or (
        not _is_length_refusal(call)
        and call.get("finish_reason") in _LENGTH_LIMIT_FINISH_REASONS
        and call.get("response") is not None
        and not _response_has_usable_output(call.get("response"))
    )

    The invariant is that unknown length-call output must neither fabricate a finding nor hide another call's explicit repetition evidence.

    Proposed acceptance, not executed: save the two calls above with distinct IDs, matching turn references, positive token counts, and matching aggregate usage. Expect exactly one runaway finding for repeat, detail containing only the observed repetition stop, the check also listed as unobserved for unknown, and verdict unhealthy. Retain the existing missing-body assertion: a lone length call without a body remains unobserved with no runaway finding. Retain the length-refusal cases: a refused call stays exempt while a separate saved reasoning-only length call is flagged. Usable length-limited answers/tool calls must remain exempt; repetition-stopped answers/tool calls must remain flagged. Verify the suggested change before adopting it.

  • fern/versions/latest/pages/evaluation/rollout-health.mdx line 136: NOTE — Suggest updating the check catalog to include repetition.

    This row still defines runaway generation solely as a length-limited call without an answer/tool call, while the new implementation and new section also classify explicit repetition stops with usable output. Someone consulting the catalog alone gets the wrong condition.

    Suggested replacement:

    | `model_call_runaway_generation` | Policy-model call | An exactly bound policy-model call explicitly stopped for repetition, even with a saved answer or tool call, or reached its output limit and its saved response holds no answer and no tool call. Reasoning alone does not count as usable output; upstream length refusals are excluded. |
    

    Static acceptance: confirm the row distinguishes explicit repetition from ordinary length termination, retains exact binding and the reasoning-only rule, and doesn't imply that ordinary stops or usable length-limited answers/tool calls are runaway generations.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Keep existing complete-verdict requirements effective when a provider repetition cause is carried beside the SDK stop category. Preserve the exact repetition signals through SSE replay while keeping ordinary decoded receipts, frozen criteria, cache identity and retry rules unchanged.

Add raw-provider regressions for the default chat path and both API endpoints. Final affected checks pass: 1495 core/model/health/stream tests, 55 False Statement, 102 FrontierScience and 305 Agentic IF tests; all-files pre-commit and docs checks pass.

Signed-off-by: Martyna Patelka <[email protected]>
@mpatel31415
mpatel31415 marked this pull request as ready for review November 10, 2026 23:39
@mpatel31415 mpatel31415 added the needs-review PR is ready for code review and waiting on a reviewer label Nov 10, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 10, 2026 23:40

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP — no eligible findings in this follow-up.

I verified that all three findings from review 5851405374 are fixed:

  • Messages conversion and SSE capture reconstruction retain optional native termination evidence without replacing the standard Anthropic stop category, content or usage.
  • Health evaluation now retains conclusive findings alongside missing-output uncertainty. The length branch requires a saved response, so unknown output doesn't manufacture a finding.
  • The check catalog now distinguishes explicit repetition from length-limited responses without usable output.

I checked the relevant regression assertions, preservation cases and adapter-test collection path. I compared the subsequent changes with the previously reviewed tree and traced their directly affected paths; this wasn't a fresh whole-PR review. I found no introduced regression eligible above the historical moderate-impact ceiling.

This was static review. I couldn't execute tests or independently verify the reported validation, native CI results or downstream compatibility prerequisite. This approval doesn't clear the stated downstream merge hold.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@mpatel31415
mpatel31415 marked this pull request as draft November 11, 2026 01:45
@mpatel31415 mpatel31415 removed the needs-review PR is ready for code review and waiting on a reviewer label Nov 11, 2026
Use the models, rollouts and trajectory exports for the six capture, health and record imports, as required outside the core library. Preserve all helper bodies, assertions, parameter cases and the private trajectory fixture import.

The existing facade contract reproduces one failure before the import correction and passes all 865 cases after it. All 25 adapter regressions pass independently. Final validation passes 2444 affected runtime and API contract tests plus all-files pre-commit. No production behavior or coverage policy changes.

Signed-off-by: Martyna Patelka <[email protected]>
@mpatel31415
mpatel31415 marked this pull request as ready for review November 11, 2026 02:03
@mpatel31415 mpatel31415 added the needs-review PR is ready for code review and waiting on a reviewer label Nov 11, 2026
@mpatel31415

Copy link
Copy Markdown
Contributor Author

Corrected the six adapter-test imports in 6f2cc609673c73d6e076bfe6f049462b939f2c26 to use the exported models, rollouts and trajectory APIs, as required outside the core library. The private trajectory fixture import and every test body/assertion remain unchanged.

The final eight-module run passed 2,444 tests, including all 865 public API contract checks and 1,579 runtime cases. The 25 adapter cases also passed independently. All-files checks passed; production code, coverage thresholds and exclusions are unchanged. The other 462 component tests retain unchanged source bindings.

New-head native CI is required before merge; no aggregate coverage pass is inferred yet. The retained review history and dependent-consumer merge hold remain in effect.

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP — no eligible findings in this follow-up.

I compared the adapter-test import changes with the previously reviewed tree and traced the public exports. The six imports resolve to the same underlying implementations. The 25 Messages integration cases retain their helpers, parameters and assertions.

The previously verified fixes remain intact: Messages conversion and SSE reconstruction preserve native termination evidence; the two-call health regression retains conclusive findings alongside missing-output uncertainty; and the catalog distinguishes repetition from length-limited unusable output.

This was a scoped follow-up, not a fresh whole-PR review. I found no introduced regression eligible above the historical moderate-impact ceiling. This was static review: I couldn't execute tests or independently verify the reported validation, native CI or downstream compatibility. This approval doesn't clear the PR's stated downstream merge hold.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 11, 2026

@AdamRajfer AdamRajfer 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.

🤖 Adam’s AI assistant
I reviewed this for Adam.

Approving. Accepting the stock repetition finish instead of failing validation is the right call: a model that loops is a model result and should be scored and flagged by health, not turned into a 500 and retried as an infra fault. The served status is unchanged, judges keep repetition-stopped replies out of scoring, and the new tests fail with the production changes reverted.

Two non-blocking notes. The "stop but not repetition" check now lives in five places (false_statement_judge/app.py:229, frontierscience_judge/app.py:301, agentic_if_realworld/benchmark/scoring.py:235, transport.py:110, checks.py:911); a shared helper would keep the next judge that checks only finish_reason == "stop" from silently accepting a repetition-stopped verdict. Also, recovery's response-failure causes (truncated/empty/malformed) don't count a repetition stop with usable text while health's faulted does; fine as a follow-up.

Please keep the merge hold until the downstream compatibility change you mention has landed.

@mpatel31415
mpatel31415 added this pull request to the merge queue Nov 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/43242110023

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 12, 2026
@mpatel31415
mpatel31415 added this pull request to the merge queue Nov 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/43250557678

Merged via the queue into NVIDIA-NeMo:main with commit 268faf9 Nov 12, 2026
70 checks passed
@mpatel31415
mpatel31415 deleted the fix/provider-repetition-health branch November 12, 2026 15:52
JeffPengCoder added a commit to JeffPengCoder/Gym that referenced this pull request Nov 12, 2026
Include main through 268faf9 after the reviewed provider-repetition health
fix (NVIDIA-NeMo#5975) and Slurm allocation bookkeeping (NVIDIA-NeMo#6014) landed. The prior
GitHub test-merge reference still used the preceding main revision.

Preserve the WebArena layer and the dependent VisualWebArena ancestry.
The upstream provider/core additions receive targeted compatibility checks
and a rerun of the affected Web integration suites before publication;
verification is recorded separately after this source integration.

Signed-off-by: Jeff Peng <[email protected]>
gwarmstrong pushed a commit to gwarmstrong/Gym that referenced this pull request Nov 13, 2026
…IDIA-NeMo#6093)

* feat(eval): count repetition stops in the inspect's failure facts

Since NVIDIA-NeMo#5975 Gym keeps vLLM's repetition stop as native_finish_reason
"repetition" beside the SDK's "stop", and rollout health flags it. The
inspect still could not see it: the evidence collector keeps only a
fixed set of finish reasons and none of the response, so a call the
serving engine stopped for repetition read as an ordinary "stop".

The collector now flags each saved model call it finds stopped for
repetition (a "repetition" finish reason or a "repetition_detected"
stop reason), and gate_task.failures counts the policy's flagged calls
and their rows as repetition_stops; the health verdict line names them
when there are any. It is a fact, not a failure: the answer stays
scored as produced, nothing is retried, and no detector is enabled.

Signed-off-by: Adam Rajfer <[email protected]>

* fix(eval): count only the policy's own repetition stops in deciding rows

A judge served by the policy's own server sent its calls under the policy's
model name, so a looping judge call counted as a policy repetition stop.
Calls a verifier invocation owns (by call id, else by model and response
id) are no longer counted.

Both repetition_stops and output_budget_refits now read only the row that
decides each scored trial (the last one saved for it), so an attempt a
later one superseded is not counted twice.

Signed-off-by: Adam Rajfer <[email protected]>

---------

Signed-off-by: Adam Rajfer <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 6f2cc609 Deployed Nov 11, 2026 by copy-pr-bot[bot] via release / finalize / notify #11709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model servers, inference providers, and model adapters bug Something isn't working complexity:high Cross-component or shared-contract change with a large review surface needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants