openclaw - 💡(How to fix) Fix WhatsApp per-peer sessions missing buildDirectChatContext delivery context injection [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#72002Fetched 2026-04-27 05:36:13
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
closed ×1commented ×1cross-referenced ×1

WhatsApp (and likely Signal/Telegram) per-peer direct sessions are systematically missing the buildDirectChatContext delivery context injection that Slack sessions receive. This causes the model to leak internal process narration into messages sent directly to contacts.

Root Cause

WhatsApp (and likely Signal/Telegram) per-peer direct sessions are systematically missing the buildDirectChatContext delivery context injection that Slack sessions receive. This causes the model to leak internal process narration into messages sent directly to contacts.

Code Example

{
  "schema": "openclaw.inbound_meta.v2",
  "account_id": "default",
  "channel": "whatsapp",
  "provider": "whatsapp",
  "surface": "whatsapp",
  "chat_type": "direct"
}
RAW_BUFFERClick to expand / collapse

Summary

WhatsApp (and likely Signal/Telegram) per-peer direct sessions are systematically missing the buildDirectChatContext delivery context injection that Slack sessions receive. This causes the model to leak internal process narration into messages sent directly to contacts.

Expected behavior

WhatsApp per-peer sessions with chatType: "direct" should receive:

"You are in a WhatsApp direct conversation. Your replies are automatically sent to this conversation."

...just as Slack sessions receive:

"You are in a Slack direct conversation. Your replies are automatically sent to this conversation."

Actual behavior

WhatsApp per-peer sessions receive only the raw inbound_meta.v2 JSON block:

{
  "schema": "openclaw.inbound_meta.v2",
  "account_id": "default",
  "channel": "whatsapp",
  "provider": "whatsapp",
  "surface": "whatsapp",
  "chat_type": "direct"
}

No buildDirectChatContext output follows. The model has no signal that its text output is delivered directly to the external contact.

Evidence

Verified across 30+ session trajectory files:

  • ALL Slack sessions → have direct conversation context in compiled system prompt
  • ALL WhatsApp sessions → missing direct conversation context

The session origin config correctly has chatType: "direct". The buildDirectChatContext() function in get-reply-CSQ5BMwG.js exists and is gated on sessionCtx.ChatType === "direct" || sessionCtx.ChatType === "dm". The function result is included in extraSystemPromptParts. But the output never appears in the compiled system prompt for WhatsApp channels.

Impact

Without the delivery context, the model (tested: Claude Opus 4-6, Claude Sonnet 4-6) emits chain-of-thought narration as regular text content alongside tool calls. Since only the final stopReason=stop message is delivered to WhatsApp, internal process notes in that final message ("Good, Reda's been notified. Now I'll acknowledge Mia's message warmly...") are sent directly to the contact.

This has occurred multiple times (April 16-18 in 3-way DMs, April 25 in per-peer DM) and is a systematic issue, not a one-off model failure.

Environment

  • OpenClaw 2026.4.22 (when incident occurred) / 2026.4.24 (current, bug persists)
  • macOS, gateway mode
  • WhatsApp channel with per-channel-peer DM scope

extent analysis

TL;DR

The buildDirectChatContext function is not being applied to WhatsApp direct sessions, causing the model to leak internal process narration into messages.

Guidance

  • Verify that the buildDirectChatContext function is correctly gated on sessionCtx.ChatType === "direct" and that the chatType is being set to "direct" for WhatsApp sessions.
  • Check the get-reply-CSQ5BMwG.js file to ensure that the buildDirectChatContext function is being called and its result is being included in extraSystemPromptParts.
  • Investigate why the buildDirectChatContext output is not appearing in the compiled system prompt for WhatsApp channels, despite being correctly configured.
  • Review the session trajectory files to confirm that the issue is systematic and not specific to certain sessions or conditions.

Example

No code snippet is provided as the issue is more related to the configuration and functionality of the buildDirectChatContext function.

Notes

The issue seems to be specific to WhatsApp direct sessions and does not affect Slack sessions. The buildDirectChatContext function is correctly implemented, but its output is not being applied to WhatsApp sessions.

Recommendation

Apply a workaround to manually inject the buildDirectChatContext delivery context into WhatsApp direct sessions, until the root cause of the issue is identified and fixed. This will prevent the model from leaking internal process narration into messages sent directly to contacts.

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

WhatsApp per-peer sessions with chatType: "direct" should receive:

"You are in a WhatsApp direct conversation. Your replies are automatically sent to this conversation."

...just as Slack sessions receive:

"You are in a Slack direct conversation. Your replies are automatically sent to this conversation."

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix WhatsApp per-peer sessions missing buildDirectChatContext delivery context injection [1 comments, 2 participants]