Summary
The Telegram adapter silently drops messages when Telegram rejects the Markdown formatting. The bot shows reactions (thinking → done) but no text reply is delivered.
Root Cause
In gateway/src/adapters/telegram.rs (line ~335):
let _ = client
.post(&url)
.json(&serde_json::json!({
"chat_id": reply.channel.id,
"text": reply.content.text,
"message_thread_id": reply.channel.thread_id,
"parse_mode": "Markdown",
}))
.send()
.await
.map_err(|e| error!("telegram send error: {e}"));
Two issues:
-
let _ = discards the response — Telegram API errors (HTTP 200 with "ok": false) are never checked. Only network-level errors are caught by map_err.
-
"parse_mode": "Markdown" is strict — If the agent response contains unescaped _, *, [, ], ` (very common in Chinese text, URLs, or code), Telegram returns "Bad Request: can't parse entities" and the message is never delivered.
Reproduction
- Send an image to the bot via Telegram with a caption like "幫我找這條牛仔褲的連結"
- Agent responds with text containing URLs and markdown-like characters
- Bot shows reactions (✅) but no text message appears in chat
Suggested Fix
Fallback pattern — try with Markdown, retry as plain text on failure:
let resp = client.post(&url)
.json(&serde_json::json!({
"chat_id": reply.channel.id,
"text": &reply.content.text,
"message_thread_id": reply.channel.thread_id,
"parse_mode": "Markdown",
}))
.send().await;
match resp {
Ok(r) => {
let body: serde_json::Value = r.json().await.unwrap_or_default();
if body["ok"].as_bool() != Some(true) {
warn!("Markdown send failed: {}, retrying as plain text", body["description"]);
let _ = client.post(&url)
.json(&serde_json::json!({
"chat_id": reply.channel.id,
"text": &reply.content.text,
"message_thread_id": reply.channel.thread_id,
}))
.send().await;
}
}
Err(e) => error!("telegram send error: {e}"),
}
Impact
Any agent response with special characters silently disappears. User sees reactions but no reply — appears broken.
Summary
The Telegram adapter silently drops messages when Telegram rejects the Markdown formatting. The bot shows reactions (thinking → done) but no text reply is delivered.
Root Cause
In
gateway/src/adapters/telegram.rs(line ~335):Two issues:
let _ =discards the response — Telegram API errors (HTTP 200 with"ok": false) are never checked. Only network-level errors are caught bymap_err."parse_mode": "Markdown"is strict — If the agent response contains unescaped_,*,[,],`(very common in Chinese text, URLs, or code), Telegram returns"Bad Request: can't parse entities"and the message is never delivered.Reproduction
Suggested Fix
Fallback pattern — try with Markdown, retry as plain text on failure:
Impact
Any agent response with special characters silently disappears. User sees reactions but no reply — appears broken.