Merge pull request #598: preserve repeated user messages in chat history

Remove only the current trailing message instead of filtering every earlier message with equal content.
This commit is contained in:
BaiFu 2026-07-22 19:40:49 +08:00 committed by GitHub
commit ad12d412ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -684,7 +684,7 @@ const sendToReportAgent = async (message) => {
// Build chat history for API
const historyForApi = chatHistory.value
.filter(msg => msg.role !== 'user' || msg.content !== message)
.slice(0, -1)
.slice(-10) // Keep last 10 messages
.map(msg => ({
role: msg.role,
@ -720,7 +720,7 @@ const sendToAgent = async (message) => {
let prompt = message
if (chatHistory.value.length > 1) {
const historyContext = chatHistory.value
.filter(msg => msg.content !== message)
.slice(0, -1)
.slice(-6)
.map(msg => `${msg.role === 'user' ? '提问者' : '你'}${msg.content}`)
.join('\n')