vllm - ✅(Solved) Fix [Feature]: Add separate_reasoning option for OpenAI chat completion API [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#43171Fetched 2026-05-20 03:39:36
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #43173: [Frontend] Add separate_reasoning parameter to chat completion API

Description (problem / solution / changelog)

Purpose

Resolves #43171

Add a separate_reasoning parameter to the /v1/chat/completions API request to control whether reasoning content is returned as a separate reasoning field or merged into the content field.

  • Default True preserves existing behavior (reasoning as a separate field).
  • When False, reasoning text is prepended to content and reasoning is set to None.
  • Works for both streaming and non-streaming responses, across all code paths (reasoning parser, harmony, plain content).

This is useful for clients that don't natively support the reasoning field and need all output in content.

Test Plan

Unit tests added in tests/entrypoints/openai/chat_completion/test_separate_reasoning.py:

.venv/bin/python -m pytest tests/entrypoints/openai/chat_completion/test_separate_reasoning.py -v

Test Result

11 passed

  • TestSeparateReasoningParameter: 3 tests (default True, explicit False, explicit True)
  • TestDeltaMessageReasoningMerge: 4 tests (merge with content, reasoning-only, no reasoning, preserve tool_calls)
  • TestDeltaMessageReasoningMerge::test_merge_matrix: 4 parametrized cases covering all combinations of separate_reasoning × reasoning presence

Linter: ruff check and ruff format both pass.

<details> <summary> Essential Elements of an Effective PR Description Checklist </summary>
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
</details>

Changed files

  • docs/features/reasoning_outputs.md (modified, +16/-0)
  • tests/entrypoints/openai/chat_completion/test_separate_reasoning.py (added, +124/-0)
  • vllm/entrypoints/openai/chat_completion/protocol.py (modified, +7/-0)
  • vllm/entrypoints/openai/chat_completion/serving.py (modified, +35/-0)

Code Example

{
  "message": {
    "reasoning": "...",
    "content": "..."
  }
}

---

{
  "reasoning": "...",
  "content": "..."
}

---

{
  "content": "<reasoning><content>"
}
RAW_BUFFERClick to expand / collapse

🚀 The feature, motivation and pitch

Problem

Currently vLLM OpenAI-compatible chat completion responses expose reasoning separately:

{
  "message": {
    "reasoning": "...",
    "content": "..."
  }
}

Some OpenAI-compatible clients, SDKs, and agent frameworks expect all generated text to appear in content only and do not parse the reasoning field.

As a result, users currently need to add custom post-processing logic on the client side to merge reasoning back into content.

Proposed feature

Add a new optional request parameter:

separate_reasoning: bool = True

Behavior:

separate_reasoning=True (default) Keep existing behavior Return reasoning and content separately

{
  "reasoning": "...",
  "content": "..."
}

separate_reasoning=False Merge reasoning into content Suppress the reasoning field

{
  "content": "<reasoning><content>"
}

Motivation

This improves compatibility with:

Existing OpenAI-compatible APIs SDKs and client libraries that only consume content Agent frameworks that do not understand a separate reasoning field Existing applications migrating to vLLM without additional response transformations

Why this approach

No breaking changes Default behavior remains unchanged Requires minimal changes Applies consistently to both streaming and non-streaming responses

Alternatives

No response

Additional context

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Feature]: Add separate_reasoning option for OpenAI chat completion API [1 pull requests, 1 participants]