Repository navigation
Llama 3.x and GPT-OSS templates: treat tool_calls None as no tool call - #17176
Merged
Merged
Conversation
`datasets` fills `tool_calls: None` into every plain message of a tool-calling dataset. The two templates tested whether the key exists, so each of those turns was read as a tool call. Llama 3.1 raised `object of type 'NoneType' has no len()` and GPT-OSS raised `None has no element 0`, on the plain rows as well as the tool rows, which stops the whole formatting map. Test `message.tool_calls` instead, as the Qwen and Gemma templates already do. A missing key renders exactly as before. An empty `tool_calls: []` now renders as a plain turn instead of raising. Test: `tests/python/test_chat_template_tool_calls_none.py` renders plain and tool conversations with `tool_calls` filled with None or [] and compares them to the clean ones. It fails 33 of 33 on main and passes with the fix.
Member
|
@codex review |
1 similar comment
Member
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
datasetsfillstool_calls: Noneinto every plain message of a tool-calling dataset.get_chat_template(tok, "llama-3.1")then raisesTypeError: object of type 'NoneType' has no len()and"gpt-oss"raisesUndefinedError: None has no element 0, on the plain rows too, so the whole formatting map dies.Both templates tested
'tool_calls' in message, which is true for a None value. They now testmessage.tool_calls, like the Qwen and Gemma templates. Covers the llama-3.1/3.2/3.3 aliases and gpt-oss/gptoss. An emptytool_calls: []now renders as a plain turn instead of raising.Rendering of conversations without the key is byte-identical (96 plain, tool, thinking and tools=... renders compared against main).
Test:
pytest tests/python/test_chat_template_tool_calls_none.pyfails 33 of 33 on main and passes 33 with the fix. Neighbouring chat template tests: 313 passed.