Skip to main content
NiadraMemory wraps the chat memory your agent already keeps (a ChatMemoryBuffer by default) and places the pack on every read; history_tools() hands over the kit as LlamaIndex tools. In TypeScript, NiadraMemory is a LlamaIndex.TS Memory and niadraTools() gives the kit as FunctionTools.

Install

The TypeScript integration ships with @niadra/sdk 0.3.0, ready on main and on npm when it is published; until then the npm package is 0.1.1.

The five primitives

Minimal example

The same code is in examples/llamaindex_agent.py.

In TypeScript

NiadraMemory is a LlamaIndex.TS Memory (it takes the same messages and options as createMemory()), so it serves agents (agent({ memory }), multiAgent) and chat engines alike. In getLLM(), which every model call goes through, it records the customer’s newest message once and returns a copy of the messages with the pack after the leading system messages and the turn_block at the end of the last user message; the stored history keeps only what was said. add() records the final answer as the agent’s turn and a handOff between agents as a handoff. For a memory you build yourself with other blocks, NiadraMemoryBlock gives the same context as a fixed block (priority 0): a block can only sit before the history, so the turn_block follows the pack in the same message, and answers are not recorded this way. niadraTools(convo) returns FunctionTools with the kit’s JSON Schemas, bound to the customer.

Agent memory

NiadraMemory(conversation, agent_memory=True) puts the agent’s own notes before the customer’s context, and history_tools(conversation, agent_memory=...) adds the two tools. See Agent memory.

Limits

  • The shape (a primary memory wrapped, a system message placed on get(), writes passed on in put()) follows the Mem0Memory of LlamaIndex’s Mem0 integration (MIT License); no code was copied. The reading is Niadra’s: one pinned pack per conversation instead of a search per message.
  • Nothing here fails the run: without a pack, get() returns your history alone.
  • Tested against llama-index-core 0.14.25 with the model replaced by a fake and Niadra on the emulator; in TypeScript, against @llamaindex/core 0.6.23 and @llamaindex/workflow 1.1.25, with real agents over a scripted LLM.

Next steps

History navigation

the three tools the agent receives.

Context and views

what goes into the pack and why.