Skip to content

fix(responses): remove reasoning_item from the boundary set, and name the training-variant error - #2453

Merged
ananthsub merged 2 commits into
mainfrom
ananthsub/responses-item-fixes
Aug 12, 2026
Merged

fix(responses): remove reasoning_item from the boundary set, and name the training-variant error#2453
ananthsub merged 2 commits into
mainfrom
ananthsub/responses-item-fixes

Conversation

@ananthsub

@ananthsub ananthsub commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Part of #2452

Two corrections to the Responses item plumbing. Neither changes behaviour at the current openai pin.

  1. _RESPONSE_OUTPUT_BOUNDARY_TYPES listed "reasoning_item", which is not a Responses output item type at any openai version.

The class is ResponseReasoningItem. Its type tag is "reasoning": https://github.com/openai/openai-python/blob/650be393dedf2a4550092817c2b82c1d04d6e9dc/src/openai/types/responses/response_reasoning_item.py#L34

which is what the responses converter emits:

reasoning_item = NeMoGymResponseReasoningItem(
id=f"rs_{uuid4().hex}",
type="reasoning",
summary=[
NeMoGymSummary(text=reasoning_text, type="summary_text") for reasoning_text in reasoning_matches
],
status="completed",

  1. RESPONSES_TO_TRAIN[item_cls] directly looks up the dict in the responses converter. It was a bare dict access, so an unregistered class raised KeyError and reached the client as a 500 with no explanation. training_variant_of() raises NotImplementedError naming the class and what to add.

Nothing reaches that path today. The lookup is passed response_output[-1] from postprocess_assistant_message_dict, whose local list can only hold NeMoGymResponseReasoningItem, NeMoGymResponseOutputMessage or NeMoGymResponseFunctionToolCall, and all three are registered. The point is that the next converter to emit a new item type gets a message telling it what to add rather than a stack trace.

  1. responses_to_chat_completion_create_params matches on each item's type and has a case for four of them. Everything else falls to case _, which raised Unsupported message type: {the whole item}:
    match m["type"]:
    case "message":
    self._format_message(m, state)
    case "reasoning":
    self._format_reasoning(m, state)
    case "function_call":
    self._format_function_call(m, state)
    case "function_call_output":
    self._format_function_call_output(m, state)
    case _: # pragma: no cover
    raise NotImplementedError(f"Unsupported message type: {m}")

That message reads as a gap in the converter. It usually is not. Most types that reach it have no Chat Completions representation at all, so the transcript needs a model server that passes Responses through rather than a new case here. openai_model does; vllm_model and inference_provider downconvert and cannot.

The message now names the type and says which of those two situations it is. It no longer prints the item, because the payload can be large or opaque, and the type tag is the part that identifies the problem.

@copy-pr-bot

copy-pr-bot Bot commented Aug 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.

@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch from be76a12 to f36e4be Compare August 10, 2026 17:19
@ananthsub ananthsub changed the title fix(responses): drop a boundary type that does not exist and name the training-variant failure fix(responses): remove reasoning_item from the boundary set, and name the training-variant error Aug 10, 2026
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch 3 times, most recently from bd2e33f to bee2e6a Compare August 10, 2026 23:05
@copy-pr-bot

copy-pr-bot Bot commented Aug 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.

@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch 4 times, most recently from e36bd6b to 7a6cd14 Compare August 11, 2026 13:39
@ananthsub
ananthsub marked this pull request as ready for review August 11, 2026 13:39
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch from 7a6cd14 to e36bd6b Compare August 11, 2026 18:38
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch from e36bd6b to b62bca8 Compare August 11, 2026 18:43
cmunley1
cmunley1 previously approved these changes Aug 11, 2026
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch from b62bca8 to 5976c75 Compare August 11, 2026 19:11
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch 4 times, most recently from e36bd6b to 6f88d0b Compare August 11, 2026 19:42
bxyu-nvidia
bxyu-nvidia previously approved these changes Aug 11, 2026
ffrujeri
ffrujeri previously approved these changes Aug 12, 2026
… the training-variant error

Two corrections to the Responses item plumbing. Neither changes behaviour at the current openai pin.

`_RESPONSE_OUTPUT_BOUNDARY_TYPES` listed `"reasoning_item"`, which is not a Responses output item
type at any openai version. I checked 2.7.2, 2.25.0, 2.31.0 and 2.44.0 by reading the `type` Literal
of every model in `openai.types.responses` (192 to 269 models depending on version) and by searching
the installed source. The value does not appear at any of them.

The name looks like a transcription of the SDK's class and module name rather than its wire value:
- the class is `ResponseReasoningItem`, in `response_reasoning_item.py`
- its `type` tag is `"reasoning"`, which is what the responses converter emits

The entry predates this repo's git history and cannot match anything, so removing it and its test
parametrization is behaviour-preserving. It only made the set look more complete than it was.

The second change is the `RESPONSES_TO_TRAIN[item_cls]` lookup in the responses converter. It was a
bare dict access, so an unregistered class raised `KeyError` and reached the client as a 500 with no
explanation. `training_variant_of()` raises `NotImplementedError` naming the class and what to add.

Nothing reaches that path today. The lookup is passed `response_output[-1]` from
`postprocess_assistant_message_dict`, whose local list can only hold `NeMoGymResponseReasoningItem`,
`NeMoGymResponseOutputMessage` or `NeMoGymResponseFunctionToolCall`, and all three are registered.
The point is that the next converter to emit a new item type gets a message telling it what to add
rather than a stack trace.

`from None` is deliberate: the suppressed `KeyError` carries only the missing key, which the new
message already names. The call-site traceback is unaffected, and the `KeyError` is still reachable
as `__context__`.

Verified: 1795 unit tests pass at openai 2.7.2.

The third change is the `case _` in the responses converter, which handles an item type the
converter has no case for. It interpolated the whole item into `Unsupported message type: {...}`.
That reads as an omission in the converter. Usually it is not: the type has no Chat Completions
representation, and the rollout needs a model server that passes Responses through. The message now
names the type and says that. It no longer prints the item, because a compaction record carries an
opaque blob and the type tag is what identifies the problem.

The fourth change is the role shortcut in `split_responses_input_output_items`. It matched any item
carrying `role == "assistant"`, and it is checked before the boundary type set, so it decided the
split on its own. Every item type with a role is a message at the current pin, which makes this
behaviour-preserving here, but a later SDK adding a role to a non-message type would have that item
open the trained segment regardless of how it is classified. The check now requires the item to be
a message as well, so classification stays the thing that decides.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Keep the named training-variant lookup while using the validated token metadata bundle from main.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@ananthsub
ananthsub dismissed stale reviews from ffrujeri and bxyu-nvidia via 0e52093 August 12, 2026 06:14
@ananthsub
ananthsub force-pushed the ananthsub/responses-item-fixes branch from 6bd05e3 to 0e52093 Compare August 12, 2026 06:14
@ananthsub
ananthsub requested a review from a team as a code owner August 12, 2026 06:14
@ananthsub ananthsub changed the title fix(responses): remove reasoning_item from the boundary set, and name the training-variant error fix(responses): remove reasoning_item from the boundary set, and name the training-variant error Aug 12, 2026
@ananthsub
ananthsub merged commit 8b7aab9 into main Aug 12, 2026
35 of 38 checks passed
@ananthsub
ananthsub deleted the ananthsub/responses-item-fixes branch August 12, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants