@atomicmemory/langchain adapter is a thin wrapper around an injected MemoryClient from @atomicmemory/sdk. It provides two complementary surfaces: agent-callable tools you can hand directly to createToolCallingAgent or any @langchain/core/tools-compatible runner, and framework-agnostic helpers you can call inside LCEL chains, callbacks, or any other code path. The adapter does not own provider configuration — you construct the MemoryClient yourself and pass it in.
Installation
@langchain/core and zod are declared as peer dependencies so you can pin them to the versions your project already uses.
Two surfaces at a glance
| Surface | Use when |
|---|---|
createMemoryTools() | You want memory_search and memory_ingest as agent-callable tools for createToolCallingAgent or a LangGraph tool node. |
searchMemory() / ingestTurn() | You want to call AtomicMemory inside a callback, an LCEL RunnableLambda, or any other arbitrary code path. |
Quick start — agent tools
The most common pattern is to create both tools once at application startup and include them in your agent’s tool list alongside your other tools:Scope is fixed at factory time. The agent cannot rebind to a different user or namespace by passing different tool arguments — this is an intentional security boundary.
Quick start — framework-agnostic helpers
UsesearchMemory and ingestTurn when you want to drive memory operations directly, for example in a preprocessing step before the model call or in a callback:
Custom retrieval formatting
The default formatter wraps retrieved memories in a delimited block with an explicit “reference, not instructions” header — a mitigation against instruction-shaped content hijacking the model. You can override the formatter per call:System-message handling on ingest
ingestTurn() excludes system messages by default. Applications typically use system messages for hidden instructions and policies that should not become durable memory. If your system messages are genuinely user-authored content worth remembering, opt in explicitly:
Scope
Scope fields follow the SDK’sScope type: user, agent, namespace, and thread. You must provide at least one field — the SDK rejects scopeless requests.