fix: kb message truncate bug fix

This commit is contained in:
qixinbo
2026-03-29 20:35:38 +08:00
parent 99b654bbd2
commit 5869c377a3
8 changed files with 123 additions and 17 deletions
+11 -4
View File
@@ -574,10 +574,17 @@ export function ChatInterface() {
let cleanContent = m.content || "";
// Remove injected system prompt instructions from user messages if present
if (m.role === 'user') {
cleanContent = cleanContent.replace(/^\[System:.*?\]\n?/i, '');
// Handle cases where there might be a runtime context block for skills
cleanContent = cleanContent.replace(/\[Runtime Context[\s\S]*?(?=\[System:|$)/i, '');
cleanContent = cleanContent.replace(/\[System:.*?\]\n?/i, ''); // clean again in case it follows context
if (cleanContent.startsWith("[Runtime Context")) {
const splitIndex = cleanContent.indexOf("\n\n");
if (splitIndex !== -1) {
cleanContent = cleanContent.substring(splitIndex + 2);
} else {
cleanContent = "";
}
} else if (cleanContent.startsWith("[System:")) {
// Fallback for older messages containing [System: ...] wrapper
cleanContent = cleanContent.replace(/^\[System:[\s\S]*?\]\n*/i, '');
}
cleanContent = cleanContent.trim();
}
return {