快速结论:这个报错通常发生在 llama-server 运行 gpt-oss-20b 模型、使用工具调用且开启 prompt cache 复用时,模型生成了不符合 Harmony 通道格式的畸形 <|channel|> 头,导致整个回合的 PEG 解析失败。优先排查 cache 复用(--cache-reuse)与 system prompt 动态变化导致的路径分歧。
适用环境:Windows x86_64,llama.cpp build 10488(官方 CUDA 13.3 版,Clang 20.1.8),CUDA 后端,RTX 5070 Ti 16 GB,模型为 ggml-org/gpt-oss-20b-GGUF 的 gpt-oss-20b-MXFP4.gguf,使用 --jinja 和 ChatML/GPT-OSS 模板。
最快修复方案:暂无确认的一步修复方案。Issue 中用户通过禁用或跳过部分 prompt cache 复用(--cache-reuse 相关设置)能显著降低触发概率,但作者未能进一步验证。对于已发生的解析错误,作者建议实现“宽松重解析”路径,但未被合并。
注意事项:该问题并非纯采样随机,而是与 cache 复用导致的 SWA 窗口失效有关,--checkpoint-min-step 1024 无效;--fa on(flash attention)配合 -ngl 99 下 VRAM 不足,作者未能测试 --swa-full。
问题场景
用户在使用 llama-server(llama.cpp)运行 gpt-oss-20b 模型,通过 Home Assistant 作为语言助手,进行工具调用(约 24 个函数工具),以 OpenAI 推荐的采样参数(--temp 1.0 --top-p 1.0)和长对话上下文(约 13k tokens)运行时,约 1%~4% 的回合会在中途抛出 “The model produced output that does not match the expected peg-native format”,整个回合结果被丢弃。
报错原文
Eval bug: gpt-oss-20b malformed Harmony channel header (`` + free text / `??` / `commentary?`) fails the final PEG parse and errors the whole turn
[server log] W common_chat_peg_parse: unparsed peg-native output: commentary to=assistantcommentary?commentary=short?comment?…???assistantanalysisWe need to answer: "What causes the porch light to come on at night?" ...
原因分析
可能原因有两层:
1. 缓存复用导致上下文损坏:作者通过对照实验发现,问题几乎总是出现在 prompt cache 部分复用、且 system prompt 每次动态变化(时间、传感器值)导致前缀分歧的场景。在固定 seed、40 次尝试中,完全复用前缀 0/40 失败;修改几个 token 使其分歧则 8/40 失败。作者猜测 gpt-oss 的 SWA(滑动窗口注意力)层在部分缓存复用后丢失了局部窗口,导致模型产生大量 ? 或 ... 垃圾 token。
2. 解析器容错不足:即使上下文中有上述垃圾 token,common_chat_peg_parse 对畸形 <|channel|> 头的容错仅覆盖 #21286 中的一种形态(<|channel|>commentary to=assistant 后紧跟合法通道),其余形态(如 <|channel|>commentary?commentary?、<|channel|>...?、<|channel|>commentary says tool returned)均解析失败并中断整个回合,而实际内容(analysis 块和工具调用)往往是完好的。
环境排查
- llama.cpp 版本:build 10488(b10488),检查
common/chat.cpp到 b10622 是否有 gpt-oss/Harmony 解析器相关变更(Issue 作者确认无)。 - CUDA 后端与显卡:RTX 5070 Ti 16 GB,驱动 591.86,
-ngl 99全量加载。 - 模型文件:
gpt-oss-20b-MXFP4.gguf(sha25627cd6c...),需与 HF LFS 校验一致。 - 运行参数:
--jinja、--cache-reuse 256、-fa on、-ub 2048、-b 2048、--parallel 1、--temp 1.0 --top-p 1.0(server 默认 top_k 40 / min_p 0.05)。 - Chat template kwargs:
reasoning_effort=medium(通过LLAMA_ARG_CHAT_TEMPLATE_KWARGS)。 - Prompt 特征:工具数组约 24 个函数,对话上下文约 13k tokens。
解决步骤
- 确认是否可用参数临时规避:在 VRAM 充足的前提下尝试
--swa-full(Issue 作者因显存不足未能验证,但这是最可能有效的规避手段,因为问题与 SWA 窗口失效相关)。 - 降低 cache 复用或不使用动态前缀:如果 system prompt 每次都会变化,考虑关闭或减少
--cache-reuse(例如--cache-reuse 0),或改为完全重新 prefill;作者实测完全 re-prefill 时 82 次全无失败。 - 若复现且愿意调试,可应用宽松解析补丁(需自行实现,社区未正式提供):在
common_chat_peg_parse中,当最终 PEG 解析失败时,尝试用 lenient 解析(is_partial=true路径)重新解析,成功后返回结果而不是报错——作者已验证该路径可恢复所有 9 个失败案例的输出。 - 检查上下文历史:如果最近一次工具调用返回了垃圾 token(大量
?/...),重放该回合后 30/40 seed 会触发此错误,建议在对话树中清除或跳过该历史片段。
验证方法
修复后,在长时间工具调用对话(≥100 回合全量统计)中观察:不再出现 “unparsed peg-native output” 日志行,且服务端不再返回 “The model produced output that does not match the expected peg-native format” 错误;如果使用了宽松解析,验证被恢复的输出结构与正常输出一致。
参考来源
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。

![[BUG] `crewai create` offers 7 retired Anthropic model ids that 404 on first call](https://www.chat-gpts.plus/wp-content/uploads/2026/08/7124-c5bd0d53-768x403.jpg)
![[Bug]: Using DeepSeek with LlamaIndex causes a 400 Bad Request because LlamaIndex calls the deprecated /v1/completions text endpoint instead](https://www.chat-gpts.plus/wp-content/uploads/2026/08/22846-c859ce1c-768x403.jpg)