Inventory System — Design Document
Status: Concept — depends on Trackers for state management and Gallery & Image Storage for visual assets.
Overview
An inventory is a gamified collection of items that a character can acquire, lose, equip, and use during a conversation. It reuses patterns familiar from RPGs and adventure games — slots, quantities, categories — but is entirely code-driven: creators define the rules, the tracker system maintains state, and the gallery provides the visuals.
The inventory is not a standalone system. It is a specialized tracker type backed by gallery images, with structured schema and UI rendering rules. A tracker of type inventory stores the current item list; each item references a gallery image for its icon/sprite; the LLM evaluation step adds or removes items based on narrative events.
Core Goals
- Give creators a plug-and-play inventory mechanic without custom code
- Reuse existing infrastructure: trackers for state, gallery for images, lorebook for item descriptions
- Keep the system code-driven — items, rules, and constraints are defined by the creator, not hardcoded
- Support both simple (flat list of items) and complex (categorized, slotted, quantity-tracked) inventories
How It Works
Inventory as a Tracker
An inventory is defined as a tracker with type: inventory. Like all trackers, it:
- Is evaluated after each assistant message by a separate LLM call
- Stores its current state as structured JSON on each message
- Carries forward across the conversation
- Can drive lorebook injection (item names as search signals)
The difference from a generic keyword tracker is the schema: an inventory tracker has structured item definitions, quantity tracking, category grouping, and optional slot/equipment mechanics.
Item Definitions
Each item in the inventory is linked to a gallery image and optionally a lorebook entry. The creator defines items upfront as part of the character/mode/package setup:
| Field | Type | Description |
|---|---|---|
name |
string | Display name ("Iron Sword", "Health Potion") |
slug |
string | Unique identifier for LLM reference (iron_sword) |
imageId |
gallery_image_id | Gallery image used as the item icon/sprite |
lorebookEntryId |
uuid (optional) | Linked lorebook entry for item description/lore |
category |
string (optional) | Grouping category ("Weapons", "Consumables", "Key Items") |
stackable |
boolean | Whether multiples collapse into quantity (potions) vs occupy separate slots (unique weapons) |
maxQuantity |
int (optional) | Maximum stack size (null = unlimited) |
equippable |
boolean | Whether the item can be equipped to a slot |
equipSlot |
string (optional) | Target slot ("main_hand", "armor", "accessory") |
description |
string | Short description shown in inventory UI tooltip |
extractionHint |
string | Hint for the evaluation LLM on when to add/remove this item |
Inventory State (Per Message)
The tracker stores the current inventory state as structured JSON:
{
"items": [
{ "slug": "iron_sword", "quantity": 1, "equipped": true },
{ "slug": "health_potion", "quantity": 3, "equipped": false },
{ "slug": "dungeon_key", "quantity": 1, "equipped": false }
],
"capacity": { "current": 5, "max": 20 }
}
LLM Evaluation
The evaluation LLM receives the current inventory state plus the item definitions and determines what changed. The extraction hint on each item guides the LLM:
- "Add this item when the player picks up a weapon or receives one as a reward"
- "Remove one when the player drinks or uses a health potion"
- "Add this key when the player finds the dungeon key in the goblin's lair"
The evaluation output is a diff: items added, removed, or quantity-changed. The tracker system applies the diff to produce the new state.
Inventory Slots & Equipment
Creators can optionally define equipment slots — named positions where items can be equipped. This enables classic RPG mechanics:
| Slot | Description |
|---|---|
main_hand |
Primary weapon |
off_hand |
Shield, secondary weapon, or torch |
armor |
Body armor |
head |
Helmet, crown, circlet |
accessory |
Ring, amulet, charm |
Slots are creator-defined strings, not hardcoded. A horror scenario might have flashlight, medicine, journal. A fantasy might have the classic RPG set. A sci-fi adventure might have primary_weapon, suit_module, data_chip.
Equipping an item to a slot:
- Moves it from "bag" to the slot
- If the slot is occupied, the previous item returns to the bag
- Equipped items are injected into the prompt context with higher priority (the LLM knows what the player has ready)
UI Rendering
Inventory Panel
When a character has an inventory tracker, the chat UI shows an inventory panel accessible from the tracker bar or a dedicated icon. The panel renders:
+--------------------------------------------------+
| INVENTORY 5 / 20 slots |
|--------------------------------------------------|
| [Equipped] |
| Main Hand: [sword icon] Iron Sword |
| Armor: [empty slot] |
| |
| [Bag] |
| [potion icon] Health Potion x3 |
| [key icon] Dungeon Key x1 |
| [scroll icon] Ancient Map x1 |
+--------------------------------------------------+
- Item icons come from gallery images (thumbnail size)
- Hovering an item shows its description (from the item definition or linked lorebook entry)
- Quantity is shown for stackable items
- Equipped items are shown in their slot with the slot label
- Empty slots are shown as placeholder outlines
- Items gained or lost since the last message are highlighted (green glow for new, red flash for removed)
Collapsed View (Tracker Bar)
In the collapsed tracker bar, inventory shows a compact summary:
Inventory: Iron Sword, Health Potion x3, Dungeon Key, Ancient Map | 5/20
Gallery Integration
Every item must have a gallery image. This is what makes inventories visual rather than just a text list. The gallery provides:
- Item icons — small thumbnail images displayed in the inventory grid
- Item sprites — larger images shown on hover or in a detail view
- Consistent art style — all items in one gallery share a visual style chosen by the creator
Creators set up a dedicated gallery (e.g., "Item Sprites") and upload item images there. When defining inventory items, they pick from their gallery using the existing ImagePickerModal.
Lorebook Integration
Items optionally link to lorebook entries. When an item is in the inventory:
- Its lorebook entry is eligible for injection (the item name acts as a search signal)
- The LLM has access to the item's full lore/description during generation
- If the item is equipped, its lorebook entry gets higher injection priority
This means a "Cursed Blade of Shadows" in the inventory automatically pulls its lorebook entry describing the blade's history, powers, and curse — without the user mentioning it.
Creator Setup Flow
- Create a gallery for item sprites/icons
- Upload item images to the gallery
- Create lorebook entries for items that need rich descriptions (optional)
- Define the inventory tracker on the character/mode:
- Set tracker type to
inventory - Define equipment slots (optional)
- Set capacity limit (optional)
- Add item definitions, linking each to a gallery image and optionally a lorebook entry
- Set tracker type to
- Write extraction hints for each item so the evaluation LLM knows when to add/remove them
- Define starting inventory — which items the player begins with
Dependencies
| Dependency | Status | What's Needed |
|---|---|---|
| Trackers | Phase 1 shipped (2026-05-30) — eval LLM, per-message snapshots and typed values (freeform / numeric / percentage / enum / list / datetime) are live; the type this needs is not | inventory tracker type, structured JSON state, evaluation LLM integration |
| Gallery | Shipped | Gallery image references for item icons/sprites |
| Lorebook | Shipped | Optional lorebook entry linking for item descriptions |
| Packages | In progress (packages are live in Browse; see its status) | Package-level inventory presets (a package can ship with pre-defined items) |
Scope Boundaries
In scope:
- Inventory as a specialized tracker type
- Item definitions with gallery image links
- Quantity tracking, categories, equipment slots
- LLM-driven item acquisition/removal
- Inventory panel UI in chat
- Lorebook integration for item lore injection
Out of scope (future):
- Item crafting or combining
- Item trading between users
- Item marketplace
- Procedurally generated items
- Item stats affecting tracker values (e.g., sword adds +5 to attack tracker)
- Inventory persistence across conversations (each conversation starts fresh from the defined starting inventory)