fix(telegram): strip raw markdown in MarkdownV2 fallback paths - #33304
fix(telegram): strip raw markdown in MarkdownV2 fallback paths#33304Vitalymt wants to merge 1 commit into
Conversation
|
Thanks for tracing the fallback paths. Current main already contains the parse-error fallback and raw- Problems
Suggested changes
This is an automated hermes-sweeper review. |
GottZ
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Summary
Two PRs address the same Telegram MarkdownV2 fallback defect with effectively identical diffs: both strip raw **bold**, send plain text after parse failure, and preserve the formatted payload during flood-control retry. Current main already contains the stripping and parse-error fallback portions, leaving the RetryAfter path as the remaining gap.
Related pull requests
- #33304
related— (+17/-4) — consolidate here, but revise before merge: despite the keep_open review on #33304, the diff is only partially applicable because main already contains the raw-**bold**stripping and parse-error fallback; retain the still-relevant formatted RetryAfter retry and add the requested regression test for its arguments. - #34570 [closed]
duplicate— (+17/-4) — duplicate of #33304: its diff is effectively identical and does not add the missing RetryAfter regression test. Although closed, it remains relevant as corroboration of the same failure mode and is superseded by the earlier PR and its contributor review context.
Duplicates
#34570 duplicates #33304; both apply the same production and test changes.
Suggested consolidation
Merge #33304 only after rebasing it onto the current plugins/platforms/telegram/adapter.py implementation, narrowing it to the remaining RetryAfter fix, and adding the contributor-requested RetryAfter regression test; keep #34570 closed as a duplicate of #33304.
Complex graph
flowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
subgraph Dup33304 ["PRs duplicating each other"]
P33304["PR #33304 (open)"]
P34570["PR #34570 (closed)"]
end
class P33304 open
class P34570 closed
class P33304 target
click P33304 "https://github.com/NousResearch/hermes-agent/pull/33304"
click P34570 "https://github.com/NousResearch/hermes-agent/pull/34570"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).
Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 7 kB of PR diffs, 2 kB of issue/PR text, 1 kB of discussion (2 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
51b3c64 to
408061f
Compare
When edit_message's MarkdownV2 fallback itself hits RetryAfter flood control, the retry previously sent raw text=content (with literal **bold** markers) instead of the already-stripped plain text from _strip_mdv2(). Track _last_sent_content through the formatted → fallback flow so the RetryAfter retry always re-sends the correct content variant. Regression test: 3-call sequence (formatted → RetryAfter → plain fallback → RetryAfter → retry succeeds) verifying the retry uses stripped plain text. Addresses review feedback on PR NousResearch#33304.
408061f to
318732b
Compare
Problem
When Telegram rejects MarkdownV2 formatting in
edit_message(), the fallback sends raw content with literal**bold**markers and noparse_mode. Thesend()method already handles this correctly by calling_strip_mdv2().Root Cause
Two code paths in
edit_message()sendtext=contentwithout stripping markdown on fallback:contentwith noparse_modecontentand noparse_modeAdditionally,
_strip_mdv2()didn't handle raw**bold**patterns — only the MarkdownV2-converted*bold*.Fix
Three changes in
gateway/platforms/telegram.py:_strip_mdv2(): Add regex to strip raw**bold**before the already-handled*bold*edit_message()MarkdownV2 fallback: Use_strip_mdv2(content)+parse_mode=None(matchingsend()behaviour)edit_message()flood-wait retry: Use already-formatted MarkdownV2 text, or fall back to_strip_mdv2()Plus test update in
tests/gateway/test_telegram_format.py.Testing
All 101 tests in
test_telegram_format.pypass.