MemoryInjectionConfig
Defined in: src/memory/types.ts:228
Configuration for memory context injection.
When enabled on a MemoryManager, the manager searches memory before a model call and makes
the top results available to the model for that call, so relevant knowledge is present without the
model choosing to search. The results are written into the latest user message as an InjectedBlock, which
stays in the conversation and the session. Extraction leaves it out.
Extends the generic InjectionConfig (which carries trigger) with the memory-owned knobs:
how many entries to retrieve, how to derive the query, and how to render the results.
Extends
Section titled “Extends”Properties
Section titled “Properties”trigger?
Section titled “trigger?”trigger?: | InjectionTrigger | ((context) => boolean);Defined in: src/injection/types.ts:43
When injection runs. An InjectionTrigger name selects a built-in policy; a predicate is the escape hatch — it receives the InjectionContext and returns whether to inject this call. A predicate that throws fails open (injection is skipped, the model call proceeds).
Default Value
Section titled “Default Value”'userTurn'Inherited from
Section titled “Inherited from”maxEntries?
Section titled “maxEntries?”maxEntries?: number;Defined in: src/memory/types.ts:241
Maximum number of entries to retrieve and inject per model call.
A store ranks by semantic similarity, which is not the same as contextual usefulness, so the default injects a small candidate set rather than betting on the top hit. Raising this improves recall at the cost of a larger prepend (context bloat); lower it for a tighter injection.
With multiple stores, results are concatenated in store-registration order with no cross-store ranking, so this cap can favor entries from earlier-registered stores.
Default Value
Section titled “Default Value”5query?
Section titled “query?”query?: (context) => string;Defined in: src/memory/types.ts:249
Derives the search query from the current conversation. Return undefined or an empty string to
skip injection for this call. A callback that throws fails open (injection is skipped).
Defaults to an adaptive query: the latest user message’s text on a user turn, otherwise the most recent assistant message’s text (the previous step on an autonomous turn).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | { messages: MessageData[]; } |
context.messages | MessageData[] |
Returns
Section titled “Returns”string
format?
Section titled “format?”format?: (context) => string;Defined in: src/memory/types.ts:263
Renders retrieved entries into the injected text. A callback that throws fails open (injection is skipped).
Defaults to a <memory> XML block with one <entry> per result, carrying a source attribute
naming the originating store (when known) so the model can attribute and weigh each memory. The
default escapes entry content and source, so a custom format that emits markup is responsible
for its own escaping.
Receives only entries that aren’t already in a block this manager wrote earlier in the
conversation. With a custom format, an entry counts as written when its content appears in such
a block.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context | { entries: MemoryEntry[]; } |
context.entries | MemoryEntry[] |
Returns
Section titled “Returns”string