Repository navigation
Keep a Qwen3.5, QwQ or Cohere2 MoE forced-open thought as llama-server parses it - #1524
Merged
Merged
Conversation
This was referenced Oct 28, 2026
Closed
Contributor
|
Chat app preview removed for |
leehack
added a commit
that referenced
this pull request
Oct 28, 2026
# Conflicts: # lib/src/core/template/chat_format_registry.dart # lib/src/core/template/handlers/hermes_handler.dart # lib/src/core/template/handlers/qwen3_coder_xml_handler.dart # lib/src/core/template/xml_tool_call_format.dart
Merged
13 tasks done
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.
Summary
620d2225does: a repeated<think>and an escaped\nstay as generated, and thinking tags after the first end tag stay in the content instead of being parsed as more reasoning. This extends the DeepSeek V3.1 rule from #1512 to these formats through the samekeepsForcedThoughtVerbatimtrait.<tool_call>before</think>ends the thought; a Cohere2 MoE thought ends at<|START_TEXT|>or<|START_ACTION|>when one comes before<|END_THINKING|>(#1523). New traitforcedThoughtContentOpenings.Plan it </thi->Plan it), in parse and stream, for every verbatim format including DeepSeek V3.1.Production-readiness scope
engine.create/ChatSessionreasoning and content for the formats above when the template opens the thought (thinking on). Stream chunks and the final message agree.<think>; a thought that does not start forced-open (Qwen3 with a leading<think>) keeps the existing extraction.<think>as content is #1525; Cohere tests/docs follow-ups are #1526. Remaining divergences are recorded on #750.Completeness checklist
template-engine-internals.md,chat-template-and-parsing.md, both changelogs. README/examples/support matrix: N/A, no capability change.)PR type guidance
extractThinking(drops repeated start tags, unescapes\n, recurses into later pairs) and the stream split only at the end tag, so no content opening ended the thought and a held partial tag was flushed into reasoning at EOF. Tests: upstream oracle fixturetest/fixtures/forced_open_thought_upstream.json(new Qwen3.5, QwQ and Cohere2 MoE entries, a DeepSeek partial-tag case) through parse and whole/bytewise stream, plusthinking_utils_test.dart. Platforms: all (Dart parse).Test Plan
dart run tool/prepare_workspace.dartdart format --output=none --set-exit-if-changed .dart analyzedart test -p vm -j 1 --exclude-tags local-only(+9213 ~5, all passed at7bbcb4848)dart test -p chrome --exclude-tags local-only(CI)./tool/testing/run_template_parity_suites.sh(all suites passed); upstream oracle, sweep, render matrix and mutation runs below.Evidence (harnesses from #1494 / #1512, oracle built from llama.cpp
620d2225):22a0c4518)hermes,qwen3CoderXml,deepseekV3,cohere2Moe; stream != parse for those formats 0 (base 345)Remaining oracle mismatches are upstream parse errors (text before a Cohere marker, trailing text after a call), tool-format differences and the recorded divergences; none come from this change.
Mutants (all killed): parse not verbatim per handler (Hermes, Qwen3-Coder XML, Cohere2 MoE, R7B openings ignored), registry traits off (hermes, qwen3CoderXml, cohere2Moe verbatim; cohere2Moe and qwen3CoderXml stream openings), content openings ignored / consumed / winning after the end tag in parse and stream, no partial-tag drop in parse, stream EOF keeps held prefix, stream does not hold an opening prefix,
withoutTrailingTagPrefixkeeps the shortest match or stops at the first tag, each Cohere opening dropped, XML verbatim branch skipped. 22 of 22.Matrix Evidence
static-format-analyzeroot-vm7bbcb4848root-chromecoverage-libstructured-output-adversarial620d2225high-risk-exact-head-independent-qa/opt/UnitySrc/personal/llama/llamadart-evidence/pr-1524/docs-sitegguf-chat-features-smokeReview Notes
b3f443a91(audited7bbcb4848+ merge of main16d4e72f3; delta checkdelta-b3f443a91.md), CI pending.High-risk regression review
620d2225(common_chat_templates_apply+common_chat_peg_parse, whole and bytewise) for the affected templates intest/fixtures/llama_cpp_templates/.