Skip to content

openai_model: handle NVIDIA-hosted gpt-oss response quirks (hosted-MCP items + reasoning strip) - #1910

Merged
bxyu-nvidia merged 5 commits into
NVIDIA-NeMo:mainfrom
OliviaViessmann:olivia/openai-model-gpt-oss-compat
Jul 14, 2026
Merged

bxyu-nvidia merged 5 commits into
NVIDIA-NeMo:mainfrom
OliviaViessmann:olivia/openai-model-gpt-oss-compat

Conversation

@OliviaViessmann

Copy link
Copy Markdown
Contributor

What

Two fixes so the openai_model server works with NVIDIA-hosted gpt-oss over the Responses API:

  1. Hosted-MCP output items. Adds NeMoGymResponseMcpCall / NeMoGymResponseMcpListTools / NeMoGymResponseMcpApprovalRequest to the NeMoGymResponse output-item union. gpt-oss surfaces its built-in python tool as an mcp_call output item; these are valid OpenAI Responses types but were missing from the union, so NeMoGymResponse.model_validate(...) raised → HTTP 500 → the whole rollout collection aborted. Closes openai_model 500s on gpt-oss hosted-MCP (mcp_call) output items, aborting rollout collection #1909.
  2. drop_input_reasoning_items. Opt-in stripping of content-less reasoning input items before the upstream call, working around endpoints that 500 with KeyError 'content' when their own reasoning items are echoed back across tool turns. Wired via POLICY_DROP_REASONING_ITEMS.

Why

The NVIDIA-hosted openai/gpt-oss-120b endpoint 500s the model server on both quirks; a single /run 500 aborts the entire ng_collect_rollouts batch. See #1909 for a minimal repro.

How it behaves

An mcp_call is executed server-side (its output is already populated), and the agent loop already stops when there is no function_call, so the item simply parses and passes through. The MCP items carry no training variant: the chat→responses training converter never produces them, so RESPONSES_TO_TRAIN is unaffected.

Tests

  • tests/unit_tests/test_openai_utils.py: mcp_call / mcp_list_tools / mcp_approval_request validate in a full NeMoGymResponse; lenient optional fields.
  • responses_api_models/openai_model/tests/test_app.py: server returns 200 on an mcp_call response; drop_input_reasoning_items strips reasoning from the upstream input.

All pass (14); ruff clean; DCO signed-off.

The openai_model server 500'd on two gpt-oss-via-Responses-API quirks, and a
single 500 aborts the whole rollout collection:

1. Hosted-MCP output items. gpt-oss surfaces its built-in python tool as an
   'mcp_call' output item (also mcp_list_tools / mcp_approval_request). These
   are valid OpenAI Responses output types but were absent from the
   NeMoGymResponse output-item union, so NeMoGymResponse.model_validate raised.
   Add lenient NeMoGymResponseMcpCall/McpListTools/McpApprovalRequest models to
   the union. The agent already stops when no function_call is present, so a
   server-executed mcp_call (output pre-populated) simply passes through.

2. Content-less reasoning items. Opt-in drop_input_reasoning_items strips
   type=reasoning input items before the upstream call, working around
   endpoints that 500 with KeyError 'content' when their own reasoning items
   are echoed back across tool turns. Wired via POLICY_DROP_REASONING_ITEMS.

Tests: mcp_call/list_tools/approval_request validate (unit + server-level 200);
drop_input_reasoning_items strips reasoning from the upstream input.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: OliviaViessmann <oviessmann@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 2, 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.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Jul 2, 2026
@OliviaViessmann
OliviaViessmann marked this pull request as ready for review July 2, 2026 13:27
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: OliviaViessmann <oviessmann@nvidia.com>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Jul 4, 2026
Comment thread nemo_gym/openai_utils.py Resolved
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-customer Waiting on the original author to respond and removed waiting-on-maintainers Waiting on maintainers to respond labels Jul 14, 2026
OliviaViessmann and others added 2 commits July 14, 2026 09:38
… types

Address review: NeMoGymResponseMcpCall/McpListTools/McpApprovalRequest
redefined the upstream Responses output-item fields from scratch. Inherit from
openai's McpCall/McpListTools/McpApprovalRequest instead, overriding only what
NVIDIA-hosted gpt-oss requires: id/server_label relaxed to optional, McpCall
status widened to str, and McpListTools tools kept as List[Any] so raw tool
entries pass through. Add a test asserting the inheritance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: OliviaViessmann <oviessmann@nvidia.com>
Comment thread nemo_gym/openai_utils.py Resolved
@bxyu-nvidia
bxyu-nvidia merged commit 21e6882 into NVIDIA-NeMo:main Jul 14, 2026
12 of 15 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-request Issue reported or requested by someone from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai_model 500s on gpt-oss hosted-MCP (mcp_call) output items, aborting rollout collection

4 participants