Voice
Nextclaw
Postgres + pgvector long-term memory plugin for OpenClaw. 4-tier recall, multi-key Xinhua-dictionary indexing, deterministic-first ingest, hard per-agent isolation, real-time dashboard.
Install
npm install &&
README
# nextclaw
> Postgres + pgvector long-term memory plugin for [OpenClaw](https://github.com/openclaw/openclaw).
> 4-tier recall Β· multi-key Xinhua-dictionary indexing Β· deterministic-first ingest Β· hard per-agent isolation Β· real-time dashboard.
[](LICENSE)

```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OpenClaw agent (DM, Discord, Slack, WhatsApp, ...) β
βββββββββββββββ¬βββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β memory_search β memory_store
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β nextclaw β
β β
β Recall tier-walk: T0 β T1 β T2 β T3 β
β Ingest pipeline: Stage 0 β 1 β 2 β 3 β 4 β 5 β 6 β
β 8-route hybrid: semantic / fulltext / trgm / β
β concept_tag / entity_ref / β
β time_bucket / anchor / category β
β β
β Per-agent isolation: WHERE c.agent_id = $X (every route) β
βββββββββββββββ¬βββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β Postgres + pgvectorβ β Embedding endpoint β
β semantic + struct β β (Ollama / OpenAI-compat / β
β + audit + cache β β vLLM / TEI / ...) β
β + cold + LISTEN/ β β β
β NOTIFY β dashboard β β β
βββββββββββββββββββββββ βββββββββββββββββββββββββββββ
```
---
## What it does
- **Drop-in replacement** for OpenClaw's bundled SQLite memory plugin (`memory-core`)
- **4-tier recall** so 75%+ of repeat queries return in <5ms with **0 LLM tokens** and **0 embedding calls**
- **Multi-key indexing** ("Xinhua dictionary"): every chunk reachable from many orthogonal angles β semantic / fulltext / trigram / concept tags / entity refs / time buckets / anchors / categories
- **Deterministic-first ingest**: no LLM in the hot path; LLM exists only as a residual stage when deterministic extraction yields nothing
- **Hard per-agent memory namespace isolation**: run a private agent and a public Discord agent on the same database β they physically can't see each other's memory (SQL-layer enforcement, not application-layer)
- **Real-time dashboard** (bilingual CN/EN) with category breakdown, redaction for health/medical, bot-turn telemetry, side-by-side model comparison
- **Self-tuning loop** (daily / weekly / monthly proposals)
- **Universal HTTP ingest gateway** β any cron / skill / external script can write memory through the same Stage 0β6 pipeline
## Quick start
```bash
# 1. Install OpenClaw
git clone https://github.com/openclaw/openclaw.git ~/openclaw
cd ~/openclaw && pnpm install && pnpm build
# 2. Bring up Postgres + pgvector
git clone https://github.com/NextAgentBC/nextclaw.git ~/openclaw/extensions/memory-postgres
cd ~/openclaw/extensions/memory-postgres/dev
docker compose up -d
# 3. Bring up an embedding endpoint (one option among many)
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &
ollama pull nomic-embed-text
# 4. Build the plugin
cd ~/openclaw && pnpm install && pnpm build
# 5. Configure ~/.openclaw/openclaw.json (see docs/INSTALL.md β€)
# 6. Generate dashboard token and start
export NEXTCLAW_DASH_TOKEN=$(openssl rand -hex 24)
pnpm openclaw gateway start
# 7. Smoke test
curl -sS -X POST http://127.0.0.1:8765/api/ingest \
-H "Authorization: Bearer $NEXTCLAW_DASH_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"text":"My favorite Postgres extension is pgvector.","source":"smoke","agentId":"main"}'
```
For the **0 β 1 walkthrough** with troubleshooting, persona files, and
a Discord bot setup, see **[docs/INSTALL.md](docs/INSTALL.md)**.
## Documentation
| Doc | What it covers |
|---|---|
| **[docs/INSTALL.md](docs/INSTALL.md)** | Fresh-machine 0 β 1 walkthrough Β· Discord bot Β· multi-agent isolation Β· troubleshooting |
| **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** | Storage layout Β· 4-tier recall Β· 8-route hybrid Β· Stage 0β6 ingest Β· isolation guarantees Β· scoring Β· self-tuning Β· workers |
| **[docs/CONFIG.md](docs/CONFIG.md)** | Every config field, default, tuning advice |
| **[docs/LIVE_TESTS.md](docs/LIVE_TESTS.md)** | How to run live tests against a real PG + embedding endpoint |
## Compatibility
- **OpenClaw** `>= 2026.4.25`
- **Node** `>= 22`
- **Postgres** `>= 16` with **pgvector** `>= 0.7.0` (HNSW)
- **Embedding**: any OpenAI- or Ollama-compat endpoint. Tested with `nomic-embed-text` (768d), `qwen3-embedding:0.6b` (1024d), `qwen3-embedding:4b` (4096d). Dimension is detected on first embed and locked into the HNSW index.
## Performance reference
Numbers from a single-machine deployment, ~280 chunks, single Discord conversation flow:
| Operation | Path | LLM tokens | Embed calls | Latency |
|---|---|---|---|---|
| Recall β repeated query within 5min | T1 | 0 | 0 | ~ 1 ms |
| Recall β anchor (e.g. PR # in query) | T2 anchor | 0 | 0 | ~ 8 ms |
| Recall β generic question | T2 hybrid | 0 | 1 | ~ 250 ms |
| Ingest β short text (<200 char), warm embed | deterministic | 0 | 0 (cache hit) | ~ 50 ms |
| Ingest β long text (~2000 char) | deterministic | 0 | 1 | ~ 600 ms |
In a typical workload, ingest spends **0 LLM tokens** end-to-end. Recall LLM tokens are 0 except when the optional intent classifier is enabled.
## Privacy by default
- `health` and `medical` chunks auto-pinned (`importance β₯ 0.7`, `retention_class='pinned'`) at ingest time, deterministically β based on a CN+EN keyword dictionary, not LLM judgment
- Their `text_excerpt` is redacted in the dashboard's `/api/recent` response
- Per-agent isolation means a public-facing agent **cannot** retrieve them even via adversarial prompting
## Status
`v0.1.0` β initial public release. Core architecture is settled; APIs may evolve in `0.x` based on feedback. Live tests pass against the reference setup. See [CHANGELOG.md](CHANGELOG.md).
## License
[Apache 2.0](LICENSE) Β· [NOTICE](NOTICE) acknowledges OpenClaw upstream.
voice
Comments
Sign in to leave a comment