Dory Memory
Backend memory store for Hermes Agent.
A semantic memory engine powered by pgvector (PostgreSQL vector database) with server-side embeddings via any OpenAI-compatible API.
Store, search, and maintain agent memories with hybrid vector + full-text retrieval, automatic decay, consolidation, and a sandbox for ephemeral context.
Features
- Hybrid search — Reciprocal Rank Fusion over vector cosine distance and full-text search (
tsvector) - Intent routing — Automatically classifies incoming memories:
Task,Reference,Environment,Preference,Backlog,Pivot,Correction - Immortal memories — Protected from decay/pruning; set automatically for
ReferenceandEnvironmentintents - Embedding cache — In-memory
DashMapdeduplication; saves API calls on repeated content - Ephemeral sandbox —
PivotandTaskintents stage memories in aVecDequebefore committing on flush - Temporal recall — Query memories within ISO datetime windows
- Token-budget search —
recall_within_token_budgetfits results into an LLM context limit - Maintenance — Automatic decay/importance adjustment every 24 h, stale-memory listing, batch purge (immortal-protected)
- Consolidation — Merges sandbox to DB when idle
- Workspace telemetry —
notify-based file watcher drives proactive horizon sweeps - Hermes plugin — Drop-in
MemoryProviderplugin with 6 agent tools (recall,sweep,search_temporal,list_stale,purge,stats)
Architecture
Hermes Agent (Python MemoryProvider plugin)
│ HTTP
▼
┌──────────────────────────────────────────┐
│ axum HTTP server (routes.rs) │
│ │
│ ┌──────────┐ ┌──────────┐ ┌────────┐ │
│ │ guard.rs │ │ embed.rs │ │ cache │ │
│ │ sanitize │→│ embedding │→│ .rs │ │
│ │ redact │ │ API call │ │ DashMap│ │
│ └──────────┘ └──────────┘ └────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌──────────────────────────────┐ │
│ │ DoryEngine (engine.rs) │ │
│ │ process_and_route_memory │ │
│ │ hybrid_recall / temporal │ │
│ │ proactive_horizon_sweep │ │
│ └──────────┬───────────────────┘ │
│ │ │
└─────────────┼─────────────────────────────┘
│ sqlx
▼
┌──────────────────────┐
│ PostgreSQL + pgvector │
│ - dory_memories │
│ - dory_namespaces │
└──────────────────────┘
Background workers (workers.rs):
- Decay/pruning (every 24h)
- Consolidation (idle trigger)
Telemetry daemon (telemetry.rs):
- notify watcher on workspace
Quick start
With Docker Compose (recommended)
Without Docker
# Start PostgreSQL with pgvector
# Build and run
Configuration
Create dory.toml:
[]
= "postgres://dory:dory@localhost:5432/dory"
[]
= "0.0.0.0"
= 5005
[]
= "https://api.openai.com/v1/embeddings"
= "sk-..." # or DORY_EMBEDDING_API_KEY env var
= "text-embedding-ada-002"
= 1536
Set DORY_CONFIG to your config path (defaults to ./dory.toml).
Security note: Prefer the
DORY_EMBEDDING_API_KEYenvironment variable over writing the key indory.toml. The config loader checks the env var first.
API Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/v1/memories |
Insert a memory |
POST |
/v1/search |
Hybrid semantic + full-text search |
POST |
/v1/search/temporal |
Recall within a time window |
POST |
/v1/search/budget |
Token-budgeted search (for prefetch) |
GET |
/v1/sweep/{namespace} |
Proactive horizon sweep (stale tasks) |
POST |
/v1/maintenance/stale |
List stale non-immortal memories |
POST |
/v1/batch/delete |
Batch delete (immortal protected) |
GET |
/v1/stats |
Database statistics |
Hermes Plugin
The plugin lives in plugins/memory/dory/ and provides:
- 6 agent tools:
recall,sweep,search_temporal,list_stale,purge,stats - Auto-namespace: derived from Hermes profile name
- Background sync: async
sync_turnrecords conversation turns - CLI:
hermes dory status,hermes dory config,hermes dory stats
Install by copying plugins/memory/dory/ into your Hermes agent's plugin directory.
Set DORY_API_URL (default http://localhost:5005).
Development
Requires Rust ≥1.85 (edition 2024). The project pins stable in rust-toolchain.toml.
Project layout
src/
├── main.rs # Entrypoint: config, pool, migrations, axum, workers
├── config.rs # TOML config struct + env var overrides
├── error.rs # DoryError (thiserror) + axum IntoResponse
├── models.rs # DoryMemoryNode, DoryInsertPayload, DoryIntent, TimeWindow
├── guard.rs # Secret redaction + prompt-injection sanitization
├── embed.rs # OpenAI-compatible API client
├── cache.rs # DashMap embedding cache + VecDeque sandbox
├── engine.rs # Core engine: routing, recall, stats, maintenance
├── routes.rs # Axum HTTP handlers
├── workers.rs # Decay/pruning + consolidation
└── telemetry.rs # Workspace file watcher