Skip to content

Commit a13b172

Browse files
committed
feat(telegram): delete tool trace message after agent response
The live tool progress message ('🔧 read_file(path) ✅') now gets deleted after the agent finishes, both on success and error. Uses the new DeleteMessage API to keep the chat clean instead of leaving stale trace messages permanently.
1 parent a51aeee commit a13b172

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cmd/odek/telegram.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,11 @@ func handleChatMessage(
895895
// Run the agent with the full message history (multi-turn).
896896
response, updatedMessages, err := agent.RunWithMessages(agentCtx, cs.Messages)
897897
if err != nil {
898+
// Clean up trace message on error too.
899+
if traceMsgID != 0 {
900+
bot.DeleteMessage(chatID, traceMsgID)
901+
traceMsgID = 0
902+
}
898903
reportError(bot, chatID, messageID, "Agent error: "+err.Error())
899904
return
900905
}
@@ -926,6 +931,14 @@ func handleChatMessage(
926931
if response != "" {
927932
handler.SendResponse(chatID, response, messageID)
928933

934+
// Clean up the tool trace message — it's stale after the response.
935+
if traceMsgID != 0 {
936+
if err := bot.DeleteMessage(chatID, traceMsgID); err != nil {
937+
log.Debug("delete trace message failed", "chat_id", chatID, "msg_id", traceMsgID, "error", err)
938+
}
939+
traceMsgID = 0
940+
}
941+
929942
// Send run stats as a separate message directly via Bot.SendMessage
930943
// (bypassing SendResponse/FormatResponse) so MarkdownV2 backtick code
931944
// formatting is handled natively by Telegram's parser.

0 commit comments

Comments
 (0)