Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #646
/v1/chat/completionspassed adevelopermessage (sent by Codex and other current OpenAI clients) straight to the chat template. Templates that don't name the role handle it badly, and two of the three failures are silent:developeron mainTemplateError: Unexpected message role.(400)TokenizeManager._rendernow rendersdeveloperassystemwhen the chat template does not mentiondeveloper. Templates that name the role (gpt-oss) get it unchanged. The DSV4 encoder path returns before this and keeps its own handling. The mapping copies the message, so the request is not mutated./v1/responsesalready foldsdeveloperinto the system message, so this only changes the chat completions path.Not covered here: a request with both a
systemand adevelopermessage now behaves like one with twosystemmessages. Templates that require a single leading system message (Qwen3.8-Flash-Next) still reject it, now withSystem message must be at the beginning.Merging the two would be a separate change.Testing
RTX 6000 Ada (48 GB), driver 595.99.02, torch 2.14.1+cu130, transformers 5.18, Python 3.12. Tokenizer-only check, no model weights:
TokenizeManager.render_promptwith[{"role": "developer", "content": "Answer in French."}, {"role": "user", "content": "hi"}]against each checkpoint's real tokenizer and chat template:TemplateError: Unexpected message role.systemspellingsystemspellingsystemtests/tokenizer/test_tokenize.py::test_developer_role_renders_as_system_unless_the_template_names_it. With the fix reverted, the case for a template withoutdeveloperfails ({'role': 'developer', ...} != {'role': 'system', ...}). With the fix, both cases pass.pytest tests/tokenizer tests/server: 755 passed, 24 skipped (needs_weights).