hermes - 💡(How to fix) Fix [Bug]: WhatsApp platform hint instructs model not to use markdown, but adapter auto-converts it [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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
NousResearch/hermes-agent#17641Fetched 2026-04-30 06:46:16
View on GitHub
Comments
3
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×4commented ×3closed ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

The model obeys the platform hint ("do not use markdown") and emits plain text. The converter has nothing to convert. Replies arrive in WhatsApp without any visual emphasis. Overriding the hint via SOUL.md does not reliably win, because PLATFORM_HINTS is appended LAST in the system prompt (run_agent.py:4901) — recency favors the upstream hint over earlier overrides.

Code Example

Report       https://paste.rs/c9Sr4
agent.log    https://paste.rs/wJSx9
gateway.log  https://paste.rs/7XFqi

---



---

"whatsapp": (
    "You are on a text messaging communication platform, WhatsApp. "
    "Please do not use markdown as it does not render. "
    ...
),

---

def format_message(self, content: str) -> str:
    """Convert standard markdown to WhatsApp-compatible formatting."""
    ...
    result = re.sub(r"\*\*(.+?)\*\*", r"*\1*", result)
    result = re.sub(r"~~(.+?)~~", r"~\1~", result)
    result = re.sub(r"^#{1,6}\s+(.+)$", r"*\1*", result, flags=re.MULTILINE)
    result = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"\1 (\2)", result)

---

platform_key = (self.platform or "").lower().strip()
if platform_key in PLATFORM_HINTS:
    prompt_parts.append(PLATFORM_HINTS[platform_key])

---

"whatsapp": (
    "You are on a text messaging communication platform, WhatsApp. "
    "Standard markdown is automatically converted to WhatsApp format. "
    "Supported: **bold**, ~~strikethrough~~, `inline code`, "
    "
RAW_BUFFERClick to expand / collapse

Bug Description

The WhatsApp PLATFORM_HINT in agent/prompt_builder.py tells the model: "Please do not use markdown as it does not render."

However, gateway/platforms/whatsapp.py ships a format_message() method that converts standard markdown to WhatsApp's native syntax on every send:

  • **bold***bold*
  • ~~strike~~~strike~
  • # Header*Header*
  • [text](url)text (url)

The platform hint and the adapter contradict each other: the model is told to avoid markdown, while the adapter is built to convert it. As a result, WhatsApp replies arrive flat — no bold on key figures, headers, or alerts — even when the agent prompt (SOUL.md) explicitly asks for bold.

This was deliberately fixed for Telegram in #10612 (closes #8261). The same fix has not been applied to WhatsApp, even though the converter and its tests already exist (tests/gateway/test_whatsapp_formatting.py).

Steps to Reproduce

  1. Configure Hermes with the WhatsApp gateway.
  2. Set up an agent prompt (SOUL.md or system prompt) that requests bold on key figures, e.g. "use bold on key numbers and alerts".
  3. Ask any question whose ideal reply contains numbers or section headers.
  4. Observe the message rendered in WhatsApp.

Expected Behavior

The model emits standard markdown (bold, strike, # Header). format_message() converts it to WhatsApp syntax before sending. The user sees properly bolded figures and headers in WhatsApp, matching the behavior already shipped for Telegram.

Actual Behavior

The model obeys the platform hint ("do not use markdown") and emits plain text. The converter has nothing to convert. Replies arrive in WhatsApp without any visual emphasis. Overriding the hint via SOUL.md does not reliably win, because PLATFORM_HINTS is appended LAST in the system prompt (run_agent.py:4901) — recency favors the upstream hint over earlier overrides.

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

WhatsApp

Debug Report

Report       https://paste.rs/c9Sr4
agent.log    https://paste.rs/wJSx9
gateway.log  https://paste.rs/7XFqi

Operating System

Ubuntu 24.04.4 LTS

Python Version

Python 3.12.3

Hermes Version

v0.11.0 (2026.4.23)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

Three pieces of upstream code make this a structural contradiction:

  1. agent/prompt_builder.py:298-307 — the hint:
"whatsapp": (
    "You are on a text messaging communication platform, WhatsApp. "
    "Please do not use markdown as it does not render. "
    ...
),
  1. gateway/platforms/whatsapp.py:607-662 — the converter (excerpt):
def format_message(self, content: str) -> str:
    """Convert standard markdown to WhatsApp-compatible formatting."""
    ...
    result = re.sub(r"\*\*(.+?)\*\*", r"*\1*", result)
    result = re.sub(r"~~(.+?)~~", r"~\1~", result)
    result = re.sub(r"^#{1,6}\s+(.+)$", r"*\1*", result, flags=re.MULTILINE)
    result = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"\1 (\2)", result)
  1. run_agent.py:4899-4901 — the hint is appended last:
platform_key = (self.platform or "").lower().strip()
if platform_key in PLATFORM_HINTS:
    prompt_parts.append(PLATFORM_HINTS[platform_key])

The Telegram hint at agent/prompt_builder.py:308-322 was updated in #10612 to correctly inform the model about its converter; WhatsApp was not. The converter logic, the tests (tests/gateway/test_whatsapp_ formatting.py), and the Telegram precedent all confirm the WhatsApp hint is simply stale.

Proposed Fix (optional)

Update PLATFORM_HINTS["whatsapp"] in agent/prompt_builder.py to mirror the Telegram pattern — tell the model markdown is auto-converted instead of telling it not to use markdown:

"whatsapp": (
    "You are on a text messaging communication platform, WhatsApp. "
    "Standard markdown is automatically converted to WhatsApp format. "
    "Supported: **bold**, ~~strikethrough~~, `inline code`, "
    "```code blocks```, [links](url), and # headers (rendered as bold). "
    "WhatsApp does not support italic via markdown — `_text_` and `*text*` "
    "are passed through as WhatsApp italic/bold respectively. "
    "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, "
    ".webp) appear as photos, videos (.mp4, .mov) play inline, and other "
    "files arrive as downloadable documents. You can also include image "
    "URLs in markdown format ![alt](url) and they will be sent as photos."
),

The converter and its full test coverage already exist; this is purely a prompt-text update.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Update the PLATFORM_HINTS["whatsapp"] in agent/prompt_builder.py to inform the model that standard markdown is automatically converted to WhatsApp format.

Guidance

  • Review the current PLATFORM_HINTS["whatsapp"] in agent/prompt_builder.py and compare it with the proposed fix to understand the changes needed.
  • Verify that the format_message() method in gateway/platforms/whatsapp.py correctly converts standard markdown to WhatsApp-compatible formatting.
  • Test the updated hint with various markdown formats (e.g., bold, strike, # Header) to ensure they are correctly converted and rendered in WhatsApp.
  • Check the existing tests in tests/gateway/test_whatsapp_formatting.py to ensure they cover the updated hint and converter logic.

Example

The proposed fix updates the PLATFORM_HINTS["whatsapp"] to:

"whatsapp": (
    "You are on a text messaging communication platform, WhatsApp. "
    "Standard markdown is automatically converted to WhatsApp format. "
    "Supported: **bold**, ~~strikethrough~~, `inline code`, "
    "```code blocks```, [links](url), and # headers (rendered as bold). "
    ...
),

This update informs the model to use standard markdown, which will be converted to WhatsApp format by the format_message() method.

Notes

The fix relies on the existing converter logic and tests, which are confirmed to work correctly. The update only changes the prompt text to reflect the correct behavior.

Recommendation

Apply the proposed fix by updating the PLATFORM_HINTS["whatsapp"] in agent/prompt_builder.py to inform the model about the automatic markdown conversion. This fix is straightforward and has a clear precedent in the Telegram implementation.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug]: WhatsApp platform hint instructs model not to use markdown, but adapter auto-converts it [3 comments, 2 participants]