Skip to documentation
Docs navigation
Docs/graftByRelevance()
Fleet Memory

graftByRelevance()

Build fleet-aware relevant graft context.

What it does

Build fleet-aware relevant graft context.

The operation follows the fleet’s memory mode and agent identity rules when selecting, storing, or transferring memory.

Signature

TypeScript
graftByRelevance(query: string, options?: FleetGraftByRelevanceOptions): Promise<InjectionResult>

Parameters

query (string) — Natural-language intent used to rank relevant memory.
options? (FleetGraftByRelevanceOptions) — A typed options object. The applicable fields and defaults are documented below.

GraftByRelevanceOptions fields

topK? (number) — Maximum number of semantic seed topics.
minSimilarity? (number) — Minimum semantic similarity for a seed.
hopDepth? (number) — Number of graph-neighbour expansion hops.
expansionStrategy? ("none" | "graph", default "graph") — Keep only seeds or expand through topic edges.
sessionIds? (string[]) — Restrict eligible source sessions where the calling API supports cross-session selection.

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.

Example

example.ts
const graft = await worker.graftByRelevance("billing");