Repository navigation
Description
Problem
NeMo Gym's litellm_model can reject a successful LiteLLM /v1/responses payload during local NeMoGymResponse validation.
LiteLLM 1.97.0's Chat Completions-to-Responses transformation can return:
usage.input_tokens_details: nullandusage.output_tokens_details: null;- a reasoning item without
summarywhose content is taggedoutput_textinstead ofreasoning_text.
Gym requires object-shaped usage details, a list-valued reasoning summary, and canonical reasoning_text content. The upstream request has succeeded, but Gym fails before returning the response to the agent.
Reproduce
Save this as reproduce.py:
from litellm.responses.litellm_completion_transformation.transformation import (
LiteLLMCompletionResponsesConfig,
)
from nemo_gym.openai_utils import NeMoGymResponse
response = LiteLLMCompletionResponsesConfig.transform_chat_completion_response_to_responses_api_response(
request_input="Synthetic schema test",
responses_api_request={},
chat_completion_response={
"id": "chatcmpl-reasoning-test",
"created": 1700000000,
"object": "chat.completion",
"model": "synthetic/model",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"reasoning_content": "Synthetic reasoning.",
"content": "Answer",
},
}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15},
},
)
NeMoGymResponse.model_validate(response.model_dump())Run it using only the published LiteLLM and NeMo Gym packages:
uv run --isolated --python 3.13.14 \
--with nemo-gym==0.6.0 \
--with litellm==1.97.0 \
python reproduce.pyNo credentials or model/provider calls are required.
Actual behavior
Validation fails. The relevant errors are:
output.0.NeMoGymResponseReasoningItem.summary: Field required
output.0.NeMoGymResponseReasoningItem.content.0.type: Input should be 'reasoning_text'
usage.input_tokens_details: Input should be a valid dictionary
usage.output_tokens_details: Input should be a valid dictionary
Impact and scope
Any Gym workflow using responses_api_models/litellm_model with an affected LiteLLM /v1/responses payload can fail before the agent or verifier receives the successful model response. This can affect:
- benchmark evaluation and reward-profiling rollout collection;
- multi-turn or tool-using agents, if any model turn has the affected shape;
- training rollout and demonstration-data generation using
litellm_model; - LLM-as-judge verification when the judge is configured through
litellm_model.
Thinking-enabled responses can trigger the malformed reasoning-item fields. Thinking-disabled responses may still be affected when LiteLLM returns null or missing usage-detail objects.
The issue is specific to the litellm_model Responses API path and the affected payload shapes. It does not establish an issue with:
- model servers such as
vllm_modelthat already return Gym-compatible responses; - direct Chat Completions workflows;
- offline processing of previously valid rollouts;
- every LiteLLM version, provider, or streaming workflow.
Expected behavior
litellm_model should normalize a supported LiteLLM response into Gym's canonical Responses representation before validation.
Cause and potential fix
responses_api_models/litellm_model/app.py::_normalize_to_response() normalizes top-level reasoning.effort and object: "chat.completion" payloads, but returns object: "response" payloads before normalizing nested reasoning and usage fields.
Before that early return, normalize:
- missing or null reasoning
summaryto[]; output_texttoreasoning_textwithin reasoning items;- missing or null usage-detail objects to
{"cached_tokens": null}and{"reasoning_tokens": null}respectively, while preserving reported values.
A focused regression test should pass the payload above through _normalize_to_response() and then NeMoGymResponse.model_validate().
Versions
- NeMo Gym 0.6.0
- LiteLLM 1.97.0
- Python 3.13.14
- OpenAI 2.44.0, resolved by NeMo Gym
- Pydantic 2.13.3 at reproduction time
Possible affected range: Representative testing confirms the issue from LiteLLM 1.83.0 through 1.101.0; no fixed stable release has been identified.
Activity
fix(litellm_model): normalize native LiteLLM responses before NeMoGym…