Fix: last msg duplication

This commit is contained in:
Grail Finder
2025-12-23 22:41:21 +03:00
parent bc49f37dce
commit 3c6f9b624e

5
bot.go
View File

@@ -91,11 +91,8 @@ func cleanToolCalls(messages []models.RoleMsg) []models.RoleMsg {
cleaned := make([]models.RoleMsg, 0, len(messages)) cleaned := make([]models.RoleMsg, 0, len(messages))
for i, msg := range messages { for i, msg := range messages {
// recognize the message as the tool call and remove it // recognize the message as the tool call and remove it
if msg.ToolCallID == "" {
cleaned = append(cleaned, msg)
}
// tool call in last msg should stay // tool call in last msg should stay
if i == len(messages)-1 { if msg.ToolCallID == "" || i == len(messages)-1 {
cleaned = append(cleaned, msg) cleaned = append(cleaned, msg)
} }
} }