MCPcopy Index your code
hub / github.com/aikohanasaki/SillyTavern-MemoryBooks

github.com/aikohanasaki/SillyTavern-MemoryBooks @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,653 symbols 5,527 edges 34 files 126 documented · 8% updated 10d ago★ 2502 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

📕 Memory Books (A SillyTavern Extension)

A next-generation SillyTavern extension for automatic, structured, and reliable memory creation. Mark scenes in chat, generate JSON-based summaries with AI, and store them as entries in your lorebooks. Supports group chats, advanced profile management, side prompts/trackers, and multi-tier memory consolidation.

❓ Vocabulary

  • Scene → Memory
  • One saved fact → Clip
  • Ongoing tracker → Side Prompt
  • Many Memories → Summary / Consolidation
  • One long entry → Compaction

Clips vs Side Prompts

Clips vs Side Prompts

Clips Side Prompts
Save selected chat text into a Memory Book entry. Ask the AI to review chat and update a tracker entry.
Best for one clear fact, line, promise, preference, item, or note. Best for information that changes over time.
Think: “pin this note.” Think: “keep this section updated.”

For the longer explanation, see the User Guide.

Compaction vs Consolidation

Compaction vs Consolidation

Compaction Consolidation
Shortens one existing STMB-managed entry. Combines multiple memories or summaries into one higher-level recap.
Use when a Clip, Side Prompt, or Memory entry is useful, but getting too long. Use when several memories are ready to become an Arc, Chapter, Book, or other larger summary.
Think: “trim this one entry.” Think: “roll these memories up into a recap.”

For the longer explanation, see the User Guide.

❗ Read Me First!

Start here: * ⚠️‼️Please read prerequisites for installation notes (especially if you run Text Completion API) * 📽️ Quickstart Video - English only (sorry, that's the language I am most fluent in) * ❓ Frequently Asked Questions * 🛠️ Troubleshooting

Other links: * 📘 User Guide (EN) * 📋 Version History & Changelog * 💡 Using 📕 Memory Books with 📚 Lorebook Ordering

Note: Supports various languages: see /locales folder for list. International/localized Readme and User Guides can be found in the /userguides folder. Lorebook converter and side prompt template library are in the /resources folder.

📑 Table of Contents


📋 Prerequisites

  • SillyTavern: 1.14.0+ (latest recommended)
  • Optional Job Queue: STMB works without the job queue. To use queueing, install and enable Chat Top Bar / Chat Top Info Bar, the official SillyTavern extension that adds a top bar to the chat window. STMB uses that top bar to show the Memory Books Jobs button and queue drawer.
  • Chat Completion Support: Full support for OpenAI, Claude, Anthropic, OpenRouter, or other chat completion API.
  • Text Completion Support: Text completion APIs (Kobold, TextGen, etc.) are supported when connected via a Chat Completion (OpenAI-compatible) API endpoint. I recommend setting up a Chat Completion API connection according to the KoboldCpp tips below (change as needed if you are Ollama or other software). After that, set up an STMB profile and use Custom (recommended) or full manual configuration (only if Custom fails or you have more than one custom connection). NOTE: Please note that if you use Text Completion, you must have a chat completion preset!

KoboldCpp Tips to using 📕 ST Memory Books

Set this up in ST (you can change back to Text Completion AFTER you get STMB working) - Chat Completion API - Custom chat completion source - http://localhost:5001/v1 endpoint (you can also use 127.0.0.1:5000/v1) - enter anything in "custom API key" (doesn't matter, but ST requires one) - model ID must be koboldcpp/modelname (don't put .gguf in the model name!) - download a chat completion preset and import it (any one will do) just so you HAVE a chat completion preset. It avoids errors from "not supported" - change the max response length on the chat completion preset so that it is at least 2048; 4096 is recommended. (Smaller means you run the risk of getting cut off.)

Llama.cpp Tips to using 📕 ST Memory Books

Just like Kobold, set the following up as a Chat Completion API in ST (you can change back to Chat Completion after you've verified STMB is working): - Create a new connection profile for a Chat Completion API - Completion Source: Custom (Open-AI Compatible) - Endpoint URL: http://host.docker.internal:8080/v1 if running ST in docker, else http://localhost:8080/v1 - Custom API key: enter anything (ST requires one) - Model ID: llama2-7b-chat.gguf (or your model, doesn't matter if you're not running more than one in llama.cpp) - Prompt post-processing: none

For starting Llama.cpp, I recommend placing something similar to the following in a shell script or bat file, so startup is easier:

llama-server -m <model-path> -c <context-size> --port 8080

💡 Recommended Global World Info/Lorebook Activation Settings

  • Match Whole Words: leave unchecked (false)
  • Scan Depth: higher is better (mine is set to 8)
  • Max Recursion Steps: 2 (general recommendation, not required)
  • Context %: 80% (based on a context window of 100,000 tokens) - assumes you don't have super-heavy chat history or bots.
  • Additional note: If the memory lorebook is your only lorebook, ensure 'Delay until recursion' is disabled in the STMB profile or the memories will not trigger!

🚀 Getting Started

1. Install & Load

  • Load SillyTavern and select a character or group chat.
  • Wait for the chevron buttons (► ◄) to appear on chat messages (may take up to 10 seconds).

Wait for these buttons

2. Mark a Scene

  • Click ► on the first message of your scene.
  • Click ◄ on the last message.

Below are some examples of what the chevron buttons look like when clicked. Your colors may vary depending on your CSS theme!

Clicked start button

Mid-scene buttons

Clicked end button

3. Create a Memory

  • Open the Extensions menu (the magic wand 🪄) and click "Memory Books", or use /creatememory slash command.
  • Confirm settings (profile, context, API/model) if prompted.
  • Wait for AI generation and automatic lorebook entry.

🧩 Memory Types: Scenes vs Summaries

📕 Memory Books supports scene memories plus multi-tier summary consolidation, each designed for different kinds of continuity.

🎬 Scene Memories (Default)

Scene memories capture what happened in a specific range of messages.

  • Based on explicit scene selection (► ◄)
  • Ideal for moment-to-moment recall
  • Preserves dialogue, actions, and immediate outcomes
  • Best used frequently

This is the standard and most commonly used memory type.


🌈 Summary Consolidation

Consolidate button

Summary consolidation captures what changed over time across multiple memories or summaries.

Instead of summarizing one scene, consolidated summaries focus on: - Character development and relationship shifts - Long-term goals, tensions, and resolutions - Emotional trajectory and narrative direction - Persistent state changes that should remain stable

The first consolidation tier is Arc, built from scene memories. Higher tiers are also supported for longer-running stories: - Arc - Chapter - Book - Legend - Series - Epic

💡 Think of these as recaps, not scene logs.

When to use Consolidated Summaries

  • After a major relationship shift
  • At the end of a story chapter or arc
  • When motivations, trust, or power dynamics change
  • Before starting a new phase of the story

How it works

  • Consolidated summaries are generated from existing STMB memories/summaries, not directly from raw chat
  • The Consolidate Memories tool lets you choose a target summary tier and select source entries
  • STMB can optionally watch selected summary tiers and show a yes/later confirmation when a tier reaches its saved minimum eligible count
  • STMB can disable source entries after consolidation if you want the higher-level summary to take over
  • Failed AI summary responses can be reviewed and corrected from the UI before retrying commit

This gives you: - lower token usage - better narrative continuity across long chats


📝 Memory Generation

JSON-Only Output

All prompts and presets must instruct the AI to return only valid JSON, e.g.:

{
  "title": "Short scene title",
  "content": "Detailed summary of the scene...",
  "keywords": ["keyword1", "keyword2"]
}

No other text is allowed in the response.

Built-in Presets

  1. Summary: Detailed beat-by-beat summaries.
  2. Summarize: Markdown headers for timeline, beats, interactions, outcome.
  3. Synopsis: Comprehensive, structured markdown.
  4. Sum Up: Concise beat summary with timeline.
  5. Minimal: 1-2 sentence summary.
  6. Northgate: Literary summary style intended for creative writing.
  7. Aelemar: Focuses on plot points and character memories.
  8. Comprehensive: Synopsis-style summary with improved keyword extraction.

Custom Prompts

  • Create your own, but must return valid JSON as above.

📚 Lorebook Integration

  • Automatic Entry Creation: New memories are stored as entries with all metadata.
  • Flag-Based Detection: Only entries with the stmemorybooks flag are recognized as memories.
  • Auto-Numbering: Sequential, zero-padded numbering with multiple supported formats ([000], (000), {000}, #000).
  • Manual/Automatic Order: Per-profile insertion order settings.
  • Editor Refresh: Optionally auto-refreshes the lorebook editor after adding a memory.

Existing memories must be converted! Use the Lorebook Converter to add the stmemorybooks flag and required fields.


✂️ Clip to Memory Book

Clip text

Clip to Memory Book is for quick “remember this” notes. Highlight important chat text, click the floating scissors button, and save the selected text as a bullet in your Memory Book without opening the lorebook editor first.

If you want an ongoing tracker that updates over time, use a Side Prompt instead. Short version: Clip = one saved fact; Side Prompt = ongoing tracker.

How it works

  • Highlight the exact text you want to remember.
  • Click the floating scissors button. You can turn this button on or off in the Memory Books popup.
  • Choose an existing clip entry or create a new one.
  • Review the current entry and updated preview before saving.
  • Rename the entry/section if needed.

Clip entries are normal lorebo

Core symbols most depended-on inside this repo

escapeHtml
called by 464
stmbJobs.js
M
called by 186
index.build.js
tr
called by 186
clipManager.js
tr
called by 79
stmbJobs.js
f
called by 73
index.build.js
i18n
called by 63
autocreate.js
p
called by 61
index.build.js
c
called by 51
index.build.js

Shape

Function 1,629
Class 16
Method 8

Languages

TypeScript100%

Modules by API surface

index.build.js814 symbols
index.js150 symbols
clipManager.js142 symbols
stmbJobs.js63 symbols
stmemory.js55 symbols
sidePrompts.js47 symbols
utils.js44 symbols
sidePromptsPopup.js43 symbols
sidePromptsManager.js39 symbols
addlore.js33 symbols
arcanalysis.js26 symbols
profileManager.js23 symbols

For agents

$ claude mcp add SillyTavern-MemoryBooks \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page