Sandbox
@major7apps/pensyve

Memory runtime for AI agents and MCP clients

Pensyve gives agents a shared memory layer so they can recall facts, sessions, and successful actions later instead of starting over. It combines retrieval signals like vector search, BM25, graph traversal, recency, and confidence, then exposes the result through SDKs, MCP, a CLI, and REST.

79 stars11 forksRustUpdated 7d ago
Who it's for

Builders who want their agent to remember past sessions, preferences, and working approaches.

What it delivers

You can keep agent work grounded in remembered context instead of re-explaining everything each session.

What it does

Three memory types

Stores episodic memory for what happened, semantic memory for what is known, and procedural memory for what works.

Fusion retrieval

Ranks recalls with vector similarity, BM25, graph traversal, intent, recency, frequency, confidence, and type boosts.

Procedural learning

Tracks action-to-outcome reliability so the agent can surface approaches that actually worked before.

Forgetting and consolidation

Uses FSRS decay and consolidation to strengthen reused memories and fade unused ones.

Offline-first core

Runs locally with SQLite and ONNX embeddings, with no API key needed to get started.

MCP and plugin support

Provides an MCP server and packaged integrations for Claude Code, Codex, Cursor, and other clients.

Multi-language SDKs

Includes Python, TypeScript, Go, and WASM interfaces around the same core engine.

REST gateway

Offers authenticated REST endpoints plus rate limiting and usage metering through `pensyve-mcp-gateway`.

How to get it

  1. 1Run
    pip install pensyve          # Python (PyPI)
    npm install @pensyve/sdk     # TypeScript (npm)
    go get github.com/major7apps/pensyve/pensyve-go/v3@latest  # Go
  2. 2Run
    pip install pensyve
  3. 3Optional: Bun (TypeScript SDK), Go 1.21+ (Go SDK)
    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__)"
  4. 4Run
    # Install dependencies (creates .venv automatically)
    uv sync --extra dev
    
    # Build the native Python module (required before running any Python code)
    uv run maturin develop --release -m pensyve-python/Cargo.toml
    
    # Verify the module loads
    uv run python -c "import pensyve; print(pensyve.__version__)"

README

Pensyve Banner Logo

Pensyve

CI License: Apache 2.0 Python 3.10+ Rust 1.88+

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 needHow Pensyve solves it
Agent forgets everything between sessionsThree memory types — episodic (what happened), semantic (what is known), procedural (what works)
Agent can't find the right memory8-signal fusion retrieval — vector similarity + BM25 + graph + intent + recency + frequency + confidence + type boost
Agent repeats failed approachesProcedural memory — Bayesian tracking on action→outcome pairs surfaces what actually works
Memory store grows unboundedFSRS forgetting curve — memories you use get stronger, unused ones fade naturally. Consolidation promotes repeated facts.
Need cloud signup to get startedOffline-first — SQLite + ONNX embeddings. Works on your laptop right now. No API keys needed.
Need to scale to productionPostgres backend — feature-gated pgvector for multi-node deployments. Managed service at pensyve.com.
Only works with one frameworkFramework-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/v3@latest  # Go

Or use the MCP server directly with Antigravity CLI, Codex, Claude Code, Cursor, or any MCP client — see MCP Setup.

Quick Start

pip install pensyve

Episode: 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 curve

Building from source

Prerequisites and build steps
  • Rust 1.88+, Python 3.10+ with uv
  • Optional: Bun (TypeScript SDK), Go 1.21+ (Go SDK)
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 Antigravity CLI, 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-plugins

The 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 headers with Authorization: Bearer for remote MCP (HTTP transport). Use the top-level env block (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-codex

For 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.

Antigravity CLI Plugin

Install the native Pensyve plugin for Google Antigravity CLI:

agy plugin install https://github.com/major7apps/pensyve/tree/main/integrations/antigravity-plugin

The plugin bundles eight working-memory rules, eight skills, and a URL-only remote MCP definition. Open /mcp in Antigravity and authenticate Pensyve in the browser; no API key is stored in the plugin.

See integrations/antigravity-plugin/README.md for MCP-only, local-stdio, and migration 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(`  ${m.content}`);
}

Go SDK

Context-aware HTTP client with structured errors.

import pensyve "github.com/major7apps/pensyve/pensyve-go/v3"

client := pensyve.NewClient(pensyve.Config{BaseURL: "http://localhost:3000"})
ctx := context.Background()
client.Remember(ctx, "seth", "Likes Go", 0.9)
memories, _ := client.Recall(ctx, "programming", nil)

CLI

cargo build --bin pensyve-cli

# Recall memories (default output is JSON; use --format text for human-readable)
./target/debug/pensyve-cli recall "editor preferences" --entity user

# Show namespace status with memory counts
./target/debug/pensyve-cli status

# Show stats
./target/debug/pensyve-cli stats

# Inspect an entity
./target/debug/pensyve-cli inspect --entity user

Environment Variables

Pensyve uses the following environment variables across its components:

Core

VariableDefaultDescription
PENSYVE_PATH~/.pensyve/<namespace>SQLite database directory
PENSYVE_NAMESPACEdefaultMemory namespace name
RUST_LOGpensyve=infoTracing filter (e.g. debug, pensyve=debug,hyper=warn)
PENSYVE_ALLOW_MOCK_EMBEDDERfalseFall back to mock embedder if real models unavailable (eager startup only, i.e. with PENSYVE_EAGER_EMBEDDER=1)
PENSYVE_EAGER_EMBEDDERfalseLoad the ONNX model at startup instead of on first use

Gateway / REST API

VariableDefaultDescription
PENSYVE_API_KEYS(empty)Comma-separated valid API keys (standalone mode)
PENSYVE_VALIDATION_URL(none)Remote endpoint for API key validation
PENSYVE_RATE_LIMIT300Max requests per minute per API key
HOST0.0.0.0Server bind address
PORT3000Server bind port

Cloud / Managed Service

VariableDefaultDescription
PENSYVE_API_KEY(none)Cloud API key for remote mode
PENSYVE_REMOTE_URLhttp://localhost:8000Remote server URL
DATABASE_URL(none)Postgres connection string
REDIS_URL(none)Redis for caching, rate limiting, daily quotas

Quotas (managed service)

VariableDefaultDescription
PENSYVE_MAX_NAMESPACESunlimitedMax namespaces per account
PENSYVE_MAX_MEMORIESunlimitedMax total memories per account
PENSYVE_MAX_RECALLS_PER_MONTHunlimitedMax recall operations per month
PENSYVE_MAX_STORAGE_BYTESunlimitedMax storage bytes per account

Optional Features

VariableDefaultDescription
PENSYVE_TIER2_ENABLEDfalseEnable Tier 2 LLM extraction
PENSYVE_TIER2_MODEL_PATH(none)Path to GGUF model file
PENSYVE_OTEL_ENDPOINT(none)OpenTelemetry collector URL

Architecture

Pensyve Architecture

Data Model

Namespace (isolation boundary)
  └── Entity (agent | user | team | tool)
        ├── Episodes (bounded interaction sequences)
        │     └── Messages (role + content)
        └── Memories
              ├── Episodic  — what happened (timestamped, multimodal content type)
              ├── Semantic  — what is known (SPO triples with temporal validity)
              └── Procedural — what works (action→outcome with Bayesian reliability)

Retrieval Pipeline

  1. Embed query via ONNX (Alibaba-NLP/gte-base-en-v1.5, 768 dims)
  2. Classify intent — Question/Action/Recall/General (keyword heuristics)
  3. Vector search — cosine similarity against stored embeddings
  4. BM25 search — FTS5 lexical matching
  5. Graph traversal — petgraph BFS from query entity
  6. Fusion scoring — weighted sum of 8 signals (vector, BM25, graph, intent, recency, access, confidence, type boost)
  7. Cross-encoder reranking — BGE reranker on top-20 candidates
  8. FSRS reinforcement — retrieved memories get stability boost

Project Structure

pensyve/
├── pensyve-core/       Rust engine (rlib) — storage, embedding, retrieval, graph, decay, mesh, observability
├── pensyve-python/     Python SDK via PyO3 (cdylib)
├── pensyve-mcp/        MCP server binary (stdio, rmcp)
├── pensyve-cli/        CLI binary (clap)
├── pensyve-ts/         TypeScript SDK (bun) — timeout, retry, PensyveError
├── pensyve-go/         Go SDK — context-aware HTTP client
├── pensyve-wasm/       WASM build — standalone minimal in-memory Pensyve
├── pensyve_server/       Shared Python utilities — billing, extraction
├── integrations/       All integrations — IDE plugins, framework adapters, code harnesses
│   ├── claude-code/    Claude Code plugin (commands, skills, agents, hooks)
│   ├── antigravity-plugin/ Antigravity plugin (rules, skills, OAuth MCP)
│   ├── vscode/         VS Code sidebar extension
│   ├── openclaw-plugin/ OpenClaw native memory plugin (TypeScript)
│   ├── opencode-plugin/ OpenCode native memory plugin (TypeScript)
│   ├── cursor/         Cursor MCP setup guide
│   ├── cline/          Cline MCP setup guide
│   ├── windsurf/       Windsurf MCP setup guide
│   ├── continue/       Continue MCP setup guide
│   ├── vscode-copilot/ VS Code Copilot Chat MCP setup guide
│   ├── langchain/      LangChain/LangGraph Python (PensyveStore + legacy PensyveMemory)
│   ├── langchain-ts/   LangChain.js/LangGraph.js TypeScript (PensyveStore)
│   ├── crewai/         CrewAI (PensyveStorage + standalone PensyveCrewMemory)
│   └── autogen/        Microsoft AutoGen multi-agent memory
├── tests/python/       Python integration tests
├── benchmarks/         LongMemEval_S evaluation + weight tuning
├── website/            Astro + Tailwind static site for pensyve.com
└── docs/               Architecture, roadmap, design specs, implementation plans

Development

First-Time Setup

# Install dependencies (creates .venv automatically)
uv sync --extra dev

# Build the native Python module (required before running any Python code)
uv run maturin develop --release -m pensyve-python/Cargo.toml

# Verify the module loads
uv run python -c "import pensyve; print(pensyve.__version__)"

Note: The pensyve Python package is a native Rust extension built with PyO3. You must run uv run maturin develop before pytest or any Python import of pensyve, otherwise you will get ModuleNotFoundError: No module named 'pensyve'.

Build & Test

make build      # Compile Rust + build PyO3 module
make test       # Run all tests (Rust + Python)
make lint       # clippy + ruff + pyright
make format     # cargo fmt + ruff format
make check      # lint + test (CI gate)

To run test suites individually:

cargo test --workspace                                       # Rust tests
uv run maturin develop --release -m pensyve-python/Cargo.toml  # Build PyO3 module first
uv run pytest tests/python/ -v                               # Python tests
cd pensyve-ts && bun test                                    # TypeScript tests
cd pensyve-go && go test ./...                               # Go tests

Additional SDKs

cd pensyve-ts && bun test          # TypeScript (38 tests)
cd pensyve-go && go test ./...     # Go (17 tests)
cd pensyve-wasm && cargo check     # WASM (standalone)

Benchmarks

# Synthetic recall smoke test (planted facts, no external dataset required)
python benchmarks/synthetic/run.py --generate --evaluate --verbose

Competitive Landscape

What you needPensyveMem0ZepHoncho
Works offline, no cloud requiredYes — SQLite, runs on your laptopNo — cloud APINo — requires serverNo — cloud API
Agent learns from outcomesYes — procedural memory tracks what worksNoNoNo
Finds memories by meaning8-signal fusion (vector + BM25 + graph + intent + 4 more)Vector onlyVector + temporalVector only
Memories fade naturallyFSRS forgetting curve with reinforcementNo — manual cleanupBasic TTLNo
Multi-turn conversation captureEpisodes with outcome trackingBasicYesYes
Framework agnosticPython, TypeScript, Go, MCP, REST, CLIPython SDKPython/JSPython
Claude Code / Cursor / VS CodeNative plugins + MCPNoNoNo
Production-ready at scalePostgres + pgvector (feature-gated)YesYesYes
Open sourceApache 2.0YesPartialYes

License

Apache 2.0

Files in the repo

Repository payload43 top-level entries
  • .agents
  • .claude-plugin
  • .github
  • benchmarks
  • docs
  • integrations
  • loadtest
  • pensyve_server
  • pensyve-benchmarks
  • pensyve-cli
  • pensyve-core
  • pensyve-go
  • pensyve-mcp
  • pensyve-mcp-gateway
  • pensyve-mcp-tools
  • pensyve-python
  • pensyve-ts
  • pensyve-wasm
  • results
  • scripts
  • tests
  • .env.example
  • .gitignore
  • AGENTS.md
  • Cargo.lock
  • Cargo.toml
  • CHANGELOG.md
  • CLAUDE.md
  • clippy.toml
  • CODE_OF_CONDUCT.md
  • conftest.py
  • CONTRIBUTING.md
  • glama.json
  • LICENSE
  • llms.txt
  • Makefile
  • pyproject.toml
  • README.md
  • rustfmt.toml
  • SECURITY.md
  • server.json
  • smithery.yaml
  • uv.lock

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k