Skip to content

notify: add pre_formatted flag for HTML pass-through - #1

Open
bermudas wants to merge 1 commit into
mainfrom
feat/notify-pre-formatted
Open

notify: add pre_formatted flag for HTML pass-through#1
bermudas wants to merge 1 commit into
mainfrom
feat/notify-pre-formatted

Conversation

@bermudas

Copy link
Copy Markdown
Owner

Summary

  • Adds optional pre_formatted: bool parameter to send_notification() in scripts/notify_lib.py (default False — preserves existing safe-escape behavior for every current caller, including supervisor.py's stuck-role warnings).
  • Exposes the same flag on the notify MCP tool in mcp/notify/server.py with default True so agents calling the tool can emit Telegram HTML (<b>, <i>, <code>, <a href>) without their markup being escaped to literal &lt;b&gt; text in the chat.
  • The role badge prefix is always HTML-escaped regardless of the flag — only the message body is affected.

Ported from ChildrenHomeWork/octobots. Asymmetric defaults are intentional: only MCP callers (agents) opt into HTML pass-through; other Python callers keep the safe default.

Trade-off worth flagging

With MCP default True, an agent that emits e.g. notify("found <UserService> bug") will fail the Telegram API call because <UserService> looks like an unclosed tag. The pre-existing fallback path doesn't catch HTML parse errors, so the call returns an error dict — visible to the agent but not silently swallowed. Discuss whether to keep MCP default True or flip it to False and have agents opt in per-call.

Test plan

  • notify(message="<b>done</b>") from an agent renders bold in Telegram
  • notify(message="plain text & special chars", pre_formatted=False) renders literally
  • send_notification("text with <angle>") from supervisor.py (no flag) still escapes safely

Adds an opt-in `pre_formatted` parameter to send_notification() in
notify_lib.py (default False — existing callers keep safe-escape
behavior) and exposes it on the MCP notify tool with default True so
agents can emit Telegram HTML (<b>, <i>, <code>, <a>) without their
markup being escaped to literal text.

The role badge is always HTML-escaped regardless of the flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant