Expand description
Context assembly — token-budgeted context building for LLM prompts.
The context assembler retrieves facts via hybrid search, ranks them by tier priority, fills a token budget greedily, and formats the output for injection into system prompts, messages, or raw JSON.
Structs§
- Char
Token Estimator - Character-based token estimator (~4 chars per token). Accurate to within ~10% for English text across GPT/Claude models.
- Context
Block - The assembled context block returned by
ContextBuilder::build(). - Context
Builder - Token-budgeted context assembler.
- Context
Config - Configuration for context assembly.
Enums§
- Output
Format - Format for the assembled context block.
Traits§
- Token
Estimator - Pluggable token estimation. Implementations convert text to an approximate token count without requiring a full tokenizer dependency.
Functions§
- format_
markdown - Format facts as human-readable Markdown.
- format_
raw - Format facts as raw JSON (array of objects with text, tier, category, confidence).
- format_
system_ prompt - Format facts as an XML-tagged block for system prompt injection.
- sort_
by_ tier_ priority - Sort facts by tier priority (Working first, then Conversation, then Knowledge). Within the same tier, preserve the original order (which is by retrieval score).