mirror of
https://github.com/kvcache-ai/sglang.git
synced 2026-11-05 01:07:39 +00:00
[PR #92] [MERGED] fix(openai): support DSV4 reasoning in Responses API #92
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/sglang#92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/sglang/pull/92
Author: @yyj6666667
Created: 9/9/2026
Status: ✅ Merged
Merged: 9/9/2026
Merged by: @yyj6666667
Base:
main← Head:fix/dsv4-reasoning-responses-codex📝 Commits (2)
2819389fix(openai): support DSV4 reasoning in Responses APIdb87597style: sort DSV4 OpenAI imports📊 Changes
7 files changed (+1608 additions, -153 deletions)
View changed files
➕
python/sglang/srt/entrypoints/openai/chat_encoding.py(+107 -0)📝
python/sglang/srt/entrypoints/openai/encoding_dsv4.py(+44 -12)📝
python/sglang/srt/entrypoints/openai/protocol.py(+76 -30)📝
python/sglang/srt/entrypoints/openai/serving_chat.py(+135 -31)📝
python/sglang/srt/entrypoints/openai/serving_responses.py(+846 -78)📝
python/sglang/srt/environ.py(+3 -2)➕
test/registered/unit/entrypoints/openai/test_dsv4_reasoning_responses.py(+397 -0)📄 Description
Summary
low/high/maxprompt mapping while preserving the older preview checkpoint mappingreasoning_effortand Responsesreasoning.effortthrough one DSV4 policy; omitted/null defaults to thinking +max,nonedisables thinking, and unsupported strings warn and fall back to thinking +maxchat_template_kwargsand the old environment variable as compatibility-only fallbacksnamespace,web_search, andreasoning.encrypted_contentrequest shapes for wire compatibility without claiming to execute unsupported tools or synthesize encrypted reasoningThis fixes the one-level-off encoder mapping described in sgl-project/sglang#33185, and also fixes the intermediate Responses API path where Codex's standard effort field previously did not reach the DSV4 encoder.
DSV4 behavior
nullmaxlowlowhighhighmaxmaxnoneminimal/medium/xhigh/ other stringsmaxEffort selects a model prompt prefix. It does not alter the token budget or kernel scheduler.
Compatibility boundary
reasoning_effortreasoning: {"effort": ..., "summary": ...}functiontools are exposed to DSV4 and round-trip throughfunction_call_outputnamespaceandweb_searchobjects are accepted but deliberately not exposed or executed in the non-Harmony pathValidation
git diff --check: passedinput_tokens/output_tokensusage fieldsreasoning.effort=max, generated anexec_commandcall, consumed itsfunction_call_output, returned the marker exactly, and exited 0The qj5090 run used an immutable image rebuilt with a wheel from the functional SGLang commit. The subsequent PR-head change only sorted imports. The already-running production container was not modified.
CI note
The heavyweight test workflows are gated on the maintainer-controlled
run-cilabel. The automatic lint workflow runs pre-commit over the entire fork and currently fails on existing files outside this PR (including 79 Black rewrites, existing shebang modes, and unrelated Ruff errors). After the import-only fix, none of this PR's seven files appears in the formatter rewrite list; their targeted isort, Black, RuffF401/F821, AST/bytecode, codespell, and whitespace checks pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.