memosift
v1.0.0-alpha.1
Published
Persistent memory + tool-result intelligence for AI agents — TypeScript SDK. One install, all framework adapters, MCP server, CLI, and the agent skill.
Maintainers
Readme
memosift
Persistent memory + tool-result intelligence for AI agents — TypeScript SDK.
MemoSift is a memory layer for AI agents that combines three things competitors don't usually combine:
- Deterministic classification + metadata + security scanning of tool results — runs locally, no cloud dependency
- A queryable knowledge graph of memories, intents, entities, and artifacts — backed by Postgres + pgvector + cross-encoder reranker
- Optional context-budget compression — auto-stub large tool outputs and auto-compress old turns when the context window fills
Same-named SDKs in TypeScript and Python, both client-side, both MIT. The cloud is a paid service.
Install
npm install memosiftThat's it. One package. Includes the entire SDK, every framework adapter (Anthropic, OpenAI, OpenAI Agents, Claude Agent SDK, LangChain, LangGraph, Vercel AI, generic), the Claude Code hook handlers, the MCP server, and the memosift CLI binary.
Requires Node.js 20+.
Pro tier — getting an API key
Anything beyond local primitives (Mode A: classify, extractMetadata, scan) requires a MemoSift cloud account. The asynchronous extraction + reconciliation pipeline that powers track, recall, compress, and explore is hosted at https://dev.memosift.com.
To enable the Pro features:
- Go to memosift.com and sign up.
- Create a project from the dashboard.
- Create an API key inside that project (it starts with
msk_). - Configure your SDK to point at the cloud at
https://dev.memosift.com. - Pass the key when constructing
MemoSift({...}). - You're live —
track,recall,compress,exploreall work.
import { MemoSift } from "memosift";
const ms = new MemoSift({
apiKey: process.env.MEMOSIFT_API_KEY!, // the msk_... key from step 3
baseUrl: "https://dev.memosift.com", // the cloud URL from step 4
});If the cloud is unreachable, every track call queues locally and ships once the network returns — your agent never blocks on MemoSift.
Quick start
import { MemoSift } from "memosift";
const ms = new MemoSift({
apiKey: process.env.MEMOSIFT_API_KEY!,
baseUrl: "https://dev.memosift.com",
});
// After each agent turn:
await ms.track(
[
{ role: "user", content: "find me CSV files" },
{ role: "assistant", content: "Found 3 CSVs." },
],
{ sessionId: "my-session" }
);
// When you want recall:
const result = await ms.recall("user's question", { sessionId: "my-session" });
for (const item of result.items) {
console.log(item.content.slice(0, 120));
}
// When you want a structured context block:
const ctx = await ms.compress({ sessionId: "my-session" });
console.log(ctx.contextBlock);Three integration modes
| Mode | Network | Mutates tool results | Provides recall | Provides compression | Use when | |---|---|---|---|---|---| | A — Inspector | None | No | No | No | Compliance, telemetry, routing — pure local primitives | | B — Sidecar (default) | Yes | No | Yes (cross-session) | No | Long-running agents that need persistent memory | | C — Co-pilot | Yes | Yes (≥2 KB tool results stubbed in model's view) | Yes | Yes (in-session) | Auto-everything; agents that hit context limits |
The Inspector primitives run locally with no cloud dependency. They're free under MIT.
import { classify, extractMetadata, scan, SecurityMode } from "memosift";
const ct = classify(myToolOutput); // ContentType enum
const md = extractMetadata(myToolOutput, ct); // structured metadata
// Security: FLAG (annotate), REDACT (mask matches), or BLOCK (throw)
const result = scan(myToolOutput, { mode: SecurityMode.REDACT });
console.log(result.content); // secrets masked
console.log(result.findings); // SecurityFinding[]Framework adapters
Each adapter leverages the most natural extension point of its target framework. Tool outputs flow through the MemoSift interception pipeline transparently — large results get replaced in place with artifact stubs (Mode C), or just observed and tracked (Modes A/B).
Anthropic
import Anthropic from "@anthropic-ai/sdk";
import { MemoSift, wrapAnthropic } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const session = ms.session("my-session");
const client = wrapAnthropic(new Anthropic(), { memosift: ms, session });
// Use `client` exactly like the original Anthropic SDK.
const response = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [...],
});OpenAI (Chat Completions + Responses API)
import OpenAI from "openai";
import { MemoSift, wrapOpenAI } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const session = ms.session("my-session");
const client = wrapOpenAI(new OpenAI(), { memosift: ms, session });LangChain
import { ChatOpenAI } from "@langchain/openai";
import { MemoSift, memosiftCallback } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const handler = memosiftCallback({ memosift: ms, session: ms.session("my-session") });
const llm = new ChatOpenAI({ callbacks: [handler] });LangGraph
import { MemoSift, withLangGraphMemoSift } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const wrapped = withLangGraphMemoSift(myCompiledGraph, { memosift: ms, session: ms.session("my-session") });Vercel AI SDK
import { generateText } from "ai";
import { MemoSift, memosiftMiddleware } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const middleware = memosiftMiddleware({ memosift: ms, session: ms.session("my-session") });
// Pass `middleware` via the Vercel AI SDK's middleware option.Claude Agent SDK
import { MemoSift, installClaudeAgentMemoSift } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
installClaudeAgentMemoSift(myAgent, { memosift: ms, session: ms.session("my-session") });OpenAI Agents SDK
import { MemoSift, wrapOpenAIAgentsTool } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const wrappedTool = wrapOpenAIAgentsTool(myTool, { memosift: ms, session: ms.session("my-session") });Generic adapter
For any framework not listed above. You declare which methods to intercept and supply an extractor.
import { MemoSift, wrapGenericClient } from "memosift";
const ms = new MemoSift({ apiKey: process.env.MEMOSIFT_API_KEY!, baseUrl: "https://dev.memosift.com" });
const wrapped = wrapGenericClient(myClient, {
memosift: ms,
session: ms.session("my-session"),
methods: ["chat.completions.create"],
extract: (result, ctx) => [{ toolName: "myTool", content: String(result) }],
});Teach your AI coding agent how to use MemoSift
This package ships with an installable skill that teaches Claude Code, Cursor, Codex CLI, Copilot, or Windsurf how to wire MemoSift into your code correctly:
# After installing the SDK, run from your project root:
memosift install-skill
# Or install everywhere this project supports:
memosift install-skill --all
# Or install globally for Claude Code:
memosift install-skill --userThe CLI auto-detects which agents are configured (.claude/, .cursor/rules/, AGENTS.md) and writes the appropriate format for each. Idempotent — re-runs without --force skip files already containing the MemoSift section.
CLI
memosift login # save your API key locally
memosift install-skill # install the agent skill into the current project
memosift install # wire MemoSift hooks into Claude Code settings
memosift mcp # run as MCP server over stdio (for Claude Code)
memosift hook post-tool-use # individual hook handlers
memosift config get|set|list # manage local config
memosift doctor # diagnostic / troubleshootingLicense
MIT — see LICENSE.
The MemoSift cloud service and dashboard are proprietary; the Inspector primitives in this SDK run locally and are free to use under MIT with no API key required.
Links
- Homepage: https://memosift.com
- Cloud API base URL: https://dev.memosift.com
- Support: [email protected]
- Python SDK:
memosifton PyPI (same surface, different language)
