Skip to content

Add support for vLLM models like gpt-oss #92

Closed as duplicate
Closed as duplicate

Description

@xinyu-dev

Describe the bug

Currently, the VLLMModel enforces a strict check:

# responses_api_models/vllm_model/app.py
assert not choice_dict["message"].get("reasoning_content"), (
     "Please do not use a reasoning parser in vLLM! There is one source of truth for handling data (including reasoning), which is NeMo Gym!"
 )

This creates an issue for gpt-oss models. These models return a reasoning_content field, even if --reasoning-parser is not used during vLLM start up. As a result, the above check fail.

One possible workaround is to detect the reasoning_content field. If detected, we extract content and wrap it with <think></think> tags. Please find more details below.

Steps/Code to reproduce bug

  1. Download model
HF_HOME=.cache/ \
HF_HUB_ENABLE_HF_TRANSFER=1 \
hf download openai/gpt-oss-20b
  1. Launch
HF_HOME=.cache/ \
HOME=. \
VLLM_ATTENTION_BACKEND=TRITON_ATTN_VLLM_V1 \
vllm serve \
    openai/gpt-oss-20b \
    --dtype auto \
    --tensor-parallel-size 1 \
    --gpu-memory-utilization 0.9 \
    --enable-auto-tool-choice --tool-call-parser openai \
    --host 0.0.0.0 \
    --port 10240
  1. Create a script to observe the vLLM behavior for gpt-oss model. Note that it always return reasoning_content
from openai import OpenAI
from loguru import logger

#  Client
client = OpenAI(
    base_url="http://localhost:10240/v1", 
    api_key="EMPTY"
)

# Reponse API
response = client.responses.create(
    model="openai/gpt-oss-20b",
    instructions="You are a helfpul assistant.",
    input="What's the capital of the United States?"
)
logger.info("RESPONSE API")
logger.debug(response.output_text)

# Chat Completion API
response = client.chat.completions.create(
    model="openai/gpt-oss-20b",
    messages=[{"role": "user", "content": "What's the capital of the United States?"}]
)
logger.info("CHAT COMPLETION API")
logger.debug("content: " + response.choices[0].message.content)

# some model will return reasoning_content, even though you did not add `reasoning-parser` in the vllm command. 
try:
    logger.info("Found `response.choices[0].message.reasoning_content`")
    logger.debug("reasoning_content: " + response.choices[0].message.reasoning_content)
except Exception as e:
    logger.debug("`response.choices[0].message.reasoning_content` not found")
  1. Now let's put it to test. In env.yaml, add this line:
# /root/Gym/env.yaml
policy_base_url: "http://localhost:10240/v1"
policy_api_key: "EMPTY"
policy_model_name: openai/gpt-oss-20b # model name as in vLLM
  1. To quickly test your vLLM set up with the Gym environment, launch a simple_weather agent with vLLM:
# ~/Gym/run.sh
config_paths="resources_servers/simple_weather/configs/simple_weather.yaml,\
responses_api_models/vllm_model/configs/vllm_model.yaml"
ng_run "+config_paths=[${config_paths}]"
  1. Then run:
python responses_api_agents/simple_agent/client.py

Observe that an error is raised, complaining about the assertion error.

Possible Workaround

I tested with the following workaround:

# responses_api_models/vllm_model/app.py

# NOTE: comment this out for models like GPT-OSS that return reasoning_content
# assert not choice_dict["message"].get("reasoning_content"), (
#     "Please do not use a reasoning parser in vLLM! There is one source of truth for handling data (including reasoning), which is NeMo Gym!"
# )

# Handle models like GPT-OSS that return reasoning_content
# by moving it to content with think tags
message_dict = choice_dict["message"]
if message_dict.get("reasoning_content"):
	print("DEBUG: Found reasoning_content. Adding to content with think tags.")
	# Move reasoning_content into content with think tags for consistent processing
	reasoning_content = message_dict["reasoning_content"]
	regular_content = message_dict.get("content", "")
	# Use the existing method to wrap reasoning in think tags
	wrapped_reasoning = self._converter._wrap_reasoning_in_think_tags([reasoning_content])
	message_dict["content"] = f"{wrapped_reasoning}{regular_content}"
	# pop it to stay consistent with the original assertion that reasoning_content is not returned
	message_dict.pop("reasoning_content")
# END of NOTE

After this fix, it now works with gpt-oss served with vLLM.

Environment details

  1. Latest version of Gym as of 9.24.25
  2. 1xA100
  3. vLLM version 0.10.2

Activity

  1. added this to the v0.1.0 milestone on Oct 14, 2025
  2. added
    models
    and removed on Oct 21, 2025
  3. added theissue type on Oct 21, 2025
  4. modified the milestones: v0.1.0, v0.2.0 on Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    models

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions