fix: filter out all dummy messages when summarize (#1989)

This commit is contained in:
yetone
2025-05-05 17:34:53 +08:00
committed by GitHub
parent a67f3071e4
commit e21f1f07bd
3 changed files with 14 additions and 1 deletions

View File

@@ -166,6 +166,8 @@ function M.generate_prompts(opts)
HistoryMessage:new({
role = "assistant",
content = string.format("Viewing file %s to get the latest content", path),
}, {
is_dummy = true,
}),
HistoryMessage:new({
role = "assistant",
@@ -179,6 +181,8 @@ function M.generate_prompts(opts)
},
},
},
}, {
is_dummy = true,
}),
HistoryMessage:new({
role = "user",
@@ -190,6 +194,8 @@ function M.generate_prompts(opts)
is_error = false,
},
},
}, {
is_dummy = true,
}),
})
end
@@ -365,6 +371,11 @@ function M.generate_prompts(opts)
dropped_history_messages =
vim.list_slice(cleaned_history_messages, 1, #cleaned_history_messages - #retained_history_messages)
dropped_history_messages = vim
.iter(dropped_history_messages)
:filter(function(msg) return msg.is_dummy ~= true end)
:totable()
-- prepend the history messages to the messages table
vim.iter(retained_history_messages):each(function(msg) table.insert(final_history_messages, msg) end)
end