Repository navigation
Conversation
0c50971 to
b356821
Compare
|
We independently reproduced the instruction-ordering issue described here. In a CPU tokenization check with a synthetic 721k-token GLM conversation, appending a system reminder left only 10.45% of the original token prefix unchanged. Keeping the reminder in its original position preserved 100% of that prefix. Our fix still combines consecutive instructions at the start of the conversation, but leaves later instructions in place. We then tested native Responses requests on GLM 5.3, Kimi K3 and DeepSeek V4.1. Each continuation included the previous assistant output, a tool result and a new system reminder. We kept request settings fixed and used the same worker so its KV cache remained available. Two continuations per model produced these results:
These measurements are from our backport on deployment-specific checkpoints; we have not tested this PR's latest commit. The DeepSeek tests used a tool schema with One additional regression test could cover top-level This investigation and comment were prepared with Codex. All measurements above come from executed CPU/GPU tests. |
f6fdfed to
4fdd158
Compare
Resolve once on OpenAIServingChat whether the prompt renderer keeps a mid-conversation system message in place (native encoder allowlist, then conversation template, then the Jinja probe), and read it from both Anthropic Messages and Responses. Drops the defensive getattrs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4fdd158 to
2722e7f
Compare
…e-system-upstream # Conflicts: # python/sglang/srt/entrypoints/openai/serving_chat.py
|
/rerun-test test/registered/unit/entrypoints/openai/test_serving_responses.py test/registered/unit/entrypoints/anthropic/test_serving.py test/registered/unit/entrypoints/openai/test_serving_chat.py test/registered/unit/entrypoints/openai/test_responses_custom_tools.py |
|
Results for 🚀 |
Related entrypoints PRs: #39711, #39716. Each is independent and they can merge in any order.
Motivation
Responses always moves an inline
developer/systeminput into the leading system message. Appending an instruction to a conversation therefore rewrites the start of the prompt and throws away the whole cached prefix, which is common for agentic clients./v1/responseswent from 25.5% to 90.7%, and from 12.9% to 92.2% for prompts ≥128K tokens. Chat Completions stayed flat (91.8% → 93.0%). This compares two 30-minute windows on 2026-09-18. They weren't matched, and the deploy included other changes, so treat it as supporting evidence rather than an A/B test.Anthropic Messages already keeps inline system messages when the chat template renders them (#28906), but it probes the tokenizer's Jinja template. Kimi K3 renders with a native encoder and has no Jinja template, so K3 Messages requests are still hoisted.
Modifications
OpenAIServingChat.supports_inline_systemis resolved once at startup from the renderer that actually builds the prompt: the native encoder allowlist (spec_supports_inline_system, currentlykimi_k3) when a native encoder is active,Falsefor a conversation--chat-template, and otherwise the existing Jinja probe (detect_inline_system_support).--chat-templateor a native encoder outside the allowlist, since the probed Jinja template is not what renders those prompts.dsv4.1branch and was closed unmerged when that branch was deleted. Addingdsv41to the allowlist is a one-line follow-up once its encoder is checked.Tests
test_serving_responses.py::test_inline_instruction_keeps_history_prefix(4 cases): the K3 and inline-Jinja cases fail on main because the instruction is hoisted. The conversation-template and dropping-Jinja cases pin the merge fallback; the conversation-template case fails if the resolver ignores--chat-template.anthropic/test_serving.py::test_inline_system_support_comes_from_the_prompt_rendererfails on main, where Messages probes a missing Jinja template and hoists.test_serving_responses.py,test_serving_responses_stream.py,test_serving_chat.py, andanthropic/test_serving.pypass.CI States
Latest PR Test (Base): ⏳ Run #36784288085
Latest PR Test (Extra): ❌ Run #36784287853
Latest PR Test (AMD ROCm 10): ⏳ Run #36784288006