Repository navigation
fix(parser): keep anchors when a stop token's text is stripped - #640
Merged
lukealonso merged 4 commits intoSep 4, 2026
Conversation
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 24 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Sep 4, 2026
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
lukealonso
merged commit Sep 4, 2026
5c90fc8
into
local-inference-lab:dev/jovian-judgement
1 check passed
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.
Problem
Serving can strip a stop token's text from
delta_textwhile retaining its ID indelta_token_ids. The non-streaming path likewise passesoutput.texttogether withmodel_output_token_idsto the parser.When the retained stop ID is an auto-assigned
DROP_TERMINAL,TokenIDScanner._recover_holdback_textcannot match the reconstructed text. Its fallback,_rebuild_from_anchors, resolves anchors right to left. A missing trailing DROP can therefore bind a structural anchor such as<tool_call>to a literal lookalike earlier in the text. With one text token followed by a stripped stop ID, the fallback can also lose the text token count.Fix
When reconstructed text does not match,
_recover_holdback_textretries without trailing DROP terminals. If the retained items match the suffix ofdelta_text, it returns them unchanged and defers the DROPs with zero prefix token counts. A laterscan()orflush_pending()still emits the deferred terminals.The previous
findcheck is replaced byendswith. Detokenizer holdback can only precede the current token reconstruction, so a valid reconstruction must be a suffix. A middle match now follows the existing anchor-rebuild path instead of silently discarding trailing text.Compatibility and side effects
TokenIDScannerchange and affects every parser-engine configuration with auto-DROP special tokens.scan()orflush_pending().StreamingParserEngine.finish()always flushes scanner state.Related work and duplicate check
This is the focused scanner portion split from closed PR #540. The GLM delimiter-state change is #639.
Open-PR searches found no upstream PR implementing the stripped trailing DROP recovery. This is not a duplicate of vllm-project/vllm#54971, which changes GLM argument-key parsing and does not touch
TokenIDScanner.Tests
Pytest validation used Python 3.12 in
/opt/venvinside the existingrtx-station/glm53-jovian:lp15image. Source and temporary test dependencies were mounted read-only. Lint validation used the repository-pinned Ruff version throughuvxon the host.Results:
tests/parser/engine: 3,797 passed.git diff --check: passed.Model and serving validation
No live model-generation evaluation was run. This is a deterministic scanner-level regression:
delta_textomits the trailing stop text whiledelta_token_idsretains its ID. Unit and parser-engine tests cover that exact input shape and verify anchor ordering and token-count preservation.AI assistance and human review
Claude Code assisted with implementation and tests. OpenAI Codex performed an independent line-by-line diff review and validation. The human submitter reviewed and understands every changed line.