From 732e4826a55644142f6015c651ca6b7ccb1e4a1c Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 29 Jan 2026 11:22:17 -0800 Subject: [PATCH] Re-add format hints to message envelope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shows agent what formatting syntax each channel supports: - Slack: *bold* _italic_ `code` - Telegram: *bold* _italic_ `code` [links](url) - WhatsApp: *bold* _italic_ `code` - Signal: ONLY *bold* _italic_ `code` This helps the agent use appropriate formatting for each channel. 🐙 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta --- src/core/formatter.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/formatter.ts b/src/core/formatter.ts index 3ea04d3..867eefb 100644 --- a/src/core/formatter.ts +++ b/src/core/formatter.ts @@ -7,7 +7,16 @@ import type { InboundMessage } from './types.js'; - +/** + * Channel format hints - tells the agent what formatting syntax to use + * Each channel has different markdown support - hints help agent format appropriately. + */ +const CHANNEL_FORMATS: Record = { + slack: 'mrkdwn: *bold* _italic_ `code` - NO: headers, tables', + telegram: 'MarkdownV2: *bold* _italic_ `code` [links](url) - NO: headers, tables', + whatsapp: '*bold* _italic_ `code` - NO: headers, code fences, links, tables', + signal: 'ONLY: *bold* _italic_ `code` - NO: headers, code fences, links, quotes, tables', +}; export interface EnvelopeOptions { timezone?: 'local' | 'utc' | string; // IANA timezone or 'local'/'utc' @@ -170,6 +179,9 @@ export function formatMessageEnvelope( // Build envelope const envelope = `[${parts.join(' ')}]`; - // Add format hint as a separate note (not cluttering the main envelope) - return `${envelope} ${msg.text}`; + // Add format hint so agent knows what formatting syntax to use + const formatHint = CHANNEL_FORMATS[msg.channel]; + const hint = formatHint ? `\n(Format: ${formatHint})` : ''; + + return `${envelope} ${msg.text}${hint}`; }