mirror of
https://github.com/bal-spec/sillytavern-character-memory.git
synced 2026-04-28 03:39:44 +00:00
fix: prevent consolidation/reformat truncation on large memory sets
- Consolidation: increase max_tokens from responseLength*2 to Math.max(responseLength*4, 4000) — ensures at least 4k output tokens regardless of the user's Response Length setting - Reformat/Convert: increase from responseLength to Math.max(responseLength*2, 4000) — same floor - Add truncation detection in consolidation: warns in activity log and toastr if response contains <memory> tags but doesn't end with </memory>, pointing user to Response Length setting Fixes #13 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2fc514c0b2
commit
700a1b4dc5
1 changed files with 8 additions and 2 deletions
10
index.js
10
index.js
|
|
@ -672,7 +672,7 @@ async function convertWithLLM(content, charName) {
|
|||
|
||||
let response;
|
||||
try {
|
||||
response = await callLLM(prompt, extension_settings[MODULE_NAME].responseLength || 2000, 'You are a text restructuring assistant. Preserve all information faithfully.');
|
||||
response = await callLLM(prompt, Math.max(extension_settings[MODULE_NAME].responseLength * 2 || 4000, 4000), 'You are a text restructuring assistant. Preserve all information faithfully.');
|
||||
} catch (err) {
|
||||
console.error(LOG_PREFIX, 'LLM conversion failed:', err);
|
||||
return { blocks: [], warnings: [`LLM call failed: ${err.message || 'Unknown error'}`] };
|
||||
|
|
@ -7013,7 +7013,7 @@ async function runConsolidationLLM(memories, charName) {
|
|||
const llmStartTime = Date.now();
|
||||
const result = await callLLM(
|
||||
prompt,
|
||||
extension_settings[MODULE_NAME].responseLength * 2,
|
||||
Math.max(extension_settings[MODULE_NAME].responseLength * 4, 4000),
|
||||
'You are a memory consolidation assistant.',
|
||||
);
|
||||
|
||||
|
|
@ -7032,6 +7032,12 @@ async function runConsolidationLLM(memories, charName) {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Detect truncated response — a complete response ends with </memory>
|
||||
if (cleanResult.includes('<memory') && !/<\/memory>\s*$/.test(cleanResult)) {
|
||||
logActivity('Consolidation response appears truncated — last block(s) may be missing. Try increasing Response Length in Settings → Extraction.', 'warning');
|
||||
toastr.warning(t`Consolidation response may be truncated. Try increasing Response Length in Settings → Extraction.`, 'CharMemory', { timeOut: 8000 });
|
||||
}
|
||||
|
||||
// Parse into memory format, then serialize back to plain text for the editor
|
||||
const timestamp = getTimestamp();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue