Skip to main content

Module assembler

Module assembler 

Source
Expand description

Context assembler: orders evaluated entries and applies token budgets.

After entries are activated and evaluated, the assembler sorts them by slot and priority, then fits them within token budgets. The result is an ordered list of AssembledBlocks that the host application inserts into the LLM prompt.

§Slots

Entries declare which slot they target. Slots represent functional depth in the context window, from deep background to immediate foreground. The host application’s ContextDefinition declares which slots exist and where they appear in the prompt.

┌─────────────────────────────┐
│  preamble                   │  ← world axioms, framing rules
│  foundation                 │  ← core lore, character backstory
│  context                    │  ← situational scene info
│  reference                  │  ← supporting material, style guides
│  framing                    │  ← scene mood, active mode
│  guidance                   │  ← behavior rules, quest objectives
│  emphasis                   │  ← active effects, high-attention
│  [chat messages...]         │
│  immediate                  │  ← urgent reminders near chat
│  at_depth(N)                │  ← injected N msgs from end
│  aftermath                  │  ← post-chat notes, summaries
└─────────────────────────────┘

Structs§

AssembledBlock
A fully assembled context block, ready for prompt insertion.
ContextAssembler
GuesstimationTokenizer
A rough tokenizer that estimates ~4 characters per token.
TokenBudget
Token budget tracking for assembled context.

Enums§

Slot
Where in the prompt an entry’s content should be inserted.

Traits§

Tokenizer
Trait for estimating token counts of text content.