---
name: memory
description: Persistent memory for cluster agents. Use when the user wants the agent to remember something across sessions (watchlists, positions, research findings, preferences), recall what was stored before, or set up a dedicated memory backend (Hindsight for learning-over-time memory with observations and mental models). Covers the built-in cluster memory API (retain/recall, deduped, recency-scored, per-wallet banks) and the Hindsight integration for production-grade memory.
allowed-tools: Read, Write, Edit, Bash(curl:*), Bash(docker:*), Bash(pip:*)
license: MIT
metadata:
  author: clusteragent
  version: "1.0.0"
title: memory
canonical_url: https://skilld.dev/gh/clusteragent/cluster/memory
last_updated: 2026-09-21T00:45:59.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install clusteragent/cluster/memory`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/memory`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/clusteragent/cluster/memory) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/memory`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/memory --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/memory --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Cluster Memory

Two tiers:

1. **Built-in memory** — zero-setup, part of every cluster deployment. Notes are
   deduped (identical content skipped), scored by recency decay, and stored per
   wallet/bank. Backs the `memory_retain` / `memory_recall` MCP tools.
2. **Hindsight backend** — production memory that *learns*: observations, mental
   models, knowledge pages. Self-hosted via Docker, or Hindsight Cloud.

## Built-in Memory (default)

### Retain

```bash
curl -X POST "https://clusteragent.dev/api/memory/retain" \
  -H "Content-Type: application/json" \
  -d '{
    "bank_id": "0xUSER_WALLET",
    "content": "User watches semiconductors; largest position NVDA, entry ~$210",
    "title": "Portfolio focus",
    "tags": ["portfolio", "semis"],
    "session_token": "…"
  }'
```

- `content` max **4000 chars** — a memory is a fact, not a document
- Duplicate content (normalized) is **skipped** unless `force: true`
- `bank_id` is the wallet address by default — memories are per-wallet private
  (wallet-scoped auth required)

### Recall

```bash
curl -X POST "https://clusteragent.dev/api/memory/recall" \
  -H "Content-Type: application/json" \
  -d '{"bank_id":"0xUSER_WALLET","query":"what does the user hold?","limit":10}'
```

Results are scored by recency decay — newest relevant facts win. Use recall
**before** acting on portfolio or preference questions; never ask the user for
something they already told the agent.

### What to store (and what not)

Store: watchlists, position notes, risk preferences, research conclusions, key
decisions ("user prefers limit orders"), recurring instructions.

Do not store: raw market snapshots (re-fetch — they rot), secrets (keys never
belong in memory), anything the user asked to forget — delete the bank instead.

## Hindsight Backend (learning memory)

Cluster's memory layer is pluggable — set `MEMORY_BACKEND=hindsight` on the server
and point it at a Hindsight instance. Hindsight does not just recall conversation;
it extracts **observations** and compiles them into **mental models** so agents get
smarter over time. LongMemEval SOTA benchmark holder.

### Start a server

```bash
docker run -it --pull always --name hindsight --restart unless-stopped \
  -p 8888:8888 -p 9999:9999 \
  -e HINDSIGHT_API_LLM_PROVIDER=openai \
  -e HINDSIGHT_API_LLM_API_KEY=$OPENAI_API_KEY \
  -v hindsight-data:/home/hindsight/.pg0 \
  ghcr.io/vectorize-io/hindsight:latest
```

API on `:8888`, UI on `:9999`. Works with 25+ LLM providers (OpenAI, Anthropic,
Gemini, DeepSeek, Ollama/local, [OI]-compatible endpoints, and subscription-backed
providers like `openai-codex` / `claude-code` / `github-copilot` — no API key needed
for those).

Bare metal: `pip install hindsight-api`. Managed: Hindsight Cloud
(`https://api.hindsight.vectorize.io`).

### Wire cluster to it

```bash
# in the cluster backend .env
MEMORY_BACKEND=hindsight
HINDSIGHT_URL=http://localhost:8888
HINDSIGHT_TENANT=cluster
```

With this set, `/api/memory/retain` and `/api/memory/recall` transparently route
through Hindsight — same tools, smarter memory. Without it, the SQLite fallback
runs (zero external services, fine for a single-process self-host).

### Direct Hindsight usage (agents)

```bash
pip install hindsight-client
```

```python
from hindsight_client import Hindsight

memory = Hindsight(base_url="http://localhost:8888")

memory.retain(bank_id="0xUSER", items=[
    {"content": "User sold half the PONS position after the +20% run"},
])

results = memory.recall(bank_id="0xUSER", query="PONS position history")
```

### MCP

Hindsight ships its own MCP server — run it alongside cluster's for native memory
tools in any MCP runtime:

```json
{ "mcpServers": { "hindsight": {
    "command": "npx", "args": ["-y", "@vectorize-io/hindsight-mcp"],
    "env": { "HINDSIGHT_BASE_URL": "http://localhost:8888" }
}}}
```

## Choosing

| Need | Use |
|---|---|
| Quick facts, single-process self-host, zero deps | Built-in (SQLite) |
| Agent should *learn* (observations, mental models), production, multi-agent | Hindsight |
