[recipe] fix: normalize LangGraph chat template token IDs - #140
Open
le-czs wants to merge 1 commit into
Open
Conversation
Normalize chat-template outputs at LangGraph boundaries before they are sliced or mutated. Add CPU regression coverage for initial prompts, Hermes tool responses, and bound system prompts. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: CzsGit <czsde@outlook.com>
le-czs
marked this pull request as ready for review
August 20, 2026 07:53
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.
What does this PR do?
Fixes #139 by normalizing every
tokenizer.apply_chat_template(..., tokenize=True)result used by the LangGraph recipe before it is sliced, appended to, sent to the rollout server, or stored in response metadata. This makes tokenizers returning a TransformersBatchEncodingfollow the same path as tokenizers returninglist[int].This is not a duplicate: no open PR matched issue #139 or the
langgraph BatchEncoding chat templatekeywords when checked on 2026-08-20. Open-PR searchAI assistance disclosure: OpenAI Codex was used to inspect the issue, implement the change, run checks, and draft this PR. The PR remains a draft pending human review of every changed line.
Checklist Before Starting
[{modules}] {type}: {description}.Test
pre-commit run --all-files --show-diff-on-failure --color=always: passed (ruff,ruff-format).recipe/langgraph_agent/test_chat_model_on_cpu.py: 8 tests passed in the combined agent-loop regression suite.val_onlyrun on 2 H20 GPUs: platform phase 5, container exit code 0, MATHacc/mean@1=0.996, and no occurrence ofBatchEncoding/listTypeErrorin the full job log.API and Usage Example
No public API or configuration changes.
Design & Code Changes
verl.utils.normalize_token_idshelper already provided by the verl commit pinned inlanggraph_agent/REQUIRED_VERL.txt.BatchEncodingfor all three paths.Checklist Before Submitting