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 "