Lorebooks
World knowledge that appears in the prompt exactly when it is relevant.
Books
A lorebook is a collection of entries plus scan settings. Attach any number of books to a conversation; all attached books scan together as one pool.
| Setting | Range | Effect |
|---|---|---|
scanDepth | 0-100 | How many recent messages are scanned for keywords. Both your messages and the character's count. |
tokenBudget | 100-32000 | Cap on the total tokens of activated entries. When books disagree, the highest budget wins. |
recursiveScanning | on / off | Activated entry content is scanned again, letting lore activate more lore (up to 3 passes). |
Entries
An entry has keys (comma-separated trigger words), optional secondary keys, and content. When any key appears in the scanned history, the entry activates and its content is injected.
Selective mode requires a primary AND a secondary key to match. Constant entries skip matching and are always injected. Disabled entries stay in the book but never fire. Match whole words prevents fire from matching campfire.
Each entry has a display name (comment) used only for organizing the editor list; it is never sent to the model and survives import/export round-trips.
Priority vs order
Two numbers control an entry's fate. Priority decides who survives the token budget: higher priority entries are kept first when space runs out.
Order (insertion order) decides placement among the survivors: higher order appears earlier in the prompt. Same order falls back to priority, then entry id.
Injection
All activated entries render into a single lorebook slot in the prompt template, each as its own message with its chosen role: system, user, or assistant.
There is no per-entry position concept; move the lorebook slot in the prompt template editor to control where lore lands relative to everything else.
Decorators
Lines starting with @@ at the top of entry content tweak that entry's behavior:
@@probability 50
@@scan_depth 8
@@role assistant
@@activate_only_after 4
@@keep| Decorator | Effect |
|---|---|
@@probability | Percent chance to inject when activated; the roll is stable within a turn. |
@@scan_depth | Override the book's scan depth for this entry. |
@@order / @@priority | Override placement order or budget priority for this entry. |
@@role | Override the injection role for this entry. |
@@activate_only_after / @@activate_only_every | Fire only after N messages, or only every N messages. |
@@keep / @@dont_activate_after_match | Keep an entry active after its first match, or never activate again after a match. |
@@is_greeting | Only active while the chat is still on the greeting message. |
Token budget behavior
Token counting uses the active model's tokenizer, so the budget reflects what the model actually sees. When entries exceed the budget, the lowest-priority entries are dropped first.
If lore keeps getting cut, raise the budget, lower entry priority spread, or shorten entries. The request log shows exactly which entries made it into a given request.