Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
This repository was archived by the owner on May 13, 2026. It is now read-only.

[Bug] <|Assistant▁END▁OF▁TOOL_CALLS|> and <|Tool|> tokens leak into user-visible streaming output #456

Description

@NunoLemos101

📦 部署方式

Docker

📌 软件版本

4.4.3

💻 系统环境

macOS

📌 系统版本

No response

🐛 问题描述

Sometimes when doing tool calls, the LLM starts streaming the tool result duplicated.

I put Claude Code investigating this issue and it says:

  Root Cause                                                                                                                              
                                                                  
  The regex on line 24 of leaked_output_sanitize.go:                                                                                      
                                                                  
  var leakedMetaMarkerPattern = regexp.MustCompile(`(?i)<[|\|]\s*(?:assistant|tool|end[_▁]of[_▁]sentence|end[_▁]of[_▁]thinking|end[_▁]of[
  _▁]toolresults|end[_▁]of[_▁]instructions)\s*[|\|]>`)                                                                                   
   
  Tokens NOT matched: 
  
  <|Tool|>[...]: The regex matches bare tool between delimiters, but the actual leaked token includes a JSON payload after closing | >, and the content between <|Tool|> and <|end▁of▁toolresults|> is not stripped

  <|Assistant▁END▁OF▁TOOL_CALLS|>: Compound token not in the alternation group — only simple assistant is matched

Image

📷 复现步骤

No response

🚦 期望结果

I manually edited the HTML to show how expected behavior should look:

Image

📝 补充信息

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions