Skip to content

fix duplicate reasoning and reasoning_content#1345

Merged
shihaobai merged 1 commit into
mainfrom
openai_fix_0612
Jun 12, 2026
Merged

fix duplicate reasoning and reasoning_content#1345
shihaobai merged 1 commit into
mainfrom
openai_fix_0612

Conversation

@shihaobai

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

critical

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)

critical

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.

@shihaobai shihaobai merged commit 3a15cb0 into main Jun 12, 2026
1 check passed
@shihaobai shihaobai deleted the openai_fix_0612 branch June 12, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant