fix duplicate reasoning and reasoning_content#1345
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the _sync_reasoning_aliases model validator from both ChatMessage and DeltaMessage in lightllm/server/api_models.py. Feedback indicates that this change breaks OpenAI API compatibility for reasoning models (like DeepSeek-R1) because the standard reasoning_content field will remain empty in API responses and stream chunks. It is recommended to revert these removals or properly handle the field mapping in api_openai.py.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
I am having trouble creating individual review comments. Click here to see my feedback.
lightllm/server/api_models.py (301-307)
Removing the _sync_reasoning_aliases validator completely breaks OpenAI API compatibility for reasoning/thinking models (like DeepSeek-R1).\n\nIn lightllm/server/api_openai.py, the ChatMessage and DeltaMessage models are instantiated by only passing the reasoning argument (e.g., reasoning=reasoning_text). Without this validator, the standard OpenAI field reasoning_content will remain None in the API responses, causing official OpenAI SDKs and clients to miss the reasoning/thinking output entirely.\n\nIf the goal is to avoid duplicating both fields in the serialized JSON response while maintaining compatibility, consider either:\n1. Reverting this change to keep the validator.\n2. Updating api_openai.py to populate reasoning_content directly, and potentially using Pydantic's Field(validation_alias=...) or serialization_alias to handle compatibility without duplicating fields in the response.
lightllm/server/api_models.py (336-342)
Similar to ChatMessage, removing this validator from DeltaMessage breaks streaming reasoning/thinking output for standard OpenAI clients, as api_openai.py only passes reasoning to DeltaMessage during streaming. Without this synchronization, reasoning_content will be None in the stream chunks.
No description provided.