Repository navigation
Closed as duplicate
Description
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
- Download model
HF_HOME=.cache/ \
HF_HUB_ENABLE_HF_TRANSFER=1 \
hf download openai/gpt-oss-20b- 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- 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")- 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- To quickly test your vLLM set up with the Gym environment, launch a
simple_weatheragent 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}]"- Then run:
python responses_api_agents/simple_agent/client.pyObserve 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 NOTEAfter this fix, it now works with gpt-oss served with vLLM.
Environment details
- Latest version of Gym as of 9.24.25
- 1xA100
- vLLM version 0.10.2
Metadata
Metadata
Assignees
Labels
modelsinfra for different models and inference providers; middleware to standardize to OAI responses
Activity