Repository navigation
LOREBOOKS
Status: Implemented
Last Updated: 2026-11-13
Audience: Users and developers
Last verified: 2026-11-13 against 5f40af2d9; activation, scanning, limits, storage, import/export, prompt insertion and editor behavior checked.
Code: src/Martlet.Core/Lorebooks/Lorebook.cs, src/Martlet.Core/Lorebooks/LorebookScanner.cs, src/Martlet.Core/Lorebooks/LorebookStore.cs, src/Martlet.Core/Lorebooks/SillyTavernLorebooks.cs, src/Martlet.Core/Settings/CharacterCard.cs, src/Martlet.Core/Sync/AppSettingsSections.cs, src/Martlet.Core/Text/SearchTerms.cs, src/Martlet.Desktop/LiveConversationConfiguration.cs, src/Martlet.Desktop/LiveConversationController.ReplyPreparation.cs, src/Martlet.Desktop/LorebookPromptContext.cs, src/Martlet.Desktop/LorebookWindow.xaml.cs
Martlet's lorebooks work like SillyTavern's World Info: each entry has keywords, and when one comes up in the conversation the entry's text is added to what Martlet sends for that reply. Always-on entries are eligible whenever their lorebook is on for the active persona; chance, entry and byte limits still apply. Open Companion › Lorebook (in Who it is, between Personality and Memory) to see which lorebooks are on, turn one on or off, import one, or open the editor.
- Martlet reads
lorebooks.jsonfrom its data folder. If the file can't be used, the reply goes ahead without lore and the conversation status says why. - Only lorebooks that are on for the active persona are scanned: with every persona, or only with the personas checked in the editor.
- The message being answered and the messages before it, up to the scan depth (2 by default: your message and Martlet's last reply), are searched for each entry's keywords. Screen and camera glances scan their prompt, including the window title and the program in front, so a game's lore can trigger while you play it. While Martlet sees a game played on this PC (Memories for a game), the game's name is scanned too, on its own and at any scan depth: an entry with the game's name as a keyword (Palworld) joins in on every reply while you play it, so a lorebook can hold what Martlet should know or do for one game. Its trigger reads Palworld (played now).
- An entry triggers when any keyword matches and its optional filter keywords pass their rule: and any, and all, none of them or not all of them. Always-on entries need no keyword. An entry with a chance below 100% is then rolled once.
- Triggered entries are kept by priority (always-on first, then higher order) up to 64 entries and the budget (4,096 UTF-8 bytes by default, 256-12,288). An entry that does not fit is skipped; a later, smaller entry may still fit. With recursion on, included entries' text is searched again (up to five rounds) so one entry can bring in another.
- The kept entries are written into the notes on the message (see
Conversation › Prompt caching)
as labeled blocks, the before-persona block first and then the
after-persona block; within each block lower orders come first, so
higher orders sit closer to the reply. An entry already in the notes of an
earlier message the request still carries isn't sent again.
{{char}}becomes the persona's name and{{user}}"the user". - Everything must fit the same request reservation as the persona, recalled memory facts and recent exchanges. Memory facts go first, then the oldest exchanges; lore entries are dropped (lowest priority first) only when nothing else is left.
Keywords are case-insensitive whole words by default. A keyword written
/pattern/flags is a regular expression (i, m and s are honored; an
invalid or slow pattern never matches). Entries can override case sensitivity,
whole-word matching, word forms and scan depth, be excluded from recursion
(only the conversation can trigger it) or stop recursion (its content never
triggers other entries).
Match other word forms (off by default, so keywords match exactly as in
SillyTavern) lets a keyword also match the other forms of its words: dragon
finds dragons, red dragon finds Red Dragons and Drache finds Drachen.
Martlet compares the words by their search stems (the same
word rules as memory, with the
light rules of Spanish, French, German, Portuguese or Italian when the
conversation is in one of them), the words of a keyword in the same order. A
case-sensitive keyword keeps its capital letters (Rose finds Roses, never
the sun rose). A /regex/ keyword, and a keyword in Chinese, Japanese,
Korean or Thai, matches exactly as before. Turn it on for all lorebooks in
the scan settings, or for one entry in its More entry options (Other word
forms: a filled box overrides the scan setting).
Lorebooks are the same on all your computers: they travel as a shared setting through your paired hosts. Only triggered entries are sent to a model, inside the already-authorized LLM request to the Thinking model you chose, so they count toward that request's size (and any per-request cost). The conversation disclosure says matching lorebooks may be included. Lorebooks are user content: they are not permissions and can't change routing, consent, tools or safety rules.
Edit lorebooks opens the editor: create, rename, delete and scope lorebooks; add, duplicate, find and edit entries (title, keywords, filter keywords and rule, content, enabled, always on, placement, order, chance and the per-entry options); change the scan settings shared by all lorebooks; and Try it: type a message to see the entries it would add, their triggers and positions, and any chance, without sending anything. It treats chance checks as passed for entries with a chance above zero. There is no Save button: every edit saves on its own (a moment after typing stops, at once for adding, duplicating, deleting or importing), the footer says All changes saved. or why the latest edit isn't saved yet (such as an invalid scan depth), and closing saves anything still waiting. A save never overwrites a file that changed elsewhere (the footer says to reopen the editor), and a file Martlet can't read is never overwritten.
Import (or drop a file on the editor) reads:
- SillyTavern World Info JSON (
{"entries": {...}}), - the
character_bookinside a SillyTavern/Chub character card: PNG/APNG (ccv3orcharachunk), JSON or CHARX, V2 or V3 (use_regexkeys become/key/i), - standalone character books and NovelAI lorebooks.
An imported lorebook is on for every persona until you change it. Entries without content, or without keywords unless always on, are skipped and counted. Export for SillyTavern writes World Info JSON that SillyTavern imports under World Info.
These carry over both ways: keywords, filter keywords and rule
(selectiveLogic), content, title (comment), always on (constant),
enabled (disable), order, placement (SillyTavern position 0 is before the
persona; every other position, including @depth, becomes after), chance
(probability/useProbability), scan depth, case sensitivity, whole words and
the two recursion options. An entry's own Other word forms choice is written
as matchWordForms, which SillyTavern doesn't use and Martlet reads back; an
entry without its own choice is exported exactly as before. SillyTavern's inclusion groups, sticky/cooldown/delay
timers, @depth roles, vector matching and automation IDs are not used.
Importing a character card as a persona (Companion › Personality) keeps the card's always-on entries in the persona text, as before, and puts its keyword-triggered entries in a lorebook named after the card, used only with that persona. It is saved together with the persona; importing the same card again for the same persona replaces that lorebook's entries.
- At most 1,000 lorebooks, 100,000 entries each, 64 keywords per entry (256 characters each) and 32,768 characters of content per entry. A lorebook can be on for up to 1,000 personas (as many as Martlet keeps).
-
lorebooks.jsonand lorebook import files are at most 256 MB each. Character cards are limited to 8 MB. Martlet reads the whole lorebook file at once, so this limit bounds the memory used by one file. A file that is too large is refused with a message, and the import message counts entries it skipped, including empty entries and entries past the 100,000-entry limit. - Scan depth 0-1,000 messages. Only the messages the conversation has are searched, so a deep scan does not read beyond the conversation. Each reply checks the entries in active lorebooks; response latency depends on the library and the computer.
Martlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine