Skip to documentation
Docs navigation
Docs/inject()
MemoGrafter

inject()

Assemble prompt context from explicit topic IDs.

What it does

Assemble prompt context from explicit topic IDs.

When to use it

Use to assemble prompt context from explicit topic IDs in an application-selected session.

Signature

TypeScript
inject(sessionId: string, topicIds: string[]): Promise<InjectionResult>

Parameters

sessionId (string) — The application-owned session whose memory should be read or changed.
topicIds (string[]) — Topic identifiers to include in the generated context.

InjectionResult fields

systemPrompt is the assembled context; this operation does not itself call the chat model.
nodes are selected topics and memories contains their active structured facts when included.
tokenCount is the assembled size; tokenBudget is present when a budget governed assembly.

Result

The selected memory context and prompt text ready to pass to an LLM.

Behavior

Loads active topic context and structured memories, applies the injection token budget, and returns prompt-ready text without calling the LLM.

Side effects and completion

Read-only.

Example

example.ts
const context = await memo.inject("session-1", topicIds);