
Pensyve
Universal memory runtime for AI agents. Framework-agnostic, protocol-native, offline-first.
Without memory
User: "I prefer dark mode and use vim keybindings"
Agent: "Got it!"
[next session]
User: "Update my editor settings"
Agent: "What settings would you like to change?"
User: "I ALREADY TOLD YOU"With Pensyve
# Session 1 — agent stores the preference
p.remember(entity=user, fact="Prefers dark mode and vim keybindings", confidence=0.95)
# Session 2 — agent recalls it automatically
memories = p.recall("editor settings", entity=user)
# → [Memory: "Prefers dark mode and vim keybindings" (score: 0.94)]Your agent stops being amnesiac. Decisions, patterns, and outcomes persist across sessions — and the right context surfaces when it's needed.
Why Pensyve
| What you need | How Pensyve solves it |
|---|---|
| Agent forgets everything between sessions | Three memory types — episodic (what happened), semantic (what is known), procedural (what works) |
| Agent can't find the right memory | 8-signal fusion retrieval — vector similarity + BM25 + graph + intent + recency + frequency + confidence + type boost |
| Agent repeats failed approaches | Procedural memory — Bayesian tracking on action→outcome pairs surfaces what actually works |
| Memory store grows unbounded | FSRS forgetting curve — memories you use get stronger, unused ones fade naturally. Consolidation promotes repeated facts. |
| Need cloud signup to get started | Offline-first — SQLite + ONNX embeddings. Works on your laptop right now. No API keys needed. |
| Need to scale to production | Postgres backend — feature-gated pgvector for multi-node deployments. Managed service at pensyve.com. |
| Only works with one framework | Framework-agnostic — Python, TypeScript, Go, MCP, REST, CLI. Drop-in adapters for LangChain, CrewAI, AutoGen. |
Install
pip install pensyve # Python (PyPI)
npm install @pensyve/sdk # TypeScript (npm)
go get github.com/major7apps/pensyve/pensyve-go@latest # GoOr use the MCP server directly with Codex, Claude Code, Cursor, or any MCP client — see MCP Setup.
Quick Start
pip install pensyveEpisode: your agent remembers a conversation
import pensyve
p = pensyve.Pensyve()
user = p.entity("user", kind="user")
# Record a conversation — Pensyve captures it as episodic memory
with p.episode(user) as ep:
ep.message("user", "I prefer dark mode and use vim keybindings")
ep.message("agent", "Got it — I'll remember your editor preferences")
ep.outcome("success")
# Later (even in a new session), the agent recalls what happened
results = p.recall("editor preferences", entity=user)
for r in results:
print(f"[{r.score:.2f}] {r.content}")Recall grouped: feed an LLM reader without rebuilding session blocks
When the consumer of recalled memories is another LLM (the dominant
"memory for an AI agent" pattern), recall_grouped() returns memories
already clustered by source session and ordered chronologically — ready
to format as session blocks in a reader prompt.
import pensyve
p = pensyve.Pensyve()
groups = p.recall_grouped("How many projects have I led this year?", limit=50)
# Each group is one conversation session — feed it to a reader directly.
for i, g in enumerate(groups, start=1):
print(f"### Session {i} ({g.session_time}):")
for m in g.memories:
print(f" {m.content}")No more manual OrderedDict clustering, no more reordering by date string,
no more boilerplate every consumer has to reinvent.
Remember: store an explicit fact
p.remember(entity=user, fact="Prefers Python over JavaScript", confidence=0.9)Procedural: the agent learns what works
# After a debugging session that succeeded:
ep.outcome("success")
# Pensyve tracks action→outcome reliability with Bayesian updates.
# Next time a similar issue comes up, recall surfaces the approach that worked.Consolidate: memories stay clean
p.consolidate()
# Promotes repeated episodic facts to semantic knowledge
# Decays memories you never access via FSRS forgetting curveBuilding from source
<details> <summary>Prerequisites and build steps</summary>git clone https://github.com/major7apps/pensyve.git && cd pensyve
uv sync --extra dev
uv run maturin develop --release -m pensyve-python/Cargo.toml
uv run python -c "import pensyve; print(pensyve.__version__)"Interfaces
Pensyve exposes its core engine through multiple interfaces — use whichever fits your stack.
Python SDK
Direct in-process access via PyO3. Zero network overhead.
import pensyve
p = pensyve.Pensyve(namespace="my-agent")
entity = p.entity("user", kind="user")
# Remember a fact
p.remember(entity=entity, fact="User prefers Python", confidence=0.95)
# Recall memories (flat list)
results = p.recall("programming language", entity=entity)
# Recall memories clustered by source session — the canonical entry point
# for "memory as input to an LLM reader" workflows.
groups = p.recall_grouped("programming language", limit=50)
# Record an episode
with p.episode(entity) as ep:
ep.message("user", "Can you fix the login bug?")
ep.message("agent", "Fixed — the session token was expiring early")
ep.outcome("success")
# Consolidate (promote repeated facts, decay unused memories)
p.consolidate()MCP Server
Works with Claude Code, Cursor, and any MCP-compatible client.
cargo build --release --bin pensyve-mcp{
"mcpServers": {
"pensyve": {
"command": "./target/release/pensyve-mcp",
"env": { "PENSYVE_PATH": "~/.pensyve/default" }
}
}
}Tools exposed: recall, remember, episode_start, episode_end, forget, inspect, status, account
Claude Code Plugin
Full cognitive memory layer for Claude Code with 7 commands, 4 skills, 2 agents, and 6 lifecycle hooks.
Install from the marketplace:
/plugin marketplace add major7apps/pensyve
/plugin install pensyve@major7apps-pensyve
/reload-pluginsThe plugin does not bundle an MCP server config — auth method and backend are user choices. Add an mcpServers.pensyve entry to your ~/.claude/settings.json (user-level) or .claude/settings.json (project-level). Pick one:
Pensyve Cloud — API key (recommended):
export PENSYVE_API_KEY="psy_your_key_here"{
"mcpServers": {
"pensyve": {
"type": "http",
"url": "https://mcp.pensyve.com/mcp",
"headers": {
"Authorization": "Bearer ${PENSYVE_API_KEY}"
}
}
}
}Pensyve Cloud — OAuth (browser sign-in):
{
"mcpServers": {
"pensyve": {
"type": "http",
"url": "https://mcp.pensyve.com/mcp"
}
}
}Pensyve Local (self-hosted, no API key):
Build the MCP binary first (see Install), then:
{
"mcpServers": {
"pensyve": {
"command": "pensyve-mcp",
"args": ["--stdio"]
}
}
}Note: Use
headerswithAuthorization: Bearerfor remote MCP (HTTP transport). Use the top-levelenvblock (Claude Code MCP schema) for local stdio servers that read environment variables at startup.
Plugin contents:
├── 7 slash commands /remember, /recall, /forget, /inspect, /consolidate, /memory-status, /using-pensyve
├── 4 skills session-memory, memory-informed-refactor, context-loader, memory-review
├── 2 agents memory-curator (background), context-researcher (on-demand)
└── 6 hooks SessionStart, Stop, PreCompact, UserPromptSubmit, PostToolUse (Write/Edit, Bash)See integrations/claude-code/README.md for full documentation.
Codex Plugin
First-class working memory for OpenAI Codex with a plugin manifest, bundled MCP server config, hooks, skills, /pensyve, and $pensyve skill invocation.
Add this repo as a Codex plugin marketplace, then install Pensyve:
codex plugin marketplace add major7apps/pensyve
codex plugin add pensyve@pensyve-codexFor local development from a checkout, use
codex plugin marketplace add /path/to/pensyve/integrations/codex-plugin instead.
Set your API key for the bundled MCP server:
export PENSYVE_API_KEY="psy_your_key_here"The plugin bundles integrations/codex-plugin/.mcp.json, so Codex can load the Pensyve MCP server without copying a project config file. Use /skills, $pensyve, or /pensyve for explicit memory work, or let the bundled hooks and instructions prompt Codex to recall before substantive project decisions. @pensyve is documented as a text-level compatibility convention; true native Codex @-mention dispatch still needs platform support.
See integrations/codex-plugin/README.md for the manual fallback and local-stdio setup.
REST API
Rust/Axum gateway serving REST + MCP with auth, rate limiting, and usage metering.
cargo build --release --bin pensyve-mcp-gateway
./target/release/pensyve-mcp-gateway # listens on 0.0.0.0:3000# Remember
curl -X POST http://localhost:3000/v1/remember \
-H "Content-Type: application/json" \
-d '{"entity": "seth", "fact": "Seth prefers Python", "confidence": 0.95}'
# Recall
curl -X POST http://localhost:3000/v1/recall \
-H "Content-Type: application/json" \
-d '{"query": "programming language", "entity": "seth"}'
# Recall, clustered by source session (canonical for LLM-reader workflows)
curl -X POST http://localhost:3000/v1/recall_grouped \
-H "Content-Type: application/json" \
-d '{"query": "How many books did I buy?", "limit": 50, "order": "chronological"}'Endpoints: GET /v1/health, POST /v1/recall, POST /v1/recall_grouped, POST /v1/remember, POST /v1/entities, DELETE /v1/entities/{name}, POST /v1/inspect, GET /v1/stats, PATCH /v1/memories/{id}, DELETE /v1/memories/{id}
TypeScript SDK
HTTP client with timeout, retry, and structured errors.
import { Pensyve } from "@pensyve/sdk";
const p = new Pensyve({
baseUrl: "http://localhost:3000",
timeoutMs: 10000,
retries: 2,
});
await p.remember({ entity: "seth", fact: "Likes TypeScript", confidence: 0.9 });
const memories = await p.recall("programming", { entity: "seth" });
// Session-grouped recall — feed an LLM reader without rebuilding session blocks.
const { groups } = await p.recallGrouped("how many projects did I lead?", {
limit: 50,
order: "chronological",
});
for (const g of groups) {
console.log(`### Session ${g.sessionId} (${g.sessionTime})`);
for (const m of g.memories) console.log(`
…