From ec769e49d23737a936d7950d1590b3a024b70bdf Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 27 Jun 2026 03:46:41 -0700 Subject: [PATCH] fix(gateway): WhatsApp/Signal hints affirm markdown instead of forbidding it (#53564) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'whatsapp' and 'signal' PLATFORM_HINTS told the agent 'Please do not use markdown as it does not render' — factually wrong. Both adapters actively convert markdown to native formatting: - whatsapp_common.format_message(): **bold**, ~~strike~~, # headers, links, code blocks -> WhatsApp native syntax - signal_format.markdown_to_signal(): same conversions via bodyRanges, plus '- item' / '* item' bullets -> '• ' Unicode bullets The wrong hint made the agent strip bullets and bold the adapter would have rendered (#12224). Rewrote both hints to mirror whatsapp_cloud: markdown is auto-converted, bullet lists work, tables are not supported. Added a contract test asserting markdown-converting platforms never forbid markdown in their hint. --- agent/prompt_builder.py | 13 +++++++++++-- tests/agent/test_prompt_builder.py | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index 1a87e66cde4..e136a9476a6 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -617,7 +617,12 @@ DEVELOPER_ROLE_MODELS = ("gpt-5", "codex") PLATFORM_HINTS = { "whatsapp": ( "You are on a text messaging communication platform, WhatsApp. " - "Please do not use markdown as it does not render. " + "Standard markdown (**bold**, *italic*, ~~strike~~, # headers, " + "`code`, ```code blocks```, [links](url)) is auto-converted to " + "WhatsApp's native syntax (*bold*, _italic_, ~strike~, monospace) — " + "feel free to write in markdown, and use bullet lists ('- item') " + "freely. Tables are NOT supported — prefer bullet lists or labeled " + "key:value pairs. " "You can send media files natively: to deliver a file to the user, " "include MEDIA:/absolute/path/to/file in your response. The file " "will be sent as a native WhatsApp attachment — images (.jpg, .png, " @@ -682,7 +687,11 @@ PLATFORM_HINTS = { ), "signal": ( "You are on a text messaging communication platform, Signal. " - "Please do not use markdown as it does not render. " + "Standard markdown (**bold**, *italic*, ~~strike~~, # headers, " + "`code`, ```code blocks```) is auto-converted to Signal's native " + "rich formatting — feel free to write in markdown, and use bullet " + "lists ('- item') freely (they render as • bullets). Tables are NOT " + "supported — prefer bullet lists or labeled key:value pairs. " "You can send media files natively: to deliver a file to the user, " "include MEDIA:/absolute/path/to/file in your response. Images " "(.png, .jpg, .webp) appear as photos, audio as attachments, and other " diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py index f1d87c7fc14..a77c24f34a7 100644 --- a/tests/agent/test_prompt_builder.py +++ b/tests/agent/test_prompt_builder.py @@ -1018,6 +1018,19 @@ class TestPromptBuilderConstants: hint = PLATFORM_HINTS["whatsapp_cloud"] assert "MEDIA:" in hint + def test_markdown_converting_platform_hints_do_not_forbid_markdown(self): + """#12224 — WhatsApp (Baileys) and Signal adapters actively convert + markdown to native formatting (gateway/platforms/whatsapp_common.py + format_message + signal_format.markdown_to_signal: bold, italic, + strikethrough, headers, bullets). Their hints previously told the + agent "do not use markdown", which made it strip bullets/bold the + adapter would have rendered. The hint must affirm markdown, not + forbid it.""" + for key in ("whatsapp", "signal"): + hint = PLATFORM_HINTS[key] + assert "do not use markdown" not in hint.lower() + assert "markdown" in hint.lower() + def test_cli_hint_does_not_suggest_media_tags(self): # Regression: MEDIA:/path tags are intercepted only by messaging # gateway platforms. On the CLI they render as literal text and