openclaw - ✅(Solved) Fix [Bug]: Raw Kimi tool-call markers leak to WhatsApp as visible assistant text in 2026.4.2 [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60465Fetched 2026-04-08 02:50:52
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
1
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2referenced ×1subscribed ×1

When using OpenClaw with WhatsApp and a Kimi-based model (k2p5 / provider normalized as kimi), malformed tool-call output can be delivered to the user as normal chat text instead of being parsed or suppressed.

The leaked message contains raw internal tool-call markers such as:

<|tool_calls_section_begin|> <|tool_call_begin|> <|tool_call_argument_begin|> <|tool_call_end|> <|tool_calls_section_end|>

Example of user-visible leaked output:

The tool syntax is showing up in chat. Let me check your Chrome profiles properly. <|tool_calls_section_begin|> <|tool_call_begin|> exec:12 <|tool_call_argument_begin|> {"command": "ls -la ~/Library/Application Support/Google/ | grep -i chrome", "timeout": 30} <|tool_call_end|> <|tool_calls_section_end|>

This should never be delivered to external messaging channels.

Root Cause

When using OpenClaw with WhatsApp and a Kimi-based model (k2p5 / provider normalized as kimi), malformed tool-call output can be delivered to the user as normal chat text instead of being parsed or suppressed.

The leaked message contains raw internal tool-call markers such as:

<|tool_calls_section_begin|> <|tool_call_begin|> <|tool_call_argument_begin|> <|tool_call_end|> <|tool_calls_section_end|>

Example of user-visible leaked output:

The tool syntax is showing up in chat. Let me check your Chrome profiles properly. <|tool_calls_section_begin|> <|tool_call_begin|> exec:12 <|tool_call_argument_begin|> {"command": "ls -la ~/Library/Application Support/Google/ | grep -i chrome", "timeout": 30} <|tool_call_end|> <|tool_calls_section_end|>

This should never be delivered to external messaging channels.

Fix Action

Fixed

PR fix notes

PR #60616: fix(outbound): strip model special tokens from user-visible text

Description (problem / solution / changelog)

Summary

Kimi and other models can leak raw tool-call markers into assistant text content:

  • <|tool_calls_section_begin|>, <|tool_call_begin|>, <|tool_call_argument_begin|>, etc.

These markers were already handled by stripModelSpecialTokens() in pi-embedded-utils.ts, but only for agent tool text formatting — not in the outbound channel delivery path.

Fix: Integrate stripModelSpecialTokens() into stripAssistantInternalScaffolding() (src/shared/text/assistant-visible-text.ts) so all channels (WhatsApp, WebChat, Telegram, iMessage, etc.) automatically strip leaked model special tokens before delivering messages to users.

Fixes #60465

Test plan

  • Verify Kimi tool-call markers (<|tool_calls_section_begin|>, etc.) are stripped from outbound WhatsApp messages
  • Verify normal text content is not affected
  • Verify code blocks containing pipe characters are preserved
  • Run existing assistant-visible-text.test.ts tests

🤖 Generated with Claude Code

Changed files

  • src/agents/pi-embedded-utils.strip-model-special-tokens.test.ts (modified, +3/-3)
  • src/agents/pi-embedded-utils.ts (modified, +4/-26)
  • src/shared/text/assistant-visible-text.test.ts (modified, +82/-0)
  • src/shared/text/assistant-visible-text.ts (modified, +7/-2)
  • src/shared/text/model-special-tokens.ts (added, +34/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

When using OpenClaw with WhatsApp and a Kimi-based model (k2p5 / provider normalized as kimi), malformed tool-call output can be delivered to the user as normal chat text instead of being parsed or suppressed.

The leaked message contains raw internal tool-call markers such as:

<|tool_calls_section_begin|> <|tool_call_begin|> <|tool_call_argument_begin|> <|tool_call_end|> <|tool_calls_section_end|>

Example of user-visible leaked output:

The tool syntax is showing up in chat. Let me check your Chrome profiles properly. <|tool_calls_section_begin|> <|tool_call_begin|> exec:12 <|tool_call_argument_begin|> {"command": "ls -la ~/Library/Application Support/Google/ | grep -i chrome", "timeout": 30} <|tool_call_end|> <|tool_calls_section_end|>

This should never be delivered to external messaging channels.

Steps to reproduce

  1. Run OpenClaw 2026.4.2
  2. Enable WhatsApp channel
  3. Use a Kimi-based model for a user-facing WhatsApp session (k2p5 / kimi)
  4. Trigger a tool-using turn where the model emits malformed or mixed tool-call output
  5. Observe that raw tool-call marker syntax is sent to the WhatsApp user as plain assistant text

Expected behavior

Malformed tool-call output should be:

• parsed into structured tool calls, or • rejected internally, or scrubbed/suppressed before outbound delivery

Under no circumstance should raw internal tool-call markup be sent to end users on WhatsApp.

Actual behavior

The malformed tool-call markup is stored in the assistant message as plain text and then delivered through WhatsApp as if it were a normal reply.

OpenClaw version

2026.4.2

Operating system

iOS 26.4

Install method

pnpm

Model

moonshot kimi/k2p5

Provider / routing chain

OpenClaw gateway → configured Kimi-compatible model route (k2p5, provider reported by runtime as kimi) → WhatsApp outbound channel

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

• The leaked payload is already present in the stored assistant message before outbound delivery, so this is not only a WhatsApp formatting issue. • The installed WhatsApp delivery code already suppresses isReasoning === true and reasoning: text, but this payload is not marked as reasoning. • The installed 2026.4.2 runtime includes Kimi-specific malformed tool-call repair logic, which suggests this provider/model family is already known to produce malformed tool-call output. • This appears related to the same class of bugs as: • reasoning leaking to WhatsApp • internal commands/errors leaking to WhatsApp • tool-call/session corruption issues

Additional information

No response

extent analysis

TL;DR

The most likely fix involves modifying the OpenClaw 2026.4.2 code to properly parse or suppress malformed tool-call output before delivering it to WhatsApp.

Guidance

  • Review the Kimi-specific malformed tool-call repair logic in the 2026.4.2 runtime to ensure it is correctly handling the k2p5 model output.
  • Verify that the WhatsApp delivery code is correctly suppressing or parsing tool-call markers, such as <|tool_calls_section_begin|>, in the assistant message.
  • Check the model configuration and provider settings to ensure that the kimi provider is correctly reported and handled by the OpenClaw gateway.
  • Investigate the possibility of updating the k2p5 model or the Kimi-compatible model route to produce well-formed tool-call output.

Example

No code snippet is provided due to the lack of specific code details in the issue.

Notes

The issue appears to be related to previous bugs involving reasoning and internal command leakage to WhatsApp, suggesting a potential pattern or common root cause. Further investigation into the OpenClaw code and Kimi model configuration may be necessary to fully resolve the issue.

Recommendation

Apply a workaround to modify the OpenClaw code to properly handle malformed tool-call output, as updating to a fixed version is not explicitly mentioned in the issue. This is due to the presence of Kimi-specific repair logic in the 2026.4.2 runtime, which suggests that a fix may be possible through code modifications.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Malformed tool-call output should be:

• parsed into structured tool calls, or • rejected internally, or scrubbed/suppressed before outbound delivery

Under no circumstance should raw internal tool-call markup be sent to end users on WhatsApp.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING