notify: add pre_formatted flag for HTML pass-through - #1
Open
bermudas wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pre_formatted: boolparameter tosend_notification()inscripts/notify_lib.py(default False — preserves existing safe-escape behavior for every current caller, includingsupervisor.py's stuck-role warnings).notifyMCP tool inmcp/notify/server.pywith default True so agents calling the tool can emit Telegram HTML (<b>,<i>,<code>,<a href>) without their markup being escaped to literal<b>text in the chat.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 defaultTrueor flip it toFalseand have agents opt in per-call.Test plan
notify(message="<b>done</b>")from an agent renders bold in Telegramnotify(message="plain text & special chars", pre_formatted=False)renders literallysend_notification("text with <angle>")fromsupervisor.py(no flag) still escapes safely