MemoGrafterAgent
graft()
Assemble prompt context from explicitly selected topics.
What it does
Assemble prompt context from explicitly selected topics.
When to use it
Use when the application already knows which topic IDs should supply broader context.
Signature
TypeScript
graft(topicIds?: string[]): Promise<InjectionResult>Parameters
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 memories for the selected topics and assembles an LLM-ready system prompt. With no IDs, it uses eligible topics from the agent session.
Side effects and completion
Read-only; grafting previews context and does not copy memory or call the LLM.
Example
example.ts
const injection = await agent.graft([topicId]);