Skip to content

Commit 9eaddac

Browse files
committed
feat: tool results as new messages instead of edits
On tool_result, send a NEW message (🔧 tool_name ✅ (size)) instead of editing the previous tool_call message. The initial tool_call message is deleted after the result arrives. This preserves the full agent timeline in chat history — the user can scroll up through each step: 💭 reasoning → 🔧 call → ✅ result.
1 parent 0013fa0 commit 9eaddac

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

cmd/odek/telegram.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,15 +1156,19 @@ func handleChatMessage(
11561156
}
11571157

11581158
case "tool_result":
1159+
// Send a new message for the result so the full timeline
1160+
// is preserved in chat history.
1161+
sizeLabel := fmt.Sprintf("%dB", len(data))
1162+
if len(data) > 1024 {
1163+
sizeLabel = fmt.Sprintf("%dKB", len(data)/1024)
1164+
}
1165+
bot.SendMessage(chatID,
1166+
fmt.Sprintf("%s `%s` ✅ (%s)", render.ToolEmoji(name), name, sizeLabel), nil)
1167+
// Clean up the initial tool_call message — it's stale now.
11591168
if msgIDVal, ok := toolMsgIDs.Load(name); ok {
1160-
msgID := msgIDVal.(int)
1161-
sizeLabel := fmt.Sprintf("%dB", len(data))
1162-
if len(data) > 1024 {
1163-
sizeLabel = fmt.Sprintf("%dKB", len(data)/1024)
1164-
}
1165-
bot.EditMessageText(chatID, msgID,
1166-
fmt.Sprintf("%s `%s` ✅ (%s)", render.ToolEmoji(name), name, sizeLabel), nil)
1169+
bot.DeleteMessage(chatID, msgIDVal.(int))
11671170
}
1171+
toolMsgIDs.Delete(name)
11681172
}
11691173
},
11701174
IterationCallback: func(info loop.IterationInfo) {

0 commit comments

Comments
 (0)