Skip to content

feat(model): forward the effort of a Messages request when configured - #6904

Open
alexandery-nvidia wants to merge 20 commits into
mainfrom
alexandery/messages-reasoning-effort
Open

alexandery-nvidia wants to merge 20 commits into
mainfrom
alexandery/messages-reasoning-effort

Conversation

@alexandery-nvidia

@alexandery-nvidia alexandery-nvidia commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The Anthropic Messages route of a model server converts a request to the Responses API and calls the server's own responses(). The conversion drops output_config.effort. The reasoning effort of a Claude Code session therefore never reaches the backend, where a /v1/responses request with reasoning.effort reaches the engine as reasoning_effort. This PR adds a setting that forwards the effort. It serves a run that sets reasoning_effort on claude_code_agent and expects the engine to apply it.

What changes:

  • A model server has the new setting forward_anthropic_reasoning_effort, off by default.
  • With it, the conversion states the effort of output_config as the Responses reasoning.effort. The Chat Completions conversion then sends it to the engine as it does for a Responses request.
  • A request without an effort leaves reasoning unset.
  • A model server that does not send its backend the reasoning effort of a request refuses the setting when its configuration is validated. base_model and agentic_if_text always refuse it. vllm_model refuses it where a Messages request goes to /v1/completions, which has no reasoning_effort: with use_completions_api: true and without is_responses_native: true.
  • With the setting, a request whose output_config is neither null nor an object, or whose effort the pinned OpenAI SDK does not list, is refused with HTTP 422. The error names output_config or output_config.effort.
  • The model-server documentation and the README of claude_code_agent state the setting.

What does not change: without the setting the effort is dropped, and the conversion does not read output_config, whatever its value is. The test test_output_config_effort_remains_ignored, which #5464 added, passes unchanged. The setting is opt-in for a reason. Claude Code states an effort in every request, high unless it is configured otherwise, and an engine can refuse a level that it does not serve.

Validation

  • pytest tests/unit_tests/models: 2797 passed, where main has 2762. pytest responses_api_models/vllm_model: 1317 passed, where main has 1313. pytest responses_api_models/base_model: 99 passed, where main has 98. pytest responses_api_models/agentic_if_text: 6 passed, where main has 5.
  • ruff check and ruff format --check (ruff 0.9.9) on the changed Python files: no finding.
  • pre-commit run --all-files was not run. Its box below is unticked.
  • Twenty-seven of the 41 new cases fail with the changed source files of main: anthropic_converter.py, base_responses_api_model.py, and app.py of vllm_model, base_model and agentic_if_text. The other 14 pass there too: the setting is off, or the request states no effort.

Rollouts

One task ran with a real model at main and at an earlier head of #6905, which is stacked on this one and held the first commit of this PR: vllm_model, claude_code_agent with Claude Code 2.1.312 and reasoning_effort: low, single_agent_turn_legacy and a Docker sandbox of ubuntu:24.04. The model is an OpenAI model behind an OpenAI-compatible endpoint that serves the Chat Completions API. A process in front of the endpoint recorded the fields of each request that the model server sent.

  • In both rollouts Claude Code stated output_config: {"effort": "low"} in each of its two requests.
  • At main the requests at the endpoint have the fields max_tokens, messages, model and tools, and no reasoning_effort.
  • With forward_anthropic_reasoning_effort: true both requests at the endpoint have reasoning_effort: low.
  • The endpoint answered both with HTTP 200. The verifier's reward is 1.0 and the health verdict is healthy, as at main.

No rollout tried a level that the endpoint refuses.

Compatibility and benchmark impact

None. The setting is new and off by default.

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 (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

🤖 Generated with Claude Code

alexandery-nvidia and others added 2 commits November 27, 2026 20:08
The model server answers a streamed /v1/messages request only when the
whole generation has returned, so the client receives no byte until then.
Claude Code 2.1.312 gives a request up after about 360 seconds without a
response byte and sends it again. API_TIMEOUT_MS does not lengthen that
wait. A longer generation therefore runs twice, and the answer of the
first run is lost. A stream that is open and then silent is given up
after 300 seconds. A stream that carries a ping event every 15 seconds is
kept for as long as the events come.

stream_keepalive_s now applies to /v1/messages as it does to
/v1/responses. A call that is still running after one interval opens the
stream with a ping event and sends another at every interval. The events
of the message follow unchanged. A call that ends within the first
interval is served as before, so its failure keeps its HTTP status.

A call that fails after the stream has opened ends it with an error
event. Its type is invalid_request_error for a refusal that the server
propagates and for another 4xx status, rate_limit_error for 429, and
api_error otherwise. Claude Code answers an error event that precedes
message_start by sending the request once more with "stream": false, and
that request gets the HTTP status. No event can hold that request open:
Claude Code gives it up after about 300 seconds without a response.

A client that leaves cancels the backend call, in the first interval and
after the stream has opened, as for /v1/responses.

A server whose response ids come from an upstream Responses API refuses
the setting at startup, as before, so it holds no Messages stream open
either.

Model-call capture does not count a ping event as the first token.

The checkpoint gate of a policy model server does not take a ping event
for the start of the answer. As after the lifecycle events of a
/v1/responses stream, a checkpoint holds such a call instead of waiting
for it, and the ledger row of the call is published when the message
starts.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The Anthropic Messages route of a model server converts a request to
the Responses API and calls the server's own `responses()`. The
conversion dropped `output_config.effort`, so the reasoning effort of a
Claude Code session never reached the backend, where a /v1/responses
request with `reasoning.effort` reaches the engine as
`reasoning_effort`.

A model server now has the setting `forward_anthropic_reasoning_effort`.
With it, the conversion states the effort as the Responses
`reasoning.effort`, and the Chat Completions conversion sends it to the
engine as it does for a Responses request. The setting is off by
default, which keeps the effort dropped: Claude Code states an effort
in every request, `high` unless it is configured otherwise, and an
engine can refuse a level that it does not serve.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 2ac97e4

@copy-pr-bot

copy-pr-bot Bot commented Nov 28, 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.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:model Model servers, inference providers, and model adapters needs-review PR is ready for code review and waiting on a reviewer labels Nov 28, 2026

@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. I found three RISK issues, with no BLOCKER.

I reviewed all 13 changed files and connected callers with three delegated reviewers. The normal effort-forwarding path works, and the streaming probes found no backend-task leak or premature checkpoint publication. The findings concern late-error attribution, lost failure reports and an unsupported forwarding configuration.

Validation:

  • I relied on head CI run 46111777187: all four core shards, all eight server-suite shards, Unit tests / Test, Unit tests / Combined core coverage and Unit tests / Server suite passed. Lint passed. Changed-server and session-routing jobs were skipped. The overall run is red because non-blocking conformance/compliance checks failed; I did not attribute those failures to this diff.
  • CPU probes ran in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:ba3eeeb0a60df9a7cd3bb9d2c1f36cabb0a493b5, the default branch’s CI image because the head had no successful container-build check. With PYTHONPATH pointing to the admitted checkout, leader/concurrent_messages.py passed 32 concurrent effort/keepalive requests. Delegated probes covered backend mappings, SDK parsing, disconnect cleanup, capture timing and checkpoint hold/resume. Error probes reproduced the findings below, including a base-versus-head comparison for failure-report loss.
  • I did not rerun the CI suites or run a real model/GPU workload. Claude Code’s documented long-duration retry timing was not exercised.

Inline comments (escaped v1):

  • nemo_gym/models/model_call_capture.py line 1129: RISK: Preserve the backend failure category after Messages pings.

    The new late-error branch returns HTTP 200 plus an Anthropic error event, so this fallback now labels a delayed upstream 422 as upstream_error instead of client_error. My route-level capture-checkpoint-1/recovery_probe.py reproduced that change. After normalizing the captured record, is_server_fault_call also changed from false to true for the same invalid request.

    This affects captured Messages calls with keepalives enabled, especially adapters without separate execution metadata. Recovery treats upstream_error as an evaluation-side fault, so request duration can change timeout attribution.

    Could you retain the original status/category in request state or terminal metadata and use it before the generic SSE fallback? Keep the required HTTP-200-plus-error-event wire behavior and adapter-specific propagation policy. Acceptance: delayed 400/422, 429 and 5xx cases should retain the same capture category and recovery responsibility with keepalives disabled or enabled, including a shared non-vLLM adapter.

  • nemo_gym/models/base_responses_api_model.py line 1029: RISK: Carry the structured failure report on the terminal Messages event.

    This conversion keeps only the exception’s type/message after headers have gone out. Unlike the sibling Responses/Chat keepalive paths, it does not retain the request failure log or serialize its final report.

    I ran leader/messages_failure_report.py against base and head. Base preserved the known model failure ID in X-NG-Failure-Report; head with a short keepalive interval carried it in neither headers nor SSE. The same loss occurs for recovered-attempt observations before a successful message_stop. A direct terminal NgFailureEvent also disappears from capture when it was not independently observed; an already-observed event can survive locally but loses its selected terminal identity.

    Could you preserve the bounded report, including the caught exception, on the terminal error or message_stop event and in local capture? Extend the stream reader and captured-report consumption for Messages, rather than adding an unread field. Preserve ping framing, fast-error HTTP statuses, cancellation cleanup and propagation of capture-finalization errors. Acceptance: explicit failure IDs/causes survive late failures and recovered-success cases through both the receiving reader and capture; oversized reports retain the existing omitted marker.

  • responses_api_models/vllm_model/app.py line 906: RISK: Reject effort forwarding for the Completions backend.

    The new forward_anthropic_reasoning_effort option is accepted with use_completions_api: true, but the Completions request builder drops reasoning_effort. In effort-conversion-1/probe.py, streamed and non-streamed /v1/messages requests with output_config.effort: max returned 200 while the fake engine received only max_tokens, model and prompt.

    Operators who enable the flag therefore still run without the requested effort on this backend, contrary to the new option’s documented behavior. This is limited to the opt-in combination; default-off behavior is unchanged.

    Could you extend the existing incompatibility validation here to reject the new flag when the Completions backend is selected, and document that limitation? Acceptance: the unsupported combination rejects before serving, Completions with forwarding disabled still works, Chat/Responses-backed forwarding stays supported, and configured sampling overrides keep their existing precedence.

Review generated by codex. This was a full 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 30, 2026
alexandery-nvidia and others added 4 commits November 30, 2026 05:26
A streamed /v1/messages call that outlasts one interval of
stream_keepalive_s opens its stream with a ping event, so its HTTP headers
go out before the backend call ends. The failure that ended such a call,
and the failures that the call observed, were then not reported to the
client: the failure header was already sent, and the stream carried no
failure report.
A keepalive /v1/responses stream and a streamed chat completion carry the
report on their terminal event in that case.

The terminal event of a Messages stream that ping events opened now
carries the request's failure report in the same field,
nemo_gym_failure_report: the error event of a call that failed, and
message_stop of a call that answered. The report selects the failure that
ended the call and holds the failures that the call observed, such as an
attempt that a retry replaced. A request with nothing to report sends its
events unchanged.

StreamFailureReportReader accepts a report on these two event types.
Rollout collection reads the report from a captured Messages stream as it
does for the two other dialects, so the events reach the rollout's row.
The function that adds the report to an event takes the event types from
the reader, so they are stated once.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This branch is stacked on alexandery/messages-stream-keepalive. The merge
brings in that branch's commit "fix(model): carry the failure report on a
keepalive Messages stream", so the terminal event of a Messages stream
that ping events opened carries the request's failure report here too.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The conversion of a Messages request read `output_config.effort` before
it checked whether the effort is forwarded. A request whose
`output_config` is not an object, such as a string or a list, therefore
failed with an AttributeError and HTTP 500 on a model server that drops
the effort, where the field was ignored before the setting existed.

The conversion now reads `output_config` only with
`forward_anthropic_reasoning_effort`. Without the setting, the field is
ignored whatever its value is.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
vllm_model accepted `forward_anthropic_reasoning_effort` together with
`use_completions_api`. A /v1/completions request has no
`reasoning_effort`, so the server answered a Messages request with HTTP
200 and sent the engine no effort, although the setting says that the
effort is forwarded.

The configuration now refuses the combination at startup, with the check
that already refuses `forward_unvalidated_reasoning_effort` with
`use_completions_api` for the same reason. The documentation of the
setting states the requirement.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test a0114ee

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Replies to the three findings of the automatic review of this pull request.

The capture record of a call that fails after the first ping.

I reproduced this: a 422 or a 429 that the backend raises after the first ping is recorded with status_code 200 and error_category upstream_error, and is_server_fault_call then returns true where it returns false for the same failure in the first interval.

The code is the keepalive path of #6903, and it is not changed there either. A /v1/responses stream under stream_keepalive_s and a streamed chat completion record exactly the same for the same late failure (checked for 422, 429, 502, 504 and a typed failure), and test_actual_stream_capture_survives_collection_and_store asserts upstream_error for both routes. Keeping the original status and category after the headers went out therefore needs a change of the capture middleware for all three dialects, which this stack does not make for one route alone.

What #6903 now changes is the failure report: commit 2477ee8 puts it on the terminal Messages event, so a typed failure keeps its id, kind and HTTP status on the wire and in the rollout row.

The failure report on the terminal Messages event.

I reproduced this: after a ping, neither the header nor the stream carried the request's failure report, for a call that failed and for a call that answered after a recovered attempt.

This is the keepalive path of #6903 and is fixed there in commit 2477ee8, which this branch holds through the merge c4139f4. The terminal event (error or message_stop) carries the bounded report in nemo_gym_failure_report, StreamFailureReportReader accepts it on these two event types, and the rollout reader reads captured Messages streams. test_a_keepalive_messages_stream_reports_late_failures_on_its_terminal_event covers the wire, and the messages cases of test_actual_stream_capture_survives_collection_and_store cover the reader and capture.

No separate case for an oversized report was added: the Messages route calls the same _stream_report as the two other routes, and the bound and the omitted marker of FailureHeader.stream_value are tested in test_a_stream_report_within_the_compact_budget_is_decoded_intact. The capture record's own failure_report still holds the observed events only, as it does for the two other routes.

The setting together with the Completions API.

I reproduced this: with forward_anthropic_reasoning_effort: true and use_completions_api: true, streamed and non-streamed /v1/messages requests with output_config.effort: max returned 200, and the engine request held only max_tokens, model and prompt.

Commit a0114ee refuses the combination when the configuration is validated, with the check that already refuses forward_unvalidated_reasoning_effort with use_completions_api, and the vllm_model documentation states the requirement. test_forwarding_the_effort_of_a_messages_request_is_refused_with_the_completions_api covers it. Forwarding on the Chat Completions backend and the Completions backend without forwarding are covered by the existing tests, which pass unchanged.

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/review reset=true

@nemo-pr-automation
nemo-pr-automation Bot requested review from a team November 30, 2026 13:32

@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 prior RISK findings remain, plus one new NOTE; I found no BLOCKER.

I reviewed all 18 changed files and connected consumers with three delegated reviewers. Compared with review 6096170678 at 2ac97e43866feb8665f2d89e894ebcbe9fb365dc, the Completions incompatibility is fixed. Terminal failure reports now survive Messages SSE and reach episode observations. Backend-error attribution is still wrong after pings, and the terminal failure is still missing from the individual call's report.

Validation:

  • I relied on head CI run 46429399907: all eight server-suite shards and their aggregate passed; core shards 1–3, Sandbox tests and LongMT scoring passed. Lint passed. Core shard 0 failed with 1 failed, 6538 passed, 22 skipped; Unit tests / Test and Nemo_CICD_Test are red, and combined core coverage was skipped. Changed-server and session-routing jobs were skipped. Non-blocking compliance/conformance checks also failed.
  • The core failure is TestDispatchBudget::test_a_row_the_budget_runs_out_on_while_its_reservation_waits_is_drained_unreserved[deadline], with posted == [] rather than [0]. That test and its implementation are unchanged from base. A focused pytest run of that exact test with --cpu -o addopts='' -p no:cacheprovider passed once. I have not established the CI failure's cause or a matching upstream failure, so CI is not validated green.
  • CPU probes used 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:ba3eeeb0a60df9a7cd3bb9d2c1f36cabb0a493b5, the default branch's CI image because the admitted head had no container-build check. Imports were bound to the admitted checkout. current-review/concurrent_messages.py passed 32 concurrent requests. effort-reset-1/probe.py verified backend mappings and configuration precedence. current-review/status_matrix.py and capture-reset-1/per_call_probe.py reproduced the two RISK findings. Checkpoint hold/resume, byte-fragmented reports, SDK parsing and disconnect cleanup probes passed. messages-reset-1/error_types_probe.py reproduced the NOTE.
  • I did not rerun passing CI suites or exercise a real model/GPU workload or Claude Code's long-duration retry behavior.

Inline comments (escaped v1):

  • nemo_gym/models/model_call_capture.py line 1131: RISK: Preserve the backend failure category after Messages pings.

    The new late-error path returns HTTP 200, so this fallback still records every terminal error as upstream_error. The added structured report does not correct that category. My current route/capture probe (current-review/status_matrix.py) records the same upstream 422 as client_error without keepalives and upstream_error after a ping; normalized is_server_fault_call changes from false to true. A 429 similarly changes from rate_limit to upstream_error.

    This affects captured Messages calls, particularly shared adapters without separate upstream execution metadata. Recovery checks this category before the typed events, so request duration can change whether an agent timeout has evaluation-side fault evidence.

    Could you retain the original backend status/category in request state or terminal metadata and prefer it before this fallback? Preserve HTTP-200 SSE behavior and each adapter's propagation policy. Acceptance: delayed 400/422, 429 and 5xx cases retain equivalent capture categories and recovery responsibility with keepalives off/on, including a non-vLLM adapter.

  • nemo_gym/models/model_call_capture.py line 711: RISK: Keep the terminal failure report on the individual call.

    The wire-report fix works, but this capture projection still loses a direct terminal NgFailureEvent raised after a ping unless it was independently observed. The route catches the exception, _stream_report constructs a reply without updating the request log, and _record later receives no failure.

    My current capture-reset-1/per_call_probe.py reads the correct selected ID from terminal SSE, but the attached call has failure_report.events == {} and failure_id == null; call-level health recovery observations are also absent. The new raw-SSE merge recovers the event only for the enclosing episode. Default serialization then drops response_raw, leaving saved call/trajectory consumers without the failure association.

    Could you carry the terminal exception/report into per-call capture, or merge the terminal report into the call before serialization? Preserve its selected ID and causal closure on the call, while continuing to treat it only as an observation at episode scope. Acceptance: a direct unobserved terminal NgFailureEvent retains its ID/causes in SSE, raw capture, attached call and trajectory metadata; recovered success has observations but no final ID, and the episode's independently selected failure stays unchanged.

  • nemo_gym/models/base_responses_api_model.py line 1062: NOTE, suggestion: retain specific Anthropic error types.

    This fallback maps a delayed upstream 401/403/404 to invalid_request_error and 529 to api_error. My messages-reset-1/error_types_probe.py reproduced this through /v1/messages; base kept the original HTTP statuses. The installed Anthropic schema distinguishes authentication_error, permission_error, not_found_error and overloaded_error, so clients inspecting the terminal type lose that distinction after a ping.

    Could you map those four statuses explicitly before the fallback? Keep status-hiding adapters generic, 429 as rate_limit_error, and refusals as invalid_request_error. Extend the existing late-error route cases for both HTTPException and propagated ClientResponseError, while retaining fast HTTP-error behavior. I did not confirm an affected Claude Code retry decision; this is a non-blocking API-accuracy suggestion.

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

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both points are in work: a refusal of forward_anthropic_reasoning_effort at startup wherever a server cannot apply it, and a guard that follows the route that serves a Messages request. I am also merging main in to clear the conflicts. I will reply in each thread with the commit.

alexandery-nvidia and others added 5 commits December 3, 2026 11:47
main changed six files that this branch also changes, and Git merged
each of them without a conflict. In
nemo_gym/models/base_responses_api_model.py main imports
chat_stream_error_message on the lines below the import that this
branch extends with ANTHROPIC_PING_SSE. The merge keeps both. The lines
that this branch adds and removes against main are the same as before
the merge.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
main added a check to the configuration validator of
responses_api_models/vllm_model/app.py that refuses
translate_none_reasoning_effort together with use_completions_api. It
stands directly below the check of forward_unvalidated_reasoning_effort,
which this branch turned into a loop over that option and
forward_anthropic_reasoning_effort. The merge keeps both: the loop of
this branch, followed by the check that main added. The lines that this
branch adds and removes against the keepalive branch are the same as
before the merge.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
base_model inherits forward_anthropic_reasoning_effort and sends every
request to /v1/completions, which has no reasoning_effort. With the
setting on, a Messages request that states an effort was answered with
200 and the effort was missing from the request to the backend.

BaseResponsesAPIModelConfig now has reasoning_effort_unsupported_reason,
which returns None by default, and one validator that refuses
forward_anthropic_reasoning_effort at startup with the reason that the
method returns. A configuration whose server sends its backend no
reasoning effort overrides the method. base_model does, and so does
agentic_if_text, which sends the effort of its own reasoning_effort
setting and never reads the effort of a request.

The tests construct each of the two configurations with the setting on
and expect the refusal. A test of the base class does the same with a
configuration that overrides the method.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
VLLMModelConfig refused forward_anthropic_reasoning_effort whenever
use_completions_api was on. With is_responses_native also on, a Messages
request goes to /v1/responses, which takes reasoning.effort, so that
server could apply the setting and did not start.

The configuration now states its reason through
reasoning_effort_unsupported_reason: the setting is refused only with
use_completions_api=true and without is_responses_native=true, where a
Messages request goes to /v1/completions. The check of its own in the
validator is removed, so that validator is the one of main again.

One test starts a server with all three settings on and expects the
effort of a Messages request in the /v1/responses request. The other
expects the refusal with use_completions_api alone.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The rule read that a model server which sends its backend no reasoning
effort refuses forward_anthropic_reasoning_effort, and one page said
that base_model and agentic_if_text send none. agentic_if_text does
send an effort, the one of its own reasoning_effort setting. It refuses
the setting because it never sends the effort of a request.

The two pages, the description of the setting and the docstring of
reasoning_effort_unsupported_reason now say that a server refuses the
setting when it does not send its backend the reasoning effort of a
request.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 69d5809

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/review reset=true

@nemo-pr-automation
nemo-pr-automation Bot requested review from a team December 3, 2026 21:24

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

Changes requested:


Inline comments (escaped v1):

  • nemo_gym/models/model_call_capture.py line 1617: RISK (moderate risk)

    What I tested
    I sent delayed 422 and 429 failures through /v1/messages on CPU, with keepalives off and on.

    What I found
    The same 422 produces client_error/server_fault=false before pings and upstream_error/server_fault=true afterward. The terminal-error fallback treats client errors as server faults, changing which side timeout recovery blames. A delayed 429 also loses rate_limit.

    What I recommend
    Keep the backend status and category in request state, and prefer them here while preserving each adapter's error policy. Add delayed 422/429 tests that preserve capture categories and recovery decisions with keepalives off and on.

  • nemo_gym/models/model_call_capture.py line 1159: RISK (moderate risk)

    What I tested
    I raised a terminal NgFailureEvent with one cause after a Messages ping on CPU.

    What I found
    The stream carries both events, but per-call capture saves failure_id=null and events={}. The route catches the exception, so capture never receives it. Default serialization drops the raw stream, leaving saved calls and trajectory metadata without those failures.

    What I recommend
    Merge the terminal report into each call before serialization, keeping its selected ID and causes. Add a serialization round-trip test that preserves them without changing the episode's independently selected failure.

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

alexandery-nvidia and others added 3 commits December 3, 2026 15:01
A streamed /v1/messages request with stream_keepalive_s has sent its
HTTP status 200 before its backend call ends, so a later failure
reaches the client as an error event. Model-call capture saved every
such call as upstream_error with no selected failure. A 422 or a 429 of
the backend then counted as a server fault, a timeout lost its
category, and a typed failure lost its id and its causes, while the
same failure before the first ping event was saved with them.

note_stream_failure stores the failure in the request state, where the
capture middleware already reads what a route notes. For a call with a
noted failure the middleware takes the category from the expression
that it uses for a failure that a route raises (_classify_failure),
passes the failure to the saved failure report, and saves the HTTP
status of the backend as upstream_status_code where the adapter noted
none. status_code stays 200, the status that the client received. The
status of an HTTPException is this server's own and is not saved as
the backend's.

Only the Messages route notes its failure. The keepalive streams of
/v1/responses and /v1/chat/completions are saved as before.

The tests send the same failure before and after the first keepalive
event through the middlewares that run_webserver installs, for a 422, a
429, the error that the model client raises with its observed attempt
as cause, a timeout and a typed failure. They compare the category, the
server fault, the status of the backend and the failure events of the
saved rows, and they state which failure the late call selects. One
test covers a late HTTPException, and one reads a typed failure back
from the saved row and checks that the episode keeps its own selected
failure.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The keepalive Messages branch now saves a failure that arrives after a
ping event with the category, the status of the backend and the
failure report of the failure. The merge brings that state. Git merged
every file without a conflict, and the lines that this branch adds and
removes against the keepalive branch are the same as before the merge.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
With forward_anthropic_reasoning_effort on, the conversion of a
Messages request reads the effort of output_config. An output_config
that is not an object raised AttributeError there, and an effort that
the pinned OpenAI SDK does not list failed the validation of the
Responses request, so the route answered HTTP 500 without calling the
backend.

The route now validates output_config before the conversion when the
setting is on (_validate_forwarded_output_config). A value that is
neither null nor an object, and an effort outside the SDK's list, are
refused with FastAPI's standard 422, as a /v1/responses body is. The
error names output_config or output_config.effort as its location.
With the setting off the field is not read, as before.

The tests post three values that are no object and two efforts that
are not listed, streamed and not streamed, and expect the 422, the
location and no call of responses(). With the setting off the same
three values are answered with 200.

Signed-off-by: alexandery <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test c13b0e8

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Replies to the findings of this round. A and B concern the keepalive code of #6903 and are fixed by commit 0d83184 there, which this branch holds by a merge. C is fixed by commit c13b0e8 here.

A late failure changes its saved classification. Reproduced through an app with the middlewares that run_webserver installs: on /v1/messages a 422 was saved as 422 / client_error, not a server fault, before the first ping, and as 200 / upstream_error, a server fault, after it; a 429 lost rate_limit and a timeout lost timeout in the same way. Commit 0d83184 lets the Messages route note the failure in the request state (note_stream_failure, nemo_gym/models/model_call_capture.py:131, called at nemo_gym/models/base_responses_api_model.py:1067), and the capture middleware then saves the call with the category that it gives a failure that a route raises, with the HTTP status of the backend as upstream_status_code, and with status_code 200 (nemo_gym/models/model_call_capture.py:1637). tests/unit_tests/models/test_stream_failure_capture.py:184 sends a 422, a 429, the error that the model client raises with its observed attempt as cause, a timeout and a typed failure with keepalive off, on before the first ping and on after it, and expects equal category, server fault, status of the backend and failure events in the saved rows; tests/unit_tests/models/test_stream_failure_capture.py:210 covers a late HTTPException. The same record on the keepalive streams of /v1/responses and /v1/chat/completions is unchanged in this pull request.

A typed failure after a ping is missing from the saved call. Reproduced: a typed failure with one cause, raised after a ping, was saved with failure_id: null and no events, while the same failure before the ping kept its id and its cause. With commit 0d83184 the capture middleware passes the noted failure to the saved failure report (nemo_gym/models/model_call_capture.py:1679), so the late call selects the failure's Gym failure event, when it has one, with its causes, in ng_model_call_capture.calls and in the trajectory metadata. tests/unit_tests/models/test_stream_failure_capture.py:220 reads the row back from its JSON text, expects the id and the cause link in the saved call, and expects the episode's own selected failure unchanged. tests/unit_tests/rollouts/test_streamed_capture_reports.py:93 asserts the selected id in the saved call and in the trajectory metadata after a collection run. As for finding A, the /v1/responses and /v1/chat/completions streams are unchanged here.

A malformed output_config answers HTTP 500. Reproduced: with forward_anthropic_reasoning_effort on, an output_config of "high", ["effort"] or 3 raised AttributeError, and the route answered HTTP 500 in both stream modes without calling the backend. An effort outside the list of the pinned OpenAI SDK did the same through the validation of the Responses request. Commit c13b0e8 validates the field in the route before the conversion (_validate_forwarded_output_config, nemo_gym/models/base_responses_api_model.py:1157, called at nemo_gym/models/base_responses_api_model.py:998) and refuses a value that is neither null nor an object with FastAPI's standard 422, as a /v1/responses body is refused, with output_config or output_config.effort as the location. With the setting off the field is still not read. The tests post the three values and two unlisted efforts in both stream modes and expect the 422, the location and no call of responses() (tests/unit_tests/models/test_responses_api_model_messages.py:166), and they expect 200 for the three values with the setting off (tests/unit_tests/models/test_responses_api_model_messages.py:186).

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/review reset=true

yaoyu-33
yaoyu-33 previously approved these changes Dec 3, 2026

@yaoyu-33 yaoyu-33 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.

The startup checks now follow the route that actually serves Messages, and malformed output_config gets a 422 before the backend is called when forwarding is enabled. That addresses my review. I’m happy with the default-off behavior.

Please coordinate with #5962 on how vLLM should handle explicit effort together with thinking: {"type": "disabled"}. The rollout here covers the OpenAI-compatible endpoint. That specific vLLM combination still needs its own check.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Dec 3, 2026
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

On the coordination with #5962 for an explicit effort together with thinking: {"type": "disabled"}:

With forward_anthropic_reasoning_effort: true, such a request reaches the engine with the effort as reasoning_effort and with nothing about thinking, because the conversion does not read thinking (nemo_gym/models/anthropic_converter.py:345-348). #5962 sends the same engine request for this combination. It differs in three other points: it forwards for every model server without a setting, it has no startup refusal, and it answers a malformed output_config with 400 where this PR answers 422.

vLLM at its v0.29.0 tag then passes enable_thinking: true to the chat template for any effort other than none, unless the request's chat_template_kwargs already hold enable_thinking (protocol.py#L586-L588). I read that in the code and have not run it. No test of either pull request sends a thinking field.

Proposal: this PR merges as approved, because the setting is off by default, and one follow-up settles the combination together with @RyaliNvidia: the rule, tests for a request with thinking disabled and enabled, and a Claude Code rollout against a model that vLLM runs. If you prefer a guard in this PR first, the smallest one is to not forward the effort of a request with thinking: {"type": "disabled"}, which leaves its engine request as it is on main. The two pull requests change five files in common, so the one that merges second needs a rebase.

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

LGTM, but please take a look at the following findings:

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

Comment thread nemo_gym/models/model_call_capture.py Outdated
failure_status, _ = _exception_http_details(stream_failure)
error_category = _classify_failure(stream_failure, failure_status)
# The status of an HTTPException is this server's own; every other status is the backend's.
upstream_status = None if isinstance(stream_failure, HTTPException) else failure_status

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.

RISK (moderate risk)

What I tested
I raised HTTPException(504) before and after a /v1/messages ping on CPU. I then serialized the captured call and ran the recovery predicates.

What I found
For model implementations raising this error, this assignment discards the only saved 504 status. Capture keeps HTTP 200 and timeout, so is_infrastructure_agent_timeout() changes from true to false. A server timeout can therefore be blamed on the model when an agent deadline expires.

What I recommend
Keep the server's failed status separately and let recovery read it. Add an early/late 504 test without labeling that status as the backend's.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reproduced. I built the app with the calls of run_webserver in its order and let the Messages route raise the same HTTPException before and after the first ping event. Only a 504 differs by default. Its category is timeout, which is no server-fault category, and the late call saved no status, so is_server_fault_call answered True before the stream opened and False after it. A 500, 502 or 503 is a server fault at both times through its category. A 408 or another 4xx is none at both times, but a by_status_code rule for such a status matched only the early call.

No model server in the repository raises an HTTPException with 504 or 408 today, so this was a gap in the contract of the saved call and not an observed failure.

Commit 7399b37 on #6903 closes it. Capture saves the status of such an exception as the new key local_status_code (nemo_gym/models/model_call_capture.py:1647 and :1175), and is_server_fault_call reads it as it reads status_code and upstream_status_code (nemo_gym/rollouts/rollout_recovery.py:323). The status is not saved as the backend's. Commit 284e90d compares the decisions before and after the ping event for a 504 and a 409, also under a by_status_code rule (tests/unit_tests/models/test_stream_failure_capture.py:220).

The line is #6903's, so the fix is pushed there. #6904 and #6905 take the commit when #6903 has merged and main is merged into them, so the two approved branches do not change now.

Signed-off-by: svcnemo-autobot <[email protected]>
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test 803ae16

@nemo-pr-automation
nemo-pr-automation Bot requested a review from a team December 4, 2026 07:14
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

The repository's automation merged main into this branch, and with it #6903, which is merged now. The code of this PR is unchanged: against main the branch adds and removes the same lines as at the approved head c13b0e82be, and the diff no longer shows the commits of #6903. The merge added a commit after the approval, so the approval may need to be renewed.

This branch has not been deployed

No deployments
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 feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge risk:high Autobot PR risk: high 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.

4 participants