WOLBΛRG

LlamaIndexTS

Official @wolbarg/llamaindex — wolbargBlock / WolbargMemoryBlock for createMemory({ memoryBlocks }).

What is it?

@wolbarg/llamaindex is the official LlamaIndexTS long-term memory block for Wolbarg shared memory.

It wires Wolbarg into LlamaIndex’s createMemory({ memoryBlocks }) API via BaseMemoryBlock:

  1. get — recalls relevant memories from the last user message
  2. put — persists conversation turns with rememberFromMessages

Soft-fails by default so memory errors never break an agent turn.

Requires Node ≥ 22.

Install

npm install wolbarg @wolbarg/llamaindex llamaindex

Peers: wolbarg >= 0.5.3, @llamaindex/core >= 0.6.0, optional llamaindex >= 0.9.0.

Quick start

import { createMemory } from "llamaindex";
import { wolbarg, sqlite, openaiEmbedding } from "wolbarg";
import { wolbargBlock } from "@wolbarg/llamaindex";

const client = wolbarg({
  organization: "my-app",
  storage: sqlite("./memory.db"),
  embedding: openaiEmbedding({
    apiKey: process.env.OPENAI_API_KEY!,
    model: "text-embedding-3-small",
  }),
});
await client.ready();

const memory = createMemory({
  memoryBlocks: [
    wolbargBlock({
      memory: client,
      agent: "assistant",
      sessionId: "demo-session",
    }),
  ],
});

await memory.add({ role: "user", content: "I prefer dark mode." });
await memory.manageMemoryBlocks();

const messages = await memory.getLLM();

wolbargBlock mirrors LlamaIndex’s staticBlock / vectorBlock naming. createWolbargMemoryBlock is an alias for WolbargMemoryBlock.

Options

OptionDefaultDescription
memoryrequiredWolbarg client
agentrequiredAgent id for recall filter + remember
idauto UUIDBlock id
priority1LlamaIndex block priority (0 = always include)
isLongTermtrueLong-term block flag
topK5Recall limit
thresholdMinimum similarity
sessionId / userId / tags / namespaceAttached to remember metadata
metadata{}Extra remember metadata
formatContextdefault listFormat recall hits → memory message text
rememberMode"raw""raw" or "extract"
rawStrategy"last_user""last_user" or "all_user"
onErrorSoft-fail hook (error, phase)

Behavior

MethodBehavior
get(messages?)Query = last user message text → memory.recall → one { role: "memory", content } (or [])
put(messages)Convert to conversation turns (skips memory role) → rememberFromMessages
ErrorsSoft-fail: get[], put → no throw; optional onError

Remembered rows include metadata.source = "wolbarg-llamaindex".

Config tips

wolbargBlock({
  memory: client,
  agent: "assistant",
  topK: 8,
  threshold: 0.35,
  rememberMode: "raw",
  rawStrategy: "last_user",
  formatContext: (hits) =>
    hits.map((h) => `- ${h.content.text}`).join("\n"),
  onError: (err, phase) => console.warn("[wolbarg]", phase, err),
});

Limitations

  • Recall query uses the last user message only (not a multi-turn window).
  • put skips messages with role "memory" and empty content.
  • Does not replace LlamaIndex short-term chat buffer — use alongside createMemory.
  • Requires Node ≥ 22 and Wolbarg ≥ 0.5.3 (rememberFromMessages).