# Extremis

> Persistent, learning memory for AI agents — RL-scored retrieval, intelligent forgetting, MCP-native. Works with Claude Code, Cursor, OpenAI.

- **Type:** MCP server
- **Install:** `agentstack add mcp-ashwanijha04-extremis`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ashwanijha04](https://agentstack.voostack.com/s/ashwanijha04)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ashwanijha04](https://github.com/ashwanijha04)
- **Source:** https://github.com/ashwanijha04/extremis
- **Website:** https://ashwanijha04.github.io/extremis

## Install

```sh
agentstack add mcp-ashwanijha04-extremis
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 🧠 extremis

**Your AI agent finally remembers. No more re-explaining your project.**

Session 1: you describe your stack, your auth setup, your preferences.
Session 2: your agent already knows — because it learned.

[](https://www.python.org)
[](LICENSE)
[](https://pypi.org/project/extremis)
[](https://www.npmjs.com/package/@extremis/sdk)
[](https://github.com/ashwanijha04/extremis/actions)
[](https://modelcontextprotocol.io)
[](https://github.com/ashwanijha04/extremis/issues/1)
[](https://glama.ai/mcp/servers/ashwanijha04/extremis)
[](results/longmemeval_s_results.jsonl)

**Works with:** Claude Code &nbsp;·&nbsp; Cursor &nbsp;·&nbsp; Windsurf &nbsp;·&nbsp; Claude Desktop &nbsp;·&nbsp; OpenAI &nbsp;·&nbsp; Gemini CLI &nbsp;·&nbsp; any MCP agent

[](https://render.com/deploy?repo=https://github.com/ashwanijha04/extremis)

One click · auto-provisions Postgres · memory persists across restarts

---

## Benchmark results

Evaluated on [LongMemEval-S](https://github.com/xiaowu0162/LongMemEval) — 500 QA instances, each backed by ~53 timestamped conversation sessions.

| Metric | Score | What it measures |
|---|---|---|
| **Retrieval R@5** | **94.4%** | Top-5 recalled memories include the answer session |
| QA accuracy | 38.8% | Correct answer given recalled context (claude-haiku-4-5 judge) |

The retrieval number is the meaningful one — it measures what extremis controls. QA accuracy is a joint score with the downstream LLM; replacing Haiku with a stronger model raises it significantly.

[Raw results (500 instances)](results/longmemeval_s_results.jsonl) · [Benchmark script](benchmarks/longmemeval_s.py) · [Reproduce it yourself](benchmarks/README.md)

---

## Quickest start — wrap your existing LLM client

Change one import. Get persistent, learning memory for free.

### Claude (Anthropic)

```python
# Before
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")

# After — one line change, nothing else in your app changes
from extremis.wrap import Anthropic
from extremis import Extremis

client = Anthropic(api_key="sk-ant-...", memory=Extremis())

# Your existing code works unchanged
response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "What's my name?"}]
)
# extremis recalled context before the call, saved the conversation after
```

### OpenAI

```python
from extremis.wrap import OpenAI
from extremis import Extremis

client = OpenAI(api_key="sk-...", memory=Extremis())
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What did we discuss last time?"}]
)
```

```bash
pip3.11 install "extremis[wrap-anthropic]"   # for Claude
pip3.11 install "extremis[wrap-openai]"      # for OpenAI
```

---

## The problem

You're building a coding agent. Session 1: you explain your project structure, your auth setup using jose middleware, your preferred patterns. Session 2: the agent asks you to explain everything again.

Or you're building a support agent. It learned a customer hates terse responses. Next conversation: terse again. The learning is gone.

Every team building an AI agent hits the same wall.

Your agent forgets everything the moment a session ends. So you add memory. You set up a vector database, write chunking logic, figure out retrieval ranking, handle stale entries, add multi-user isolation. Three weeks later you've built a half-working RAG pipeline and still haven't shipped the actual feature.

And even when you ship it — **it doesn't learn**. Every memory is treated identically. The fact your agent recalled a hundred times and the user loved sits next to one it got wrong once. Nothing improves. There's no feedback loop. You're running the same dumb cosine search forever.

The other problem is lock-in. Your vectors are in Pinecone. Moving them means re-embedding everything, rewriting your retrieval logic, and hoping nothing breaks.

extremis solves all three.

---

## What makes extremis different

### 1. Memory that forgets intelligently

Every competitor focuses on storing memory. Nobody talks about forgetting.

Human memory doesn't keep everything forever — unimportant things fade, important things strengthen. Agents with infinite, flat memory become slow and noisy over time. Intelligent forgetting is the hard problem nobody is solving.

extremis does two things here: **recency decay** (old memories rank lower automatically) and **asymmetric RL weighting** (negative feedback hurts 1.5× more than positive feedback helps, because mistakes should leave a stronger mark). The result is a memory that naturally surfaces what matters and buries what doesn't.

```python
mem = Extremis(config=Config(
    recency_half_life_days=30,  # episodic memories halve in rank every 30 days
    rl_alpha=0.8,               # strong RL signal — useful things stick, useless things fade
))

# This memory will rank lower in every future search
mem.report_outcome([bad_memory_id], success=False, weight=1.0)
# → score decreases by 1.5 (not 1.0 — the asymmetry is intentional)
```

---

### 2. Memory that explains itself

Agents make decisions based on memory. But *why* did it recall that specific memory? Without explainability you're guessing, debugging is painful, and auditing is impossible.

Every `recall()` result includes a plain-English reason:

```python
results = mem.recall("what does the user prefer?")

for r in results:
    print(r.memory.content)
    print(r.reason)

# "User prefers concise answers, no filler words"
# → "similarity 0.91 · score +4.0 · used 8× · 3d old"

# "User prefers dark mode in all UIs"
# → "semantic (always included) · similarity 0.73 · score +1.0 · used 3× · 12d old"

# "User once mentioned preferring email over Slack"
# → "similarity 0.54 · score -1.5 · first recall · 45d old"
```

The reason tells you: how semantically relevant it was, how much feedback has validated it, how many times it's been used, and how old it is. Auditable. Debuggable.

---

### 3. Cross-agent shared memory

Right now memory is per-agent. But the next wave of AI is **agent teams** — a research agent, a writing agent, a review agent, all working together. They need a shared brain.

extremis's namespace model already supports this. Multiple agents can read from and write to the same memory pool:

```python
# All three agents share the same memory namespace
research = Extremis(config=Config(namespace="team_alpha"))
writer   = Extremis(config=Config(namespace="team_alpha"))
reviewer = Extremis(config=Config(namespace="team_alpha"))

# Research agent stores what it found
research.remember("GPT-4 outperforms Claude on math benchmarks by 12%")
research.remember("Source: Stanford HAI report, April 2026")

# Writing agent recalls it without any extra wiring
results = writer.recall("GPT-4 performance data")
# → [GPT-4 outperforms Claude on math benchmarks by 12%]
# → [Source: Stanford HAI report, April 2026]

# Knowledge graph is shared too
research.kg_add_entity("Stanford HAI", EntityType.ORG)
research.kg_add_relationship("Stanford HAI", "HAI Report", "published")
print(writer.kg_query("Stanford HAI"))  # same graph
```

---

### 4. No RAG pipeline to build

One `pip install`. Two lines of config. extremis handles embedding, storage, retrieval ranking, consolidation, and the knowledge graph. You call `remember()` and `recall()`.

```python
# Local — zero infra
from extremis import Extremis
mem = Extremis()

# Your existing vector store
mem = Extremis(config=Config(store="pinecone", pinecone_api_key="..."))

# Self-hosted server — no model download on the client
from extremis import HostedClient
mem = HostedClient(api_key="extremis_sk_...", base_url="http://your-server:8000")

# Same three lines work for all three
mem.remember("User is building a WhatsApp AI", conversation_id="c1")
results = mem.recall("what is the user building?")
mem.report_outcome([r.memory.id for r in results], success=True)
```

---

### 5. Backend portability — no lock-in

Your vectors in Pinecone. Your team moves to Chroma. Your product needs Postgres. One command, everything migrates — and re-embeds automatically if you're switching models:

```bash
extremis-migrate --from pinecone --to postgres \
  --source-pinecone-api-key pk_... \
  --dest-postgres-url postgresql://...

# Switching to OpenAI embeddings at the same time
extremis-migrate --from sqlite --to chroma \
  --dest-embedder text-embedding-3-small
```

---

### Coming soon

**Memory health dashboard** — freshness score, contradiction count, retrieval hit rate, coverage gaps. Memory observability nobody is building yet.

**Domain profiles** — pre-built memory configurations for common agent types:
```python
# Coming in v0.2
from extremis.profiles import SalesAgent, CodingAgent, SupportAgent

mem = Extremis(profile=SalesAgent())
# Knows to remember: customer names, deal stage, objections, preferences
# Knows to forget: small talk after 7 days, meeting logistics after 24h
# Attention: high for "budget", "decision maker", "timeline"
```

---

## How extremis compares

| | extremis | Mem0 | LangChain | Zep | Raw Pinecone |
|--|---------|------|-----------|-----|-------------|
| Self-hostable | ✅ | ❌ cloud only | ✅ | ✅ | ✅ |
| Backend-agnostic | ✅ 4 backends | ❌ | ⚠️ manual | ❌ | — |
| RL-scored retrieval | ✅ | ❌ | ❌ | ❌ | ❌ |
| Asymmetric feedback (1.5×) | ✅ | ❌ | ❌ | ❌ | ❌ |
| Intelligent forgetting | ✅ | ❌ | ❌ | ❌ | ❌ |
| Knowledge graph | ✅ | ❌ | ❌ | ✅ | ❌ |
| 5-layer memory | ✅ | ⚠️ basic | ⚠️ basic | ⚠️ basic | ❌ |
| Log-first durability | ✅ | ❌ | ❌ | ❌ | ❌ |
| Migration CLI | ✅ | ❌ | ❌ | ❌ | — |
| MCP server (Claude Code / Cursor) | ✅ | ❌ | ❌ | ❌ | ❌ |
| Open source | ✅ MIT | ⚠️ partial | ✅ | ✅ | — |

---

## How it works

### The intelligence layer

extremis sits **above** your vector store. RL scoring, the knowledge graph, consolidation, and attention scoring are all backend-independent — they work the same whether your vectors are in SQLite, Pinecone, or Chroma.

```
┌────────────────────────────────────────────────────────────────┐
│                     YOUR APP / AGENT                            │
│      remember() · recall() · report_outcome() · kg_*()         │
└──────────────────────────┬─────────────────────────────────────┘
                           │
┌──────────────────────────▼─────────────────────────────────────┐
│                  EXTREMIS INTELLIGENCE LAYER                      │
│   RL scoring · Knowledge graph · Consolidation · Observer       │
│   Attention scorer · Namespace isolation · Log durability       │
└────┬──────────────┬──────────────┬──────────────┬──────────────┘
     │              │              │              │
┌────▼───┐   ┌──────▼──┐   ┌──────▼──┐   ┌──────▼──┐
│SQLite  │   │Postgres │   │  Chroma  │   │Pinecone │
│(local) │   │+pgvector│   │ (local)  │   │(hosted) │
└────────┘   └─────────┘   └──────────┘   └─────────┘
```

### The memory flow

```
Every conversation
─────────────────
  remember("user said X")     ──▶  fsync to JSONL log (durable)
                                    + episodic memory (embedded + stored)

  recall("topic")             ──▶  embed query
                                    → identity + procedural  (always included)
                                    → semantic + episodic    (ranked by score)
                                    ← ranked results

  report_outcome(ids, +1/-1)  ──▶  adjust utility scores
                                    negative gets 1.5× weight (human memory bias)

Periodically
────────────
  consolidate()               ──▶  read log since last checkpoint
                                    → Claude Haiku extracts facts
                                    → semantic/procedural memories written
                                    → checkpoint advanced (safe to re-run)
```

### Retrieval ranking

Every recalled memory gets a `final_rank` that balances three signals:

```
final_rank = cosine_similarity
           × (1 + α · tanh(utility_score))   ← learned from feedback
           × exp(−ln2 · age_days / half_life) ← recency decay
```

A memory that has proven useful (`+1` feedback) ranks above an equally similar but unvalidated memory. Negative signals apply **1.5× weight** — the same asymmetry human threat-learning uses.

### Memory layers

| Layer | What it holds | Written by | Always recalled? |
|-------|--------------|-----------|-----------------|
| `identity` | Who the user fundamentally is | Human review only | ✅ Always |
| `procedural` | Behavioural rules: *"ask about deadline first"* | Consolidator | ✅ Always |
| `semantic` | Durable facts: *"user is a solo Python developer"* | Consolidator | By relevance |
| `episodic` | Timestamped conversation events | `remember()` | By relevance |
| `working` | Session-scoped, expires on a set datetime | `remember_now()` | By relevance |

### Knowledge graph

Beyond vectors, extremis maintains a structured graph — answers structural questions that semantic search can't:

```python
mem.kg_add_entity("Alice", EntityType.PERSON)
mem.kg_add_entity("Acme Corp", EntityType.ORG)
mem.kg_add_relationship("Alice", "Acme Corp", "works_at", weight=0.95)
mem.kg_add_attribute("Alice", "timezone", "Asia/Dubai")
mem.kg_add_attribute("Alice", "tone", "formal")

# "Who does Alice work for?" — can't answer with cosine similarity alone
result = mem.kg_query("Alice")
# → Entity + all relationships + all attributes + BFS traverse

# Two-hop traverse
graph = mem.kg_traverse("Alice", depth=2)
```

### Attention scoring

Before deciding how much to engage with an incoming message, score it — free, zero LLM cost:

```
score = sender_score + channel_score + content_score + context_score  (0–100)

full      ≥ 75  → engage fully
standard  ≥ 50  → balanced response  
minimal   ≥ 25  → brief acknowledgement
ignore     **Requires Python 3.11+**
>
> If `pip install extremis` says **"no matching distribution found"** — your default `pip` points to Python 3.9 or older. This is common on macOS.
>
> **Check your version:** `python3 --version`
>
> | Platform | Fix |
> |----------|-----|
> | macOS | `brew install python@3.11` then use `pip3.11` |
> | Linux | `sudo apt install python3.11 python3.11-pip` |
> | Windows | [python.org/downloads](https://python.org/downloads) |

```bash
# Confirm you have Python 3.11+
python3.11 --version

# Core — SQLite + local sentence-transformers (no API key needed)
pip3.11 install extremis

# + MCP server (Claude Desktop / Code)
pip3.11 install "extremis[mcp]"

# + Postgres backend
pip3.11 install "extremis[postgres]"

# + Chroma backend
pip3.11 install "extremis[chroma]"

# + Pinecone backend
pip3.11 install "extremis[pinecone]"

# + OpenAI embeddings (swap out the 90 MB model download)
pip3.11 install "extremis[openai]"

# + LLM client wrappers (Claude / OpenAI — automatic memory, one import change)
pip3.11 install "extremis[wrap-anthropic]"   # for Claude
pip3.11 install "extremis[wrap-openai]"      # for OpenAI

# + Hosted API server
pip3.11 install "extremis[server]"

# + Python SDK for hosted cloud
pip3.11 install "extremis[client]"

# Everything
pip3.11 install "extremis[all]"
```

**Requires Python 3.11+**

> **First run note** — `sentence-transformers` downloads `all-MiniLM-L6-v2` (~90 MB) on first use. One-time, cached to `~/.cache/huggingface/`. To skip it, use OpenAI embeddings: `EXTREMIS_EMBEDDER=text-embedding-3-small`.

---

## SDKs

| Language | Package | Source |
|---|---|---|
| Python | [`pip install extremis`](https://pypi.org/project/extremis/) | [`src/extremis/`](src/extremis/) |
| TypeScript | [`npm install @extremis/sdk`](https://www.npmjs.com/package/@extremis/sdk) | [`sdk/typescript/`](sdk/typescript/) |

All SDKs talk to the same `/v1/*` HTTP API and expose the same hallucination-detection signals — `effective_confidence`, `verification.verdict`, and per-issue `recommendations` — as first-class typed fields.

### TypeScript quick start

```ts
import { ExtremisClient } from "@extremis/sdk";

con

…

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ashwanijha04](https://github.com/ashwanijha04)
- **Source:** [ashwanijha04/extremis](https://github.com/ashwanijha04/extremis)
- **License:** MIT
- **Homepage:** https://ashwanijha04.github.io/extremis

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-ashwanijha04-extremis
- Seller: https://agentstack.voostack.com/s/ashwanijha04
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
