Skip to content

[Docs] Clarify OpenAI chat template defaults - #32172

Merged
JustinTong0323 merged 6 commits into
sgl-project:mainfrom
mottopanikeiku:docs/reasoning-template-defaults
Sep 4, 2026
Merged

JustinTong0323 merged 6 commits into
sgl-project:mainfrom
mottopanikeiku:docs/reasoning-template-defaults

Conversation

@mottopanikeiku

@mottopanikeiku mottopanikeiku commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

PR #29579 added --default-chat-template-kwargs to OpenAIServingChat-backed rendering paths, but the server-argument reference does not list it and the OpenAI chat-completions guide does not explain how its ordinary template keys interact with request values. The Qwen3 example also says that omitting enable_thinking disables reasoning, although omission follows the detected chat-template default and Qwen3 defaults to thinking enabled.

Related to #5948.

Modifications

  • Add --default-chat-template-kwargs to the server-argument reference with its actual None default and JSON type.
  • List the paths that consume these defaults: Chat Completions, Responses, Anthropic-compatible requests, and chat tokenization.
  • Explicitly state that direct Ollama and embedding paths do not consume them.
  • Document request-first precedence for ordinary template keys such as enable_thinking:
    1. explicit request chat_template_kwargs;
    2. --default-chat-template-kwargs;
    3. model chat-template default.
  • Document that reasoning_effort follows a separate normalization path and should not be configured at both server and request layers.
  • Update the reasoning usage checklist to distinguish overriding a template default from enabling the reasoning parser.
  • Correct the Qwen3 omission behavior.
  • Add one concise OpenAI chat-completion launch example.
  • Clarify that reasoning parsers separate reasoning output but do not themselves enable reasoning in a chat template.

This remains a documentation-only change: 2 files, 32 insertions, and 5 deletions.

Accuracy Tests

N/A. No model output or runtime behavior changed.

Speed Tests and Profiling

N/A. Documentation-only change.

Validation

  • Four existing ServingChatTestCase tests covering ordinary default application, per-request override, server-provided effort, and Qwen3's default-true toggle: 4 passed.
  • Full-conversion probe with request reasoning_effort=low and server default reasoning_effort=high: observed request=low, rendered=high, confirming that effort does not follow ordinary-key precedence and motivating the explicit warning not to configure both layers.
  • Source verification of consumers: OpenAIServingResponses inherits OpenAIServingChat and calls _process_messages; Anthropic delegates to the same handler; chat tokenization constructs OpenAIServingChat; direct Ollama calls the tokenizer template directly.
  • mint validate: build validation passed after every independent-review correction, including the final consumer list.
  • pre-commit run --files docs_new/docs/advanced_features/server_arguments.mdx docs_new/docs/basic_usage/openai_api_completions.mdx: all applicable hooks passed.
  • mint dev: visually verified the corrected server-argument row and reasoning section.
  • mint broken-links: the repository-wide command reports 332 links across 86 files; this change adds no links.

Independent review

A separate read-only reviewer checked all three contribution PRs against current source. It found three scope/correctness issues here, all corrected:

  1. universal request-first precedence incorrectly included reasoning_effort;
  2. “server-wide” incorrectly implied every API consumed the defaults;
  3. narrowing to only Chat Completions omitted other OpenAIServingChat-backed consumers.

The final reference now lists the exact consumer groups and exclusions, while the how-to remains focused on its OpenAI Chat Completions example. Closing/reopening refreshed GitHub's stale PR head after each fork update; the current PR-visible head is 43a3467d6.

Checklist

  • Format code according to the SGLang contribution guide.
  • Add unit tests. N/A: documentation-only; existing behavior tests and a full-conversion probe were run.
  • Update documentation according to the contribution guide.
  • Follow the SGLang documentation style and validate the Mintlify build.

CI States

Latest PR Test (Base): ✅ Run #33919561361
Latest PR Test (Extra): ❌ Run #33919601458
Latest PR Test (AMD ROCm 7.2): ➖ No AMD PR run found for this commit.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 23, 2026
@mottopanikeiku

Copy link
Copy Markdown
Contributor Author

Hi @wisclmy0611, could you please review this focused docs update for the merged --default-chat-template-kwargs behavior? It is limited to 2 MDX files (+30/-5); the relevant existing behavior tests pass, mint validate passes, pre-commit passes, and both pages were checked in the local Mintlify preview. @ispobock, could you or another authorized maintainer please run /tag-and-rerun-ci for the current commit? Thank you!

@mottopanikeiku mottopanikeiku changed the title [Docs] Clarify server-wide reasoning template defaults [Docs] Clarify OpenAI chat template defaults Jul 23, 2026
@mottopanikeiku

Copy link
Copy Markdown
Contributor Author

Independent review found two overbroad claims in the first revision. Commit 0d91585e0 now (1) limits the feature to OpenAI-compatible chat-completion requests rather than every server API and (2) limits request-first precedence to ordinary template keys, explicitly documenting reasoning_effort's separate normalization path. I reproduced the effort exception through the full conversion path, then reran mint validate, pre-commit, and both rendered-page checks. The PR title/body are updated. The /tag-and-rerun-ci request applies to this current commit.

@mottopanikeiku

Copy link
Copy Markdown
Contributor Author

Final independent-review scope correction is on fork head 43a3467, but GitHub left the PR object pinned to 0d91585. Closing and immediately reopening to refresh the head association; all prior review context remains in this PR.

@mottopanikeiku

Copy link
Copy Markdown
Contributor Author

Final independent-review correction is in 43a3467d6: the server-argument reference now lists all verified OpenAIServingChat-backed consumers (Chat Completions, Responses, Anthropic-compatible requests, and chat tokenization) and explicitly excludes direct Ollama and embedding paths. mint validate and pre-commit pass on this final wording. Closing/reopening refreshed the stale PR head, so all review corrections are now visible. The /tag-and-rerun-ci request applies to this head.

@JustinTong0323 JustinTong0323 added the run-ci CI: run the baseline test suite on this PR label Sep 4, 2026
@JustinTong0323

Copy link
Copy Markdown
Collaborator

Updated the branch against latest main. The docs directory was renamed docs_new/ → docs/ since this PR opened; the merge carried both file edits over to the new paths, no content changes.

@JustinTong0323 JustinTong0323 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified both edits against current main:

  • Consumer list is accurate: the defaults merge in OpenAIServingChat._process_messages (serving_chat.py), which also covers Responses (serving_responses.py calls _process_messages) and the Anthropic endpoint (delegates to openai_serving_chat), and the merge happens before apply_chat_template, so chat tokenization sees them. Ollama (ollama/serving.py) and embeddings call apply_chat_template directly and never touch the defaults — the exclusion note is correct.
  • Precedence claim matches the implementation: defaults are applied with setdefault, so explicit per-request chat_template_kwargs wins.
  • The reasoning_effort caveat is real: serving_chat.py promotes reasoning_effort out of the kwargs onto the request field, so it indeed doesn't follow the ordinary-key precedence.
  • The Qwen3 enable_thinking default and the "parser doesn't enable reasoning" note match the Qwen3 chat template and parser behavior.

Docs-only, LGTM from my read.

@JustinTong0323 JustinTong0323 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Docs-only, content verified against current main (see earlier review). LGTM.

@JustinTong0323
JustinTong0323 merged commit 3e873c2 into sgl-project:main Sep 4, 2026
121 of 130 checks passed
StevenChenSE pushed a commit to StevenChenSE/sglang that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants