Repository navigation
[Fix] openai: Reject developer messages silently omitted by chat templates - #40103
yuchenwang3 wants to merge 2 commits into
Conversation
7fa5649 to
03e9a1b
Compare
|
Rebased onto main ( The chat-serving and prompt-round-trip CPU suites pass: 155 tests. All applicable changed-file pre-commit hooks pass. No GPU/full-server run was performed for this revision. |
|
@JustinTong0323 Could you review the developer-message handling here? It returns 400 before generation when the selected template silently omits those instructions. Rebased onto |
b49304c to
55589f4
Compare
|
@JustinTong0323 Rebased on main and fixed the conflict. All 170 chat-serving and prompt-round-trip CPU tests pass, and the branch includes the updated CI minimum base. Could you review the developer-message check and enable CI? |
Assisted-by: OpenAI Codex Signed-off-by: Yuchen Wang <[email protected]>
55589f4 to
732aaba
Compare
|
Head |
Assisted-by: OpenAI Codex Signed-off-by: Yuchen Wang <[email protected]>
|
Merged current main in 9de27b0 and resolved the test conflict by keeping both the developer-role and output-limit cases. The chat-serving and prompt-round-trip suites pass all 226 CPU tests; changed-file pre-commit hooks pass. Could a maintainer enable |
Motivation
Fixes #40082. A chat template can silently omit
developermessages while/v1/chat/completionsaccepts the request. With the Qwen3-0.6B tokenizer, the resulting prompt contains the user question but loses the developer instruction.Return a 400 response before generation when the selected Jinja template does not render a developer message. Preserve the role, contents, and ordering for templates that support it; do not implicitly promote developer instructions to system instructions.
Modifications
I checked existing work: #40077 addresses inline instruction ordering in Responses/Kimi Messages, not unsupported developer roles in this generic Chat Completions path. No direct fix for #40082 was found at submission.
Latest validation (November 19)
Merged current main
17a9168f1f99into9de27b0f8f5d, retaining both developer-role regressions and upstream's output-limit validation tests. The chat-serving suite passed 217 tests and the prompt-round-trip suite passed 9 tests with normal imports in the restored macOS Python 3.12 environment, using the suite's existingmaybe_stub_sgl_kernelhelper. All applicable changed-file pre-commit hooks passed. No GPU or live server run was performed.Previous validation (October 26)
Merged main
e732f5d41e9d279c1be7e5818ce9fd8bd425c0b2into head732aaba18a2a3525da4a38aebba9d0087984d287. The upstream GLM47 tokenizer fixture now supports the non-tokenized developer-message probe used by this change.The chat-serving and prompt-round-trip CPU suites passed all 188 tests with normal imports and an isolated
tml-renderers==0.1.0dependency overlay. All applicable changed-file pre-commit hooks passed. No GPU or full-server run was performed. These are the saved October 26 results; they were not rerun on November 5.The current CI gate reports
Missing required label 'run-ci'; model/server tests have not run on this head.Latest validation (September 21)
Rebased onto main (
00986c81b) at03e9a1bfd2953741c00ffa3a83bfe7d3b8aa6e95. Resolved the overlap with the new direct-token encoding path, preserving its control tokens. Added coverage for supported and dropped developer messages on that path, including cache reuse.The chat-serving and prompt-round-trip CPU suites pass: 155 tests. All applicable changed-file pre-commit hooks pass. No GPU/full-server run was performed for this revision.
Earlier validation below describes the original revision unless stated otherwise.
Accuracy Tests
CPU validation on macOS, Python 3.12, Torch 2.13.0, Transformers 5.12.1:
PYTHONPATH=python .venv/bin/python -m unittest \ test.registered.unit.entrypoints.openai.test_serving_chat -q # Ran 144 tests: OKThe suite uses its existing mocked tokenizer manager/generation and
maybe_stub_sgl_kernelCPU helper. The added template tests use Transformers' real Jinja renderer. A baseline control with the new tests and unmodifiedserving_chat.pyfails the three new rejection checks; the supported-role/cache control passes.Separately loaded the actual
Qwen/Qwen3-0.6Btokenizer atc1899de289a04d12100db370d81485cdf75e47ca: the original template omits the developer instruction; the patched serving handler returns 400 before calling generation; a system-role control retains the instruction. This checks the tokenizer and handler, not a live GPU server or model accuracy benchmark. No model weights were loaded.Speed Tests and Profiling
No end-to-end throughput benchmark. There is one additional CPU template render for an uncached request containing developer messages; there is no additional model invocation. Requests without developer messages and existing template-cache hits retain their render counts.
Checklist
AI assistance: developed and tested with OpenAI Codex.
CI States
Latest PR Test (Base): ⊘ Skipped -- add the
run-cilabel to run CI tests.Latest PR Test (Extra): ⊘ Skipped -- add the
run-cilabel to run CI tests.Latest PR Test (AMD ROCm 10): ⊘ Skipped -- add the
run-cilabel to run CI tests.Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: