From 03123d1ff780f4e39be9d11282471acabae2c60d Mon Sep 17 00:00:00 2001 From: Manohar Date: Wed, 10 Jun 2026 14:59:41 +0000 Subject: [PATCH] fix(bridge): mirror shows only what Telegram actually saw - skip assistant messages carrying toolCall blocks (working narration like 'Let me check if codexbar is available' was never sent to Telegram) - ignore thinking blocks - strip injected '(untrusted metadata)' json fences from user messages - drop synthetic system messages (session startup, heartbeats) --- bridge/src/routes/chat-telegram.ts | 52 +++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/bridge/src/routes/chat-telegram.ts b/bridge/src/routes/chat-telegram.ts index c51f424..1c2370b 100644 --- a/bridge/src/routes/chat-telegram.ts +++ b/bridge/src/routes/chat-telegram.ts @@ -51,6 +51,38 @@ interface SessionIndexEntry { updatedAt?: number; } +/** + * OpenClaw injects machinery into user messages before they reach the model: + * - leading blocks like: + * Conversation info (untrusted metadata): ```json {...}``` + * Sender (untrusted metadata): ```json {...}``` + * - whole synthetic messages ("A new session was started via /new...", + * heartbeat prompts, system reminders) + * None of that was typed by the human in Telegram, so the mirror strips it. + * Returning "" makes the caller drop the message entirely. + */ +function cleanUserText(raw: string): string { + let text = raw; + + // Strip any leading "