preloadMemoryContext
function preloadMemoryContext( store, session, userInput,maxTokens): Promise<string | null>;Preloads relevant extracted facts into the system prompt before each LLM call.
This is NOT a tool the LLM calls. It is a Runtime-level middleware that:
- Takes the user’s latest message as a search query
- Loads cross-session facts from
ExtractedValueStore(slugfacts) - Formats matching facts as a markdown section
- Truncates the output to fit within the allocated token budget
The maxTokens parameter is mandatory. If the formatted output exceeds maxTokens, memories are dropped in lowest-relevance-first order until the output fits.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”Promise<string | null>