Yash030 commited on
Commit
9604d35
·
1 Parent(s): 5cd3cca

Intial Files

Browse files
AGENTS.md DELETED
@@ -1,289 +0,0 @@
1
- # agentcache-python — Agent Instructions
2
-
3
- ## What this project is
4
-
5
- A Python REST + WebSocket + MCP memory server backed by SQLite. No Node.js, no iii-engine, no Dolt. Agents use it to store observations scoped to `(folder_path, agent_id)` pairs and global long-term memories. The viewer, MCP tools, and REST API are built around the **folder-based memory model** — sessions, lessons, slots, and actions are removed.
6
-
7
- ## Project layout
8
-
9
- ```
10
- src/
11
- ├── app.py Thin Flask factory — create_app(), WebSocket, CORS hook
12
- ├── cli.py CLI entrypoint (agentcache serve/migrate/export)
13
- ├── connect.py Client connection helper
14
- ├── db.py StateKV — SQLite WAL, per-thread connections, stats()
15
- ├── functions.py All canonical business logic (large; memory/ shims delegate here)
16
- ├── search.py BM25 + VectorIndex + HybridSearch + 3 embedding providers
17
- ├── viewer_helpers.py Viewer HTML injection helper
18
- ├── workers.py Background threads — index rebuild, auto-forget, SIGTERM handler
19
- │
20
- ├── routes/ Flask blueprints
21
- │ ├── observations.py /observe, /agent/observe, /folders, /folder/observations
22
- │ ├── memories.py /remember, /agent/remember, /memories, /forget
23
- │ ├── search.py /search, /timeline
24
- │ ├── graph.py /graph, /graph/stats, /graph/query, /graph/build
25
- │ ├── health.py /livez, /health, /audit, /config/flags
26
- │ ├── mcp.py /mcp/tools GET+POST (12 active tools)
27
- │ └── migration.py /migrate
28
- │
29
- ├── memory/ Thin shim package — delegates to functions.py
30
- │ ├── observe.py folder_observe, observe, build_synthetic_compression, strip_private_data
31
- │ ├── remember.py remember, forget, jaccard_similarity
32
- │ ├── context.py context, export_data, rebuild_index
33
- │ ├── graph.py folder_graph_build
34
- │ ├── timeline.py folder_timeline, folder_search
35
- │ └── health.py health_check, auto_forget
36
- │
37
- ├── storage/ KV scope registry + path/ID utilities
38
- │ ├── scopes.py KV class (mirrored from functions.py)
39
- │ ├── paths.py normalize_folder_path, validate_agent_id, generate_id, fingerprint_id
40
- │ └── images.py save_image_to_disk, delete_image, touch_image
41
- │
42
- └── viewer/
43
- └── index.html Single-file HTML dashboard (4 tabs: Folders / Memories / Graph / Timeline)
44
-
45
- sync.py HuggingFace dataset backup/restore
46
- Dockerfile HF Space container definition
47
- start.sh Boot: restore DB → start server → start sync loop
48
- requirements.txt flask, flask-sock, requests, websockets, python-dateutil, huggingface_hub
49
- pyproject.toml pip-installable package (agentcache==0.9.8, Python ≥3.10)
50
- tests/ pytest suite — unit, integration, and Hypothesis property tests
51
- ```
52
-
53
- ## Running
54
-
55
- ```bash
56
- pip install -r requirements.txt
57
- python src/app.py
58
- # Server on http://localhost:3111
59
- # Viewer at http://localhost:3111/viewer
60
- ```
61
-
62
- No build step. No external database. SQLite file lives at `~/.agentcache/agentcache.db`.
63
-
64
- ## Architecture
65
-
66
- ### Data Model — Folder-Based Memory
67
-
68
- The primary unit of storage is `(folder_path, agent_id)`. Each agent accumulates observations scoped to the folder it is working in. Global long-term memories remain unchanged.
69
-
70
- ### Storage — `src/db.py`
71
-
72
- `StateKV` wraps a single SQLite file with:
73
- - `kv_store(scope TEXT, key TEXT, value TEXT, PRIMARY KEY(scope, key))` — all data as JSON
74
- - `audit_log(id, ts, agent_id, message)` — write audit trail
75
- - `sync_state_metadata(key, value)` — HuggingFace sync watermark
76
-
77
- Per-thread persistent connections via `threading.local()`. WAL checkpoint registered via `atexit` and on `SIGTERM`/`SIGINT`.
78
-
79
- Key scopes (defined in `functions.py` `KV` class and mirrored in `src/storage/scopes.py`):
80
-
81
- | Scope | Content |
82
- |-------|---------|
83
- | `mem:folders` | Index of all `(folder_path, agent_id)` pairs — key = `"{path}:{agent}"` |
84
- | `mem:folder:{path}:{agent}` | Observations for a pair — key = obs_id |
85
- | `mem:foldermeta:{path}:{agent}` | Metadata for a pair (obsCount, lastUpdated, summary) |
86
- | `mem:obs_lookup` | O(1) reverse-lookup: obs_id → `{folderPath, agentId}` |
87
- | `mem:memories` | Global long-term memories |
88
- | `mem:index:bm25:*` | Sharded BM25 index (2MB chunks) |
89
- | `mem:audit` | Audit log entries |
90
- | `mem:relations` | Knowledge graph edges |
91
- | `mem:sessions` | Legacy session store (read-only, migration only) |
92
- | `mem:obs:{session_id}` | Legacy per-session observations (read-only, migration only) |
93
-
94
- ### Business logic — `src/functions.py`
95
-
96
- All canonical implementations live here. `src/memory/*` are thin shims that re-export from this module (for future decoupling).
97
-
98
- **Observation pipeline:**
99
- ```
100
- raw payload → normalize_folder_path() → validate_agent_id() → strip_private_data()
101
- → build obs dict → kv.set(folder_obs scope) → upsert folder_meta + folders index
102
- → kv.set(obs_lookup) → BM25-indexed → vector-indexed (if key set)
103
- → schedule_save() (debounced 5s) → audit log → WebSocket broadcast
104
- ```
105
-
106
- **Memory versioning:** `remember()` checks Jaccard similarity against existing memories. If > 0.7 match found, new memory supersedes old (`isLatest=False` on old, `parentId` set on new).
107
-
108
- **Search:** `folder_search()` uses `HybridSearch` (BM25 + vector, RRF k=60). Falls back to BM25-only when no embedding provider is configured. Results include both folder observations and global memories.
109
-
110
- **`health_check()`** returns: `folderCount`, `agentCount`, `pairCount`, `observationCount`, `memoryCount`, `bm25IndexSize`, `vectorIndexSize`, `dbPath`, plus `db.stats()` fields.
111
-
112
- ### Search — `src/search.py`
113
-
114
- - `SearchIndex`: BM25 with Porter stemmer and synonym expansion. Dirty-flag (`_dirty`) prevents unnecessary saves. Persisted in sharded 2MB KV chunks.
115
- - `VectorIndex`: cosine similarity over embeddings stored as base64-encoded float32 arrays. Also has `_dirty` flag.
116
- - `HybridSearch`: fuses BM25 + vector scores with RRF (k=60).
117
-
118
- **Embedding providers** (auto-selected by priority in `create_app()`):
119
-
120
- | Priority | Provider | Env var | Dimensions |
121
- |----------|----------|---------|------------|
122
- | 1 | `GeminiEmbeddingProvider` | `GEMINI_API_KEY` / `GOOGLE_API_KEY` | 768 |
123
- | 2 | `OpenAIEmbeddingProvider` | `OPENAI_API_KEY` | 1536 |
124
- | 3 | `SentenceTransformerProvider` | `AGENTCACHE_LOCAL_EMBEDDING_MODEL` | variable |
125
- | 4 | BM25-only | — | — |
126
-
127
- ### Server — `src/app.py`
128
-
129
- Boot order:
130
- 1. Load `~/.agentcache/.env` if present
131
- 2. Initialize `StateKV` (SQLite)
132
- 3. Auto-select embedding provider (Gemini → OpenAI → SentenceTransformer → BM25-only)
133
- 4. Initialize `IndexPersistence` (load or rebuild)
134
- 5. Backfill `obs_lookup` index if missing
135
- 6. Create Flask app, register blueprints
136
- 7. Set up WebSocket `/stream/mem-live/viewer`
137
- 8. Register CORS `after_request` hook
138
- 9. Start background workers (index rebuild if empty/stale, auto-forget loop)
139
-
140
- Auth: all endpoints check `AGENTCACHE_SECRET` via `hmac.compare_digest`. `/livez` is always open.
141
-
142
- ## MCP Tools
143
-
144
- The server exposes **12 MCP tools** via `GET /agentcache/mcp/tools` and `POST /agentcache/mcp/tools`.
145
-
146
- | Tool | Description | Status |
147
- |------|-------------|--------|
148
- | `agent_observe` | Log observation to a `(folderPath, agentId)` pair | Working |
149
- | `agent_remember` | Save to global long-term memory | Working |
150
- | `memory_recall` | Search folder obs + global memories (BM25+vector) | Working |
151
- | `memory_smart_search` | Hybrid semantic+keyword search (alias for recall) | Working |
152
- | `memory_save` | Explicitly save insight to long-term memory | Working |
153
- | `memory_export` | Export all data as JSON (v2 format) | Working |
154
- | `memory_forget` | Delete memory or folder pair observations | Working |
155
- | `memory_diagnose` | Health check (folder/agent/obs/memory counts) | Working |
156
- | `memory_folders` | List all `(folder, agent)` pairs | Working |
157
- | `memory_folder_observations` | Get observations for a specific pair | Working |
158
- | `memory_timeline` | Folder activity feed (sorted by time, filterable) | Working |
159
-
160
- **MCP stdio wrapper:** `src/mcp_stdio.py` reads `AGENTCACHE_URL` and `AGENTCACHE_SECRET` from environment variables dynamically.
161
-
162
- ## Consistency rules
163
-
164
- **When adding a REST endpoint:**
165
- 1. Add the route in the appropriate `src/routes/*.py` blueprint
166
- 2. Update the `API Reference` section in `README.md`
167
- 3. Add the MCP tool in `src/routes/mcp.py` if it should be agent-callable
168
-
169
- **When adding an MCP tool:**
170
- 1. Add the schema to the `GET /mcp/tools` response in `src/routes/mcp.py`
171
- 2. Add the handler case to the `POST /mcp/tools` dispatch in `src/routes/mcp.py`
172
- 3. Update the tool table in `README.md`
173
- 4. Update `AGENTS.md` tool list
174
-
175
- **When changing data scopes:**
176
- 1. Update the `KV` class in `src/functions.py` (canonical)
177
- 2. Mirror the change in `src/storage/scopes.py`
178
- 3. Update the scope table in this file
179
-
180
- ## Code patterns
181
-
182
- ### Adding a new KV scope
183
-
184
- ```python
185
- # In src/functions.py KV class (canonical):
186
- class KV:
187
- your_scope = "mem:your-scope"
188
-
189
- @staticmethod
190
- def your_dynamic_scope(id: str) -> str:
191
- return f"mem:your-scope:{id}"
192
- ```
193
-
194
- ### Adding a REST endpoint
195
-
196
- ```python
197
- # In the appropriate src/routes/*.py blueprint:
198
- @your_bp.route('/agentcache/your-path', methods=['POST'])
199
- def your_endpoint():
200
- auth_err = _check_auth()
201
- if auth_err:
202
- return auth_err
203
- body = request.get_json(force=True) or {}
204
- # validate fields explicitly — never pass raw body to functions
205
- result = functions.your_function(_get_kv(), body.get('field'))
206
- return jsonify(result), 200
207
- ```
208
-
209
- ### Adding an MCP tool schema
210
-
211
- In `src/routes/mcp.py`, `GET /agentcache/mcp/tools` handler:
212
- ```python
213
- {
214
- "name": "memory_your_tool",
215
- "description": "What it does",
216
- "inputSchema": {
217
- "type": "object",
218
- "properties": {
219
- "query": {"type": "string", "description": "..."}
220
- },
221
- "required": ["query"]
222
- }
223
- }
224
- ```
225
-
226
- In `src/routes/mcp.py`, `POST /agentcache/mcp/tools` handler:
227
- ```python
228
- elif tool_name == 'memory_your_tool':
229
- query = args.get('query', '')
230
- result = functions.your_function(kv, query)
231
- return jsonify({'content': [{'type': 'text', 'text': json.dumps(result)}]})
232
- ```
233
-
234
- ## Environment variables
235
-
236
- | Variable | Default | Purpose |
237
- |----------|---------|---------|
238
- | `III_REST_PORT` / `PORT` | `3111` | Server port |
239
- | `GEMINI_API_KEY` / `GOOGLE_API_KEY` | — | Enables Gemini vector search (priority 1) |
240
- | `OPENAI_API_KEY` | — | Enables OpenAI vector search (priority 2) |
241
- | `AGENTCACHE_LOCAL_EMBEDDING_MODEL` | — | SentenceTransformer model name (priority 3) |
242
- | `AGENTCACHE_SECRET` | — | Bearer token auth |
243
- | `AGENT_ID` | — | Default agent ID |
244
- | `AGENTCACHE_AGENT_SCOPE=isolated` | — | Filter data to current agent |
245
- | `AGENTCACHE_CWD` | — | Fallback folder path for legacy clients |
246
- | `MAX_OBS_PER_FOLDER` | `2000` | Observations hard cap per (folder, agent) pair |
247
- | `TOKEN_BUDGET` | `2000` | Context compilation cap |
248
- | `GRAPH_EXTRACTION_ENABLED` | `false` | Graph extraction (needs LLM) |
249
- | `CONSOLIDATION_ENABLED` | `false` | Consolidation (needs LLM) |
250
- | `AGENTCACHE_AUTO_COMPRESS` | `false` | LLM compression |
251
- | `AUTO_FORGET_ENABLED` | — | Auto-forget sweep (set to "false" to disable) |
252
- | `AGENTCACHE_CORS_ORIGINS` | see app.py | Comma-separated allowed origins |
253
- | `AGENTCACHE_IMAGE_STORE_MAX_BYTES` | 500MB | Image store byte limit |
254
- | `HF_TOKEN` | — | HuggingFace sync |
255
- | `AGENTCACHE_DATASET_REPO` | — | HF dataset repo for backup |
256
-
257
- ## Testing
258
-
259
- ```bash
260
- pip install -e ".[dev]"
261
- pytest tests/ -v
262
- ```
263
-
264
- Tests live in `tests/` — 17 test files covering unit tests, integration tests (Flask test client), and Hypothesis property tests.
265
-
266
- Key test files:
267
- - `tests/test_properties.py` — 8 correctness properties (pair isolation, obs count consistency, index coverage, privacy, timeline ordering, forget completeness, memory version uniqueness, path normalization idempotency)
268
- - `tests/test_api.py` — Flask test client integration tests
269
- - `tests/test_route_regressions.py` — regression suite after blueprint split
270
-
271
- ## HuggingFace Space deployment
272
-
273
- Data flow: `agentcache.db` (SQLite) ↔ `sync.py` ↔ HF dataset repo.
274
-
275
- `start.sh` sequence:
276
- 1. Restore `agentcache.db` from dataset repo
277
- 2. Start `python src/app.py` in background
278
- 3. Run `sync.py` in a loop (backup every ~60s if changed)
279
-
280
- ## Viewer — `src/viewer/index.html`
281
-
282
- Single-file HTML dashboard, served directly by Flask at `/viewer`. No build step, no bundler.
283
-
284
- Tabs: **Folders**, **Memories**, **Graph**, **Timeline**.
285
-
286
- - **Folders tab**: lists all `(folder, agent)` pairs; click a row to drill into observations
287
- - **Memories tab**: global long-term memories with search
288
- - **Graph tab**: force-directed graph — nodes = folder paths, edges = same-parent / cross-ref / agent-shared
289
- - **Timeline tab**: all observations sorted by timestamp desc, filterable by folder path and agent ID
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ARCHITECTURE.md DELETED
@@ -1,144 +0,0 @@
1
- # agentcache-python — Architecture
2
-
3
- ## Overview
4
-
5
- A Python REST + WebSocket + MCP memory server backed by SQLite.
6
- Agents store observations scoped by `(folderPath, agentId)` pairs and retrieve
7
- context at session start. No Node.js, no external database, no build step.
8
-
9
- ---
10
-
11
- ## Module Responsibilities
12
-
13
- ```
14
- src/
15
- ├── app.py Flask application factory (create_app).
16
- │ Initialises DB, embeddings, blueprints, WebSocket,
17
- │ CORS hook, and background workers.
18
- │
19
- ├── routes/ Flask blueprints — one per domain area.
20
- │ ├── __init__.py register_blueprints(app) helper.
21
- │ ├── observations.py /observe, /agent/observe, /folders, /folder/observations
22
- │ ├── memories.py /remember, /agent/remember, /memories, /forget
23
- │ ├── search.py /search, /timeline
24
- │ ├── graph.py /graph, /graph/stats, /graph/query, /graph/build
25
- │ ├── health.py /livez, /health, /audit, /config/flags
26
- │ ├── mcp.py GET+POST /mcp/tools
27
- │ └── migration.py /migrate
28
- │
29
- ├── functions.py Core business logic.
30
- │ observe(), folder_observe(), remember(), forget(),
31
- │ folder_search(), folder_timeline(), health_check(),
32
- │ export_data(), rebuild_index(), auto_forget(),
33
- │ folder_graph_build(), KV scope registry.
34
- │
35
- ├── db.py StateKV — SQLite wrapper (WAL mode, kv_store + audit_log).
36
- │
37
- ├── search.py SearchIndex (BM25 + Porter stemmer + synonyms),
38
- │ VectorIndex (cosine similarity, base64 float32),
39
- │ GeminiEmbeddingProvider, HybridSearch (RRF).
40
- │
41
- ├── workers.py Daemon threads: index rebuild, auto-forget sweep,
42
- │ graceful shutdown (SIGTERM/SIGINT).
43
- │
44
- ├── viewer_helpers.py make_viewer_response() — reads viewer/index.html,
45
- │ injects nonce + version, sets CSP headers.
46
- │
47
- ├── mcp_stdio.py stdio MCP bridge: reads AGENTCACHE_URL and
48
- │ AGENTCACHE_SECRET, proxies tool calls to the HTTP API.
49
- │
50
- └── viewer/
51
- └── index.html Single-file HTML dashboard (no bundler).
52
- ```
53
-
54
- ---
55
-
56
- ## KV Scope Layout
57
-
58
- All data lives in a single SQLite file (`~/.agentcache/agentcache.db`) in two tables:
59
-
60
- - `kv_store(scope TEXT, key TEXT, value TEXT, PRIMARY KEY(scope, key))` — JSON values
61
- - `audit_log(id, ts, agent_id, message)` — write audit trail
62
-
63
- | Scope | Content |
64
- |-------|---------|
65
- | `mem:folders` | Global index of all `(folderPath, agentId)` pairs |
66
- | `mem:folder:{path}:{agent}` | Observations for one `(folder, agent)` pair |
67
- | `mem:foldermeta:{path}:{agent}` | Metadata for one pair (obsCount, lastUpdated, summary) |
68
- | `mem:memories` | Long-term global memories |
69
- | `mem:index:bm25` | BM25 index shards (manifest + data chunks) |
70
- | `mem:audit` | Audit log entries (via `record_audit()`) |
71
- | `mem:relations` | Knowledge graph edges |
72
- | `mem:sessions` | Legacy session objects (read-only for migration) |
73
- | `mem:obs:{session_id}` | Legacy session observations (read-only for migration) |
74
-
75
- ---
76
-
77
- ## Data Flow
78
-
79
- ### Observation Ingestion
80
-
81
- ```
82
- POST /agent/observe
83
- └─► folder_observe(kv, payload)
84
- 1. Validate folderPath, agentId, text, timestamp
85
- 2. normalize_folder_path() + validate_agent_id()
86
- 3. strip_private_data()
87
- 4. Cap text at 4000 chars
88
- 5. Enforce MAX_OBS_PER_FOLDER cap
89
- 6. Generate obs_id (fobs_...)
90
- 7. Write FolderObservation to KV.folder_obs(fp, aid)
91
- 8. Upsert folder metadata (KV.folder_meta)
92
- 9. Upsert global folders index (KV.folders)
93
- 10. Add to BM25 index (_bm25_index.add)
94
- 11. Add to vector index if embedding provider is set
95
- 12. Debounce persistence save (IndexPersistence.schedule_save)
96
- 13. Write audit log entry (kv.commit_version)
97
- 14. Broadcast via WebSocket (/stream/mem-live/viewer)
98
- └─► return {"observationId": obs_id}
99
- ```
100
-
101
- ### Search
102
-
103
- ```
104
- POST /search or POST /mcp/tools {name:"memory_recall"}
105
- └─► folder_search(kv, query, limit, folderPath?, agentId?)
106
- 1. HybridSearch.search() → BM25 + vector RRF fusion
107
- 2. Load all (folder, agent) pairs from KV.folders
108
- 3. Hydrate obs_ids from KV.folder_obs scopes
109
- 4. Apply folderPath/agentId post-filters
110
- 5. Also include matching global memories
111
- 6. Sort by score descending, cap at limit
112
- ```
113
-
114
- ### Memory Versioning
115
-
116
- `remember()` scans existing memories for Jaccard similarity > 0.7.
117
- If found, old memory is marked `isLatest=False` and new memory sets `parentId`.
118
-
119
- ---
120
-
121
- ## Authentication
122
-
123
- All endpoints except `/livez` check `AGENTCACHE_SECRET` via timing-safe
124
- `hmac.compare_digest` Bearer token comparison. No secret → no auth check.
125
-
126
- ---
127
-
128
- ## WebSocket
129
-
130
- `/stream/mem-live/viewer` broadcasts raw JSON payloads to connected viewers.
131
- The viewer's "Replay" tab subscribes to this stream for live observation updates.
132
-
133
- ---
134
-
135
- ## Embedding Providers
136
-
137
- Priority order (auto-selected at startup):
138
-
139
- 1. `GeminiEmbeddingProvider` — if `GEMINI_API_KEY` or `GOOGLE_API_KEY` is set (768 dims)
140
- 2. `OpenAIEmbeddingProvider` — if `OPENAI_API_KEY` is set (1536 dims)
141
- 3. `SentenceTransformerProvider` — if `AGENTCACHE_LOCAL_EMBEDDING_MODEL` is set
142
- 4. BM25-only fallback
143
-
144
- Without an embedding provider, `HybridSearch` falls back to pure BM25.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CHANGELOG.md DELETED
@@ -1,69 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to agentmemory-python are documented here.
4
-
5
- The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions track the Python reimplementation, not the upstream Node.js agentmemory releases.
6
-
7
- ---
8
-
9
- ## [Unreleased]
10
-
11
- ---
12
-
13
- ## [1.0.0] — 2026-06-09
14
-
15
- Initial public release of the Python reimplementation.
16
-
17
- ### Added
18
-
19
- - **Flask REST server** (`src/app.py`) — full API surface matching the agentmemory wire format: sessions, observations, memories, lessons, slots, relations, actions, replay, context, search, MCP
20
- - **SQLite storage** (`src/db.py`) — `StateKV` backed by a single WAL-mode SQLite file at `~/.agentmemory/agentmemory.db`; replaces Dolt SQL Server
21
- - **Audit log** — `audit_log(id, ts, agent_id, message)` table replaces Dolt git versioning; every write is tracked
22
- - **BM25 search** (`src/search.py`) — custom Porter stemmer, in-memory index, persisted to DB in 2MB shards
23
- - **Vector search** (`src/search.py`) — Gemini `text-embedding-004` 768-dim cosine similarity; enabled by `GEMINI_API_KEY`
24
- - **Hybrid search** — RRF fusion of BM25 + vector (k=60), session-diversified (max 3 per session)
25
- - **MCP tools endpoint** — 16 tools via `GET/POST /agentmemory/mcp/tools`
26
- - **WebSocket live stream** — `/stream/mem-live/viewer` broadcasts all observations in real time
27
- - **Built-in viewer** (`src/viewer/index.html`) — single-file HTML dashboard: Dashboard, Sessions, Memories, Graph, Timeline, Lessons, Slots, Replay tabs
28
- - **Knowledge graph visualization** — Graph tab shows project folders as nodes with unique hash-based HSL colors; edges represent shared concepts or common parent paths
29
- - **4-tier memory consolidation** — Working → Episodic → Semantic → Procedural; enabled by `CONSOLIDATION_ENABLED=true` + LLM key
30
- - **Lessons system** — confidence-scored, fingerprinted by SHA-256, duplicate saves strengthen confidence, weekly decay, auto-evict below 0.1
31
- - **Memory versioning** — Jaccard similarity check; memories with > 0.7 overlap supersede each other with `parentId` linkage
32
- - **Session lifecycle** — start, end, commit with summary; auto-close dangling active sessions on new session start
33
- - **HuggingFace Space support** — `Dockerfile`, `start.sh`, `sync.py` for deploy-and-forget on HF Spaces
34
- - **Sync with fingerprinting** (`sync.py`) — mtime+size hash prevents redundant uploads; only backs up when DB actually changed
35
- - **Privacy filtering** — API keys, secrets, `<private>` tags stripped before storage
36
- - **Bearer token auth** — timing-safe `hmac.compare_digest` check on all endpoints when `AGENTMEMORY_SECRET` is set
37
- - **Agent scope isolation** — `AGENTMEMORY_AGENT_SCOPE=isolated` filters all reads to the current `AGENT_ID`
38
-
39
- ### Migrated
40
-
41
- - `migrate_dolt_to_sqlite.py` — one-time migration script that reads all rows from a local Dolt SQL server and writes them to SQLite; migrated 7502 rows (19.6MB) from the original deployment
42
-
43
- ### Removed
44
-
45
- - Dolt SQL server dependency — no more `dolt sql-server`, no more `pymysql`, no more Dolt install in Dockerfile
46
- - Node.js / iii-engine dependency — the entire iii-engine binary and worker model is gone
47
- - `start.sh` Dolt startup block — `sleep 5`, `DOLT_*` env vars, migration step all removed
48
-
49
- ### Dependencies (6 total)
50
-
51
- ```
52
- flask>=3.0.0
53
- flask-sock>=0.7.0
54
- requests>=2.31.0
55
- websockets>=12.0
56
- python-dateutil>=2.8.2
57
- huggingface_hub>=0.20.0
58
- ```
59
-
60
- ---
61
-
62
- ## Format
63
-
64
- - **Added** — new features
65
- - **Changed** — changes to existing behavior
66
- - **Fixed** — bug fixes
67
- - **Removed** — removed features
68
- - **Security** — security fixes
69
- - **Migrated** — data or infrastructure migrations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CLAUDE.md DELETED
@@ -1,109 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## What This Is
6
-
7
- A Python REST + WebSocket + MCP memory server backed by SQLite. No Node.js, no Dolt. Agents use it to store observations scoped to `(folder_path, agent_id)` pairs and global long-term memories. The architecture is **folder-based** — sessions, lessons, slots, and actions are removed.
8
-
9
- ## Running
10
-
11
- ```bash
12
- pip install -r requirements.txt
13
- python src/app.py
14
- # Server on http://localhost:3111
15
- # Viewer at http://localhost:3111/viewer
16
- ```
17
-
18
- No build step. SQLite file lives at `~/.agentcache/agentcache.db`. Config optionally loaded from `~/.agentcache/.env`.
19
-
20
- ## Running Tests
21
-
22
- ```bash
23
- pip install -e ".[dev]"
24
- pytest tests/ -v
25
- ```
26
-
27
- ## Key Environment Variables
28
-
29
- | Variable | Default | Purpose |
30
- |---|---|---|
31
- | `III_REST_PORT` / `PORT` | `3111` | API server port |
32
- | `GEMINI_API_KEY` / `GOOGLE_API_KEY` | — | Gemini vector search (priority 1) |
33
- | `OPENAI_API_KEY` | — | OpenAI vector search (priority 2) |
34
- | `AGENTCACHE_LOCAL_EMBEDDING_MODEL` | — | SentenceTransformer model (priority 3) |
35
- | `AGENTCACHE_SECRET` | — | Bearer token auth on all endpoints |
36
- | `AGENT_ID` | — | Default agent ID |
37
- | `AGENTCACHE_AGENT_SCOPE=isolated` | — | Filter data to current `AGENT_ID` |
38
- | `AGENTCACHE_CWD` | — | Fallback folder path for legacy clients |
39
- | `MAX_OBS_PER_FOLDER` | `2000` | Hard cap on observations per (folder, agent) pair |
40
- | `TOKEN_BUDGET` | `2000` | Context compilation cap |
41
- | `GRAPH_EXTRACTION_ENABLED` | `false` | Knowledge graph extraction (needs LLM) |
42
- | `CONSOLIDATION_ENABLED` | `false` | Memory consolidation (needs LLM) |
43
- | `AGENTCACHE_AUTO_COMPRESS` | `false` | LLM-powered observation compression |
44
- | `AGENTCACHE_CORS_ORIGINS` | see app.py | Comma-separated allowed CORS origins |
45
-
46
- ## Architecture
47
-
48
- ### `src/db.py` — Storage Layer
49
-
50
- `StateKV` wraps SQLite with two tables:
51
- - `kv_store(scope, key, value)` — all data as JSON, namespaced by scope
52
- - `audit_log(id, ts, agent_id, message)` — write audit trail
53
-
54
- Per-thread persistent connections via `threading.local()`. WAL checkpoint on shutdown.
55
-
56
- Key scopes: `mem:folders` (index), `mem:folder:{path}:{agent}` (observations), `mem:foldermeta:{path}:{agent}` (metadata), `mem:obs_lookup` (O(1) reverse lookup), `mem:memories` (global), `mem:index:bm25:*` (search).
57
-
58
- ### `src/functions.py` — Business Logic
59
-
60
- All core implementations. Key functions:
61
- - `folder_observe(kv, payload)` — ingest a folder-scoped observation
62
- - `folder_search(kv, query, limit, folder_path, agent_id)` — BM25+vector hybrid search
63
- - `folder_timeline(kv, limit, folder_path, agent_id, before, after)` — activity feed
64
- - `folder_graph_build(kv)` — build graph nodes + edges
65
- - `remember(kv, data)` / `forget(kv, data)` — global memory management
66
- - `health_check(kv)` — system stats
67
- - `export_data(kv, data)` — v2 JSON export
68
- - `migrate_sessions_to_folders(kv, dry_run)` — legacy migration
69
-
70
- `src/memory/*` contains thin shim modules that re-export from here.
71
-
72
- ### `src/search.py` — Search Indexes
73
-
74
- - `SearchIndex`: BM25 with Porter stemmer + synonym expansion. `_dirty` flag prevents unnecessary saves.
75
- - `VectorIndex`: cosine similarity over embeddings as base64 float32. `_dirty` flag.
76
- - `HybridSearch`: RRF fusion (k=60) of BM25 + vector.
77
- - `GeminiEmbeddingProvider`, `OpenAIEmbeddingProvider`, `SentenceTransformerProvider`.
78
-
79
- ### `src/app.py` — Flask Factory
80
-
81
- `create_app()`: init DB → auto-select embedding provider → init IndexPersistence → backfill obs_lookup → register blueprints → setup WebSocket → register CORS → start background workers.
82
-
83
- ### `src/routes/` — Flask Blueprints
84
-
85
- | Blueprint | Endpoints |
86
- |-----------|-----------|
87
- | `observations.py` | `/observe`, `/agent/observe`, `/folders`, `/folder/observations`, legacy session shims |
88
- | `memories.py` | `/remember`, `/agent/remember`, `/memories`, `/forget` |
89
- | `search.py` | `/search`, `/timeline` |
90
- | `graph.py` | `/graph`, `/graph/stats`, `/graph/query`, `/graph/build` |
91
- | `health.py` | `/livez`, `/health`, `/audit`, `/config/flags` |
92
- | `mcp.py` | `/mcp/tools` GET+POST (12 tools) |
93
- | `migration.py` | `/migrate` |
94
-
95
- ### `src/workers.py` — Background Threads
96
-
97
- - Index rebuild thread (if BM25 index is empty or out of sync on boot)
98
- - Auto-forget sweep loop (hourly)
99
- - SIGTERM/SIGINT handlers: flush `IndexPersistence`, WAL checkpoint, exit 0
100
-
101
- ### `src/viewer/index.html` — Dashboard
102
-
103
- Single-file HTML, served at `/viewer`. Tabs: **Folders**, **Memories**, **Graph**, **Timeline**. No build step.
104
-
105
- ## MCP Tools (12 active)
106
-
107
- `agent_observe`, `agent_remember`, `memory_recall`, `memory_smart_search`, `memory_save`, `memory_export`, `memory_forget`, `memory_diagnose`, `memory_folders`, `memory_folder_observations`, `memory_timeline`
108
-
109
- Full schema at `GET /agentcache/mcp/tools`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CODE_OF_CONDUCT.md DELETED
@@ -1,48 +0,0 @@
1
- # Code of Conduct
2
-
3
- agentmemory follows the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
4
-
5
- The short version:
6
-
7
- - Be kind. Assume good faith.
8
- - Disagree on the idea, not the person.
9
- - Harassment — in issues, PRs, discussions, or any other project space — is not tolerated.
10
- - Unwelcome behavior gets moderated first by reminder, then by time-out, then by removal.
11
-
12
- ## Enforcement
13
-
14
- Reports go to **ghumare64@gmail.com** with subject `agentmemory CoC`. All reports are confidential.
15
-
16
- Responses follow the Covenant's enforcement ladder — correction, warning, temporary ban, permanent ban — and are decided by the project Maintainers listed in [MAINTAINERS.md](./MAINTAINERS.md). Where a Maintainer is a party to the report, that Maintainer recuses.
17
-
18
- ### Escalation when no impartial Maintainer is available
19
-
20
- If every listed Maintainer recuses, or if the project is operating with a single Maintainer and the report concerns that Maintainer, the report is forwarded to an external neutral contact for independent adjudication. The current fallback chain, in order:
21
-
22
- 1. **Contributor Covenant community ombudsperson** — email `ombudsperson@contributor-covenant.org` (see <https://www.contributor-covenant.org/faq/>).
23
- 2. **Hosting foundation abuse channel** — when agentmemory is accepted into a foundation (see `GOVERNANCE.md`), reports can be routed to that foundation's conduct committee instead. The current contact will be published here at that time.
24
- 3. **GitHub Trust & Safety** — for conduct that occurs inside GitHub spaces, the report can also be filed through <https://support.github.com/contact/report-abuse>.
25
-
26
- The external contact receives the original report verbatim (redacted only of third-party PII unrelated to the incident) and decides the enforcement step. The Maintainer body executes whatever enforcement action the external contact recommends. This ensures no report can dead-end because every internal reviewer is conflicted.
27
-
28
- ## Scope
29
-
30
- This applies to every project space:
31
-
32
- - GitHub issues, PRs, discussions, and reviews on this repo.
33
- - Any official chat channel that gets set up (currently none).
34
- - Public representation of the project at conferences, meetups, and on social media.
35
-
36
- ## Full text
37
-
38
- Reproduced verbatim from the Contributor Covenant 2.1 for convenience:
39
-
40
- > We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
41
- >
42
- > We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
43
-
44
- Full Covenant v2.1 text: <https://www.contributor-covenant.org/version/2/1/code_of_conduct/>
45
-
46
- ## Attribution
47
-
48
- Contributor Covenant is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CONTRIBUTING.md DELETED
@@ -1,97 +0,0 @@
1
- # Contributing to agentmemory-python
2
-
3
- Thanks for your interest. This covers the path from "I have an idea" to "it's merged."
4
-
5
- ## License
6
-
7
- Apache-2.0. Every contribution is covered by it.
8
-
9
- ## Before opening an issue
10
-
11
- Search [open issues](https://github.com/Yashwant00CR7/agentcache/issues?q=is%3Aopen) and [closed issues](https://github.com/Yashwant00CR7/agentcache/issues?q=is%3Aclosed) first.
12
-
13
- **Bug reports** — include:
14
- - Python version (`python --version`)
15
- - OS
16
- - Exact steps to reproduce
17
- - What you expected vs. what happened
18
- - Any relevant log lines from the server
19
-
20
- **Feature requests** — describe the user problem before the implementation. "I couldn't X because Y" is more useful than "please add Z."
21
-
22
- ## Before opening a PR
23
-
24
- 1. Fork the repo and create a branch off `main`:
25
- - `feat/<short-name>` for new features
26
- - `fix/<issue-number>-<short-name>` for bug fixes
27
- - `docs/<topic>` for documentation
28
- - `refactor/<topic>`, `chore/<topic>` for everything else
29
-
30
- 2. Install dependencies:
31
- ```bash
32
- pip install -r requirements.txt
33
- ```
34
-
35
- 3. Make your change. Keep it focused — one logical change per PR.
36
-
37
- 4. Run the server and test manually:
38
- ```bash
39
- python src/app.py
40
- curl http://localhost:3111/agentmemory/livez
41
- ```
42
-
43
- 5. No test runner is configured yet. If you're adding tests, use `pytest`:
44
- ```bash
45
- pip install pytest
46
- pytest
47
- ```
48
-
49
- 6. Run linting before submitting:
50
- ```bash
51
- pip install ruff
52
- ruff check src/
53
- ruff format src/
54
- ```
55
-
56
- ## Pull request guidelines
57
-
58
- - Write a clear description: what it does, why, and how to verify.
59
- - Link the issue the PR resolves (`Fixes #NNN` or `Closes #NNN`).
60
- - Keep PRs small — large PRs are harder to review and slower to merge.
61
- - Address review feedback in new commits, not force-pushes.
62
-
63
- ## Code style
64
-
65
- - Python 3.10+. No walrus operator or match/case unless there's a real reason.
66
- - No comments that restate what the code does. Only comment the *why* — a hidden constraint, a workaround for a specific bug, a non-obvious invariant.
67
- - No dead code or commented-out blocks.
68
- - Validate inputs at system boundaries (REST endpoints, MCP handlers). Never pass raw request bodies to internal functions.
69
- - Use `hmac.compare_digest` for secret comparisons — never `==`.
70
-
71
- ## Architecture rules
72
-
73
- When adding a REST endpoint, also update:
74
- - `README.md` API Reference table
75
- - `AGENTS.md` if it's agent-callable
76
-
77
- When adding an MCP tool, also update:
78
- - The schema list in `GET /agentmemory/mcp/tools` in `src/app.py`
79
- - The dispatch handler in `POST /agentmemory/mcp/tools` in `src/app.py`
80
- - The tool table in `README.md`
81
- - The tool list in `AGENTS.md`
82
-
83
- When adding a new KV scope, also update:
84
- - The `KV` class in `src/functions.py`
85
- - The scope table in `AGENTS.md`
86
-
87
- ## Good first contributions
88
-
89
- - Add pytest test coverage for `src/functions.py`
90
- - Add a hook script for a new agent (see `INSTALL_FOR_AGENTS.md`)
91
- - Add support for an additional embedding provider (OpenAI, Cohere, local)
92
- - Improve error messages in the viewer
93
- - Add a language-specific README to `READMEs/`
94
-
95
- ## Questions?
96
-
97
- Open an issue or start a discussion. The project is small enough that a quick question is usually faster than reading all the code.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
EPIC.md DELETED
@@ -1,134 +0,0 @@
1
- # Epic: Enterprise-Grade Memory, Context Ingestion, & Database Scaling for `agentcache`
2
-
3
- This document outlines the product epic for transforming `agentcache` into an industry-leading, production-grade memory server for AI coding agents. It covers database scaling, zero-config onboarding, cognitive pruning, observability, and team-based memory synchronization.
4
-
5
- ---
6
-
7
- ```mermaid
8
- graph TD
9
- A[Epic: Enterprise Memory Server] --> B[Pillar 1: Storage & Vector Hardening]
10
- A --> C[Pillar 2: Zero-Config Bootstrapper & SDKs]
11
- A --> D[Pillar 3: Memory Decay & Cognitive Pruning]
12
- A --> E[Pillar 4: Time-Travel Debugger & Replay]
13
- A --> F[Pillar 5: Graph-Augmented Retrieval & Docs]
14
- A --> G[Pillar 6: Enterprise Observability & RBAC]
15
- A --> H[Pillar 7: Git-Backed Team Memory Sync]
16
-
17
- style A fill:#0F172A,stroke:#334155,color:#fff
18
- style B fill:#0369A1,stroke:#1E293B,color:#fff
19
- style C fill:#0369A1,stroke:#1E293B,color:#fff
20
- style D fill:#0369A1,stroke:#1E293B,color:#fff
21
- style E fill:#0F766E,stroke:#1E293B,color:#fff
22
- style F fill:#0F766E,stroke:#1E293B,color:#fff
23
- style G fill:#B91C1C,stroke:#1E293B,color:#fff
24
- style H fill:#6B21A8,stroke:#1E293B,color:#fff
25
- ```
26
-
27
- ---
28
-
29
- ## Pillar 1: Core Datastore & Vector Hardening (Pluggable Storage)
30
- To run in production with millions of logs and observations, the core storage and vector indices must scale beyond a single SQLite file and in-memory list arrays.
31
-
32
- ### 1. Storage Layer Interface (`BaseStorage`)
33
- Abstract all database key-value operations behind a unified repository interface:
34
- * **Interface Definition:** Abstract operations `get`, `set`, `delete`, `list`, and `commit`.
35
- * **Swappable Backends:**
36
- - `SQLiteStorage`: Optimized default backend featuring tuned WAL and memory-mapped pragmas.
37
- - `PostgreSQLStorage`: Scalable production backend storing scope data inside `JSONB` columns with GIN indexing.
38
- - `RedisStorage`: High-speed memory storage for volatile and ephemeral caching environments.
39
-
40
- ### 2. Out-of-Process Vector Indexing (`BaseVectorIndex`)
41
- Move beyond holding float32 list arrays in Python process memory, which bloats and slows search queries over time.
42
- * **Interface Definition:** Abstract vector insertion, eviction, and cosine similarity query runs.
43
- * **Swappable Backends:**
44
- - `InMemoryVectorIndex`: Flat-list memory storage (default).
45
- - `QdrantVectorIndex` / `ChromaVectorIndex`: Offloads embedding storage and spatial indexing to external, specialized vector database services, enabling sub-10ms hybrid search queries.
46
-
47
- ---
48
-
49
- ## Pillar 2: Zero-Config Context Ingestion & Client SDKs
50
- Minimize developer friction by automating prompt context bootstrap and exposing clean programming clients.
51
-
52
- ### 1. Auto-Context Bootstrapper (`agentcache bootstrap`)
53
- * **The Problem:** Coding agents have to waste token limits and execution time calling MCP tools like `memory_recall` at startup just to figure out "what was I doing here?".
54
- * **The Solution:** A background directory watcher writes the latest active tasks, recent lessons, and pinned slots to a local `.agentcache_context.md` file in the project.
55
- * **Execution:** Since agents (Cursor, Cline, Windsurf) automatically read local files on boot, context is injected into their initial system prompt automatically, saving token overhead.
56
-
57
- ### 2. Client SDK Packages
58
- * **Python SDK (`agentcache-client`):** Programmatic async client wrappers:
59
- ```python
60
- from agentcache import AgentCacheClient
61
- client = AgentCacheClient(url="http://localhost:3111", token="...")
62
- client.observe(folder="./src", agent="coder", text="Refactored modules")
63
- ```
64
- * **TypeScript SDK (`@agentcache/client`):** Native Node.js package to simplify integrations inside VS Code extensions and JavaScript agent scripts.
65
-
66
- ---
67
-
68
- ## Pillar 3: Memory Decay & Cognitive Pruning (Noise Erasure)
69
- AI agents generate vast volumes of raw tool execution logs. Without pruning, search results become polluted with transient noise, inflating context sizes and costs.
70
-
71
- ### 1. Time-To-Live (TTL) on Transient Data
72
- * Tag incoming logs with TTLs. EPhemeral warnings, intermediate compiler failures, and temporary shell outputs are deleted automatically after a short duration (e.g. 2 hours).
73
- * If a "build passed" or "test successful" observation is logged, previous compiler errors in that folder are immediately deleted.
74
-
75
- ### 2. Semantic Compression (Episode Crystallization)
76
- * Once a folder pair reaches a threshold of observations, run a background LLM consolidation sweep.
77
- * Compress those observations into high-level semantic facts (e.g., "Resolved circular imports in auth.py by using lazy imports").
78
- * Store the consolidated summaries as permanent memories and evict the underlying raw log observations.
79
-
80
- ---
81
-
82
- ## Pillar 4: Time-Travel Debugger & Interactive Trace Replay
83
- Provide developer visibility and trace debugging controls for agent loops and mental states.
84
-
85
- ### 1. Interactive Trace Replay
86
- * A debugger screen in the HTML dashboard allowing developers to step forward or backward through each event in an agent's history.
87
- * **Cognitive Diffs:** Side-by-side visualization showing file changes, prompt context, tool outcomes, and memory states at each execution step.
88
- * **Mental Model Correction:** Allow developers to edit or inject memories mid-run, correcting the agent's assumptions before resuming execution.
89
-
90
- ---
91
-
92
- ## Pillar 5: Graph-Augmented Retrieval (GRAG) & Auto-Documentation
93
- Combine vector similarity with topological relations to improve query relevance and developer documentation.
94
-
95
- ### 1. Topological Search Expansion
96
- * Vector similarity only matches text similarity. Codebases are topological (e.g., `UserAuth` calls `db.py`, which is loaded by `routes/auth.py`).
97
- * Traverse Knowledge Graph relations to pull adjacent files, parent folders, and concept associations into search results, giving the agent a structural map of the codebase.
98
-
99
- ### 2. Auto-Documentation Generator (`memory_crystalize_docs`)
100
- * An MCP tool and API endpoint that reads the consolidated semantic and procedural memories of all agent runs.
101
- * Automatically compiles them into structured developer documentation (e.g., `ARCHITECTURE.md` or `DEVELOPER_GUIDE.md`), explaining workarounds and design decisions.
102
-
103
- ---
104
-
105
- ## Pillar 6: Enterprise Observability & Multi-Token RBAC Security
106
- Prepare `agentcache` for enterprise networks and cloud environments through secure and monitored interfaces.
107
-
108
- ### 1. Multi-Token Role-Based Access Control (RBAC)
109
- * Implement timing-safe HMAC verification against multiple client tokens.
110
- * Enforce access privileges:
111
- - `Viewer Token`: Read-only access to HTML dashboard.
112
- - `Agent Token`: Scoped read-write access to specific folder namespaces.
113
- - `Admin Token`: Full control over migrations, settings, and database purges.
114
-
115
- ### 2. Operations Telemetry
116
- * **Structured JSON Logging:** Replace raw standard prints with standard python `logging` outputting JSON, allowing simple ingestion by log aggregators (Splunk, ELK, Datadog).
117
- * **Prometheus Metrics:** Expose `/metrics` containing:
118
- - Active WebSocket client counts.
119
- - SQLite WAL size and connection pool details.
120
- - Execution latencies for BM25, Vector, and Hybrid search runs.
121
-
122
- ---
123
-
124
- ## Pillar 7: Git-Backed Team Memory Synchronization
125
- Enable developer teams to share agent learnings using existing Git repository workflows.
126
-
127
- ### 1. Repository-Level Snapshots
128
- * A CLI command `agentcache export --format=db --type=semantic` that compiles and outputs a highly compressed SQLite snapshot containing only semantic/procedural memories.
129
- * Store this snapshot under `.agentcache/project_memories.db` in the repository.
130
-
131
- ### 2. Git Hook Automation
132
- * **Pre-commit hook:** Automatically triggers memory consolidation and commits the updated lightweight snapshot.
133
- * **Post-pull hook:** Merges the incoming memory snapshot into the developer's local `agentcache` SQLite database.
134
- * **Result:** Every developer on the team benefits from the collective intelligence of all agents running in the repository.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
GOVERNANCE.md DELETED
@@ -1,88 +0,0 @@
1
- # Governance
2
-
3
- This document describes how decisions are made in the agentmemory project.
4
-
5
- The model here is a near-copy of the [Linux Foundation Minimum Viable Governance (MVG)](https://github.com/todogroup/ospolog/blob/main/governance/minimum-viable-governance.md) pattern, scoped to the project's current single-maintainer reality with a concrete plan to diversify maintainership over the next two release cycles.
6
-
7
- ## Mission
8
-
9
- Ship a persistent, local-first memory runtime for AI coding agents that:
10
-
11
- - Requires zero external databases.
12
- - Runs under any MCP-compatible client.
13
- - Stays compatible with the open [Model Context Protocol](https://modelcontextprotocol.io).
14
- - Keeps every user's data on the user's machine by default.
15
-
16
- ## Roles
17
-
18
- ### Users
19
-
20
- Anyone who runs agentmemory. No process obligation beyond the license. Feedback via [GitHub issues](https://github.com/rohitg00/agentmemory/issues) and [discussions](https://github.com/rohitg00/agentmemory/discussions) is the input channel.
21
-
22
- ### Contributors
23
-
24
- Anyone who opens an issue, comments on an issue, opens a pull request, or otherwise helps the project. See [CONTRIBUTING.md](./CONTRIBUTING.md) for the how-to.
25
-
26
- ### Maintainers
27
-
28
- A Maintainer has commit access to the repository, responsibility for reviewing PRs, and a vote on project-level decisions. The current list is tracked in [MAINTAINERS.md](./MAINTAINERS.md).
29
-
30
- A Maintainer is expected to:
31
-
32
- - Respond to PRs they are review-owner for within a reasonable window (goal: 3 working days for first comment).
33
- - Uphold the [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
34
- - Avoid merging their own non-trivial PRs without a second reviewer once the maintainer count is greater than one.
35
- - Disclose conflicts of interest (employer, paid relationships to users).
36
-
37
- ### Maintainer acceptance process
38
-
39
- A Contributor becomes a Maintainer by:
40
-
41
- 1. Sustained, high-signal contributions over the prior 6 months (multiple merged PRs across more than one subsystem, plus review comments on others' PRs).
42
- 2. A Maintainer nominates the Contributor in a public PR editing `MAINTAINERS.md`.
43
- 3. The PR stays open for 7 calendar days to collect objections.
44
- 4. If no standing objection from an existing Maintainer, the PR merges and the new Maintainer is added.
45
-
46
- A Maintainer steps down by opening a PR that moves their entry to the `Emeritus` section. This is always accepted.
47
-
48
- ## Decision-making
49
-
50
- ### Default: lazy consensus on PRs
51
-
52
- Most decisions happen inside pull requests. A PR merges when any Maintainer approves it and no other Maintainer blocks it. Silence is assent after 72 hours of no objection.
53
-
54
- ### Non-PR decisions
55
-
56
- Anything that is not a normal code change — charter changes, governance edits, maintainer additions/removals, project scope, breaking API changes, relicensing — happens in a GitHub Issue labeled `governance` with a proposal in the first comment.
57
-
58
- - Minor scope decisions: rough consensus in the issue thread, captured by a Maintainer in a summary comment.
59
- - Formal votes: Maintainers react `+1` / `-1` / `0` to the summary comment. Simple majority of Maintainers with a minimum of two distinct voters carries. If only one Maintainer exists, a 7-day public comment window substitutes for a vote.
60
-
61
- ### Breaking changes
62
-
63
- A breaking change to the REST / MCP surface requires:
64
-
65
- 1. A tracking issue labeled `breaking` opened at least one minor release cycle ahead of the change.
66
- 2. A deprecation path in the codebase (warning log, feature flag, or adapter) for at least one minor release.
67
- 3. The change landing in the CHANGELOG under a clearly marked `Breaking` sub-section.
68
-
69
- ## Release process
70
-
71
- Releases follow [Semantic Versioning](https://semver.org). See the [release process](./CONTRIBUTING.md#release-process) in `CONTRIBUTING.md` and the automated `.github/workflows/publish.yml` pipeline for the mechanics.
72
-
73
- ## Conflicts of interest
74
-
75
- Maintainers employed by a company that sells a product competing with agentmemory, or by a company whose business depends on agentmemory's roadmap, should disclose that relationship in `MAINTAINERS.md` next to their name. Nothing prohibits such maintainership; transparency is the requirement.
76
-
77
- ## Amending this document
78
-
79
- This document changes by PR. Edits follow the Non-PR decisions path above: open a `governance` issue, collect feedback, then open the PR citing the issue.
80
-
81
- ## Related documents
82
-
83
- - [LICENSE](./LICENSE) — Apache-2.0
84
- - [CONTRIBUTING.md](./CONTRIBUTING.md) — how to contribute
85
- - [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) — community behavior
86
- - [SECURITY.md](./SECURITY.md) — how to report a vulnerability
87
- - [MAINTAINERS.md](./MAINTAINERS.md) — who has commit access
88
- - [ROADMAP.md](./ROADMAP.md) — where the project is heading
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
INSTALL_FOR_AGENTS.md DELETED
@@ -1,237 +0,0 @@
1
- # Install agentcache-python (agent runbook)
2
-
3
- You are a coding agent. Follow this runbook top to bottom to install agentcache-python, wire it into yourself, and verify that persistent memory works. Run each command, check the result against the "Expect" note, then move on.
4
-
5
- ## What you are installing
6
-
7
- agentcache-python is a local memory server for coding agents. It runs on your machine, exposes a REST API on port 3111 and an MCP endpoint, and stores all memories in a single SQLite file at `~/.agentcache/agentcache.db`. It is built with Python and Flask — no Node.js, no external database, no daemon to manage separately.
8
-
9
- Default mode works with no API key. It runs BM25 keyword search out of the box. Set `GEMINI_API_KEY` to also enable vector semantic search.
10
-
11
- ## Prerequisites
12
-
13
- - Python 3.10 or newer. Check with `python --version` or `python3 --version`.
14
- - pip. Check with `pip --version`.
15
- - Port 3111 free. If taken, set `III_REST_PORT=<other>` in `~/.agentcache/.env`.
16
-
17
- ## 1. Clone the repo
18
-
19
- ```bash
20
- git clone https://github.com/Yashwant00CR7/agentcache.git
21
- cd agentcache
22
- ```
23
-
24
- Expect: the directory exists with `src/app.py` inside.
25
-
26
- ## 2. Install dependencies
27
-
28
- ```bash
29
- pip install -r requirements.txt
30
- ```
31
-
32
- This installs: flask, flask-sock, requests, websockets, python-dateutil, huggingface_hub.
33
-
34
- Expect: install completes without errors.
35
-
36
- ## 3. Start the server
37
-
38
- ```bash
39
- python src/app.py &
40
- ```
41
-
42
- Or run in a separate terminal: `python src/app.py`
43
-
44
- Wait until it is reachable:
45
-
46
- ```bash
47
- curl -fsS http://localhost:3111/agentcache/livez
48
- ```
49
-
50
- Expect: `{"status": "ok"}`. On first run the BM25 index initializes in the background; this takes under a second.
51
-
52
- ## 4. Prove save and recall works
53
-
54
- ```bash
55
- # Save a memory
56
- curl -X POST http://localhost:3111/agentcache/remember \
57
- -H "Content-Type: application/json" \
58
- -d '{"content":"agentcache-python install verification probe","concepts":["install-check"]}'
59
-
60
- # Recall it
61
- curl -X POST http://localhost:3111/agentcache/search \
62
- -H "Content-Type: application/json" \
63
- -d '{"query":"install verification probe","limit":5}'
64
- ```
65
-
66
- Expect: first call returns `{"id": "...", "success": true}`, second returns results containing the probe memory.
67
-
68
- ## 5. Wire MCP into the calling agent
69
-
70
- Detect which agent is running this runbook, then add agentcache-python to its MCP config.
71
-
72
- ### Standard MCP block (Cursor, Claude Desktop, Cline, Windsurf, Gemini CLI)
73
-
74
- Merge this into the agent's `mcpServers` object:
75
-
76
- ```json
77
- "agentcache": {
78
- "command": "npx",
79
- "args": ["-y", "@agentcache/mcp"],
80
- "env": {
81
- "AGENTCACHE_URL": "http://localhost:3111"
82
- }
83
- }
84
- ```
85
-
86
- ### Claude Code
87
-
88
- Add to `~/.claude.json` under `mcpServers`:
89
-
90
- ```json
91
- "agentcache": {
92
- "command": "npx",
93
- "args": ["-y", "@agentcache/mcp"],
94
- "env": {
95
- "AGENTCACHE_URL": "http://localhost:3111"
96
- }
97
- }
98
- ```
99
-
100
- Then reload MCP: run `/mcp` in Claude Code.
101
-
102
- ### Any agent — verify tool count
103
-
104
- After wiring, the agent should list agentcache's tools. With the server running you should see 16 tools (e.g. `memory_save`, `memory_smart_search`, `memory_sessions`).
105
-
106
- If you see 0 tools or an error, check that `python src/app.py` is running and `AGENTCACHE_URL` points at it.
107
-
108
- ## 6. Setting up agent hooks
109
-
110
- Agent hooks post observations to agentcache automatically on every tool use, command, or edit — no manual calls required. Hook scripts live in the [`hooks/`](hooks/) directory.
111
-
112
- ### Claude Code (`hooks/claude-code-hook.sh`)
113
-
114
- Add a `PostToolUse` hook to `.claude/settings.json`. The hook script reads `AGENTCACHE_URL` and `AGENTCACHE_SECRET` from your shell environment, so no secrets are embedded in the config file.
115
-
116
- ```json
117
- {
118
- "hooks": {
119
- "PostToolUse": [
120
- {
121
- "matcher": "*",
122
- "hooks": [
123
- {
124
- "type": "command",
125
- "command": "bash /path/to/hooks/claude-code-hook.sh"
126
- }
127
- ]
128
- }
129
- ]
130
- }
131
- }
132
- ```
133
-
134
- Set the required environment variables before starting Claude Code:
135
-
136
- ```bash
137
- export AGENTCACHE_URL=http://127.0.0.1:3111
138
- export AGENTCACHE_SECRET=your-secret-here # omit if no auth set
139
- ```
140
-
141
- The script picks up `$PWD` as `folderPath` and `$CLAUDE_AGENT_ID` (falling back to `"claude-code"`) as `agentId`.
142
-
143
- ### Cursor (`hooks/cursor-hook.js`)
144
-
145
- Require the hook from your `.cursorrules` file (or any JS entry point Cursor runs) and call `logObservation()` with the tool name and input:
146
-
147
- ```js
148
- const { logObservation } = require('/path/to/hooks/cursor-hook.js');
149
-
150
- // Call inside your Cursor hook handler, e.g. after every tool invocation:
151
- logObservation(`Tool: ${toolName}\nInput: ${JSON.stringify(toolInput)}`);
152
- ```
153
-
154
- The module reads `AGENTCACHE_URL`, `AGENTCACHE_SECRET`, and `AGENTCACHE_AGENT_ID` from `process.env`. Set them in your shell profile or in Cursor's environment settings.
155
-
156
- ### `.env` file format
157
-
158
- All hooks and the server itself read credentials from `~/.agentcache/.env`. Create this file if it doesn't exist:
159
-
160
- ```
161
- III_REST_PORT=3111
162
- AGENTCACHE_SECRET=your-secret-here
163
- GEMINI_API_KEY=your-gemini-key-here
164
- ```
165
-
166
- The server loads this file on startup. Hook scripts read the same variables from your shell environment (export them from your profile after sourcing `~/.agentcache/.env`, or use `direnv` / `dotenv` tooling).
167
-
168
- ## 7. Open the viewer (optional)
169
-
170
- ```bash
171
- open http://localhost:3111/viewer
172
- # or on Linux:
173
- xdg-open http://localhost:3111/viewer
174
- # or on Windows:
175
- start http://localhost:3111/viewer
176
- ```
177
-
178
- The viewer shows live sessions, memories, and the knowledge graph.
179
-
180
- ## Optional: enable vector search
181
-
182
- Vector search finds memories semantically, not just by keyword. Enable it with a free Gemini API key:
183
-
184
- ```bash
185
- mkdir -p ~/.agentcache
186
- echo "GEMINI_API_KEY=your-key-here" >> ~/.agentcache/.env
187
- ```
188
-
189
- Restart the server after adding the key. The viewer's search bar will now use hybrid BM25 + vector retrieval.
190
-
191
- ## Optional: enable LLM compression
192
-
193
- LLM compression makes each observation richer and more searchable. Requires an LLM API key:
194
-
195
- ```bash
196
- # Add to ~/.agentcache/.env
197
- ANTHROPIC_API_KEY=your-key # or OPENAI_API_KEY or GEMINI_API_KEY
198
- AGENTCACHE_AUTO_COMPRESS=true
199
- ```
200
-
201
- ## Lifecycle
202
-
203
- ```bash
204
- # Stop the server (find and kill the process)
205
- pkill -f "python src/app.py"
206
-
207
- # Check what's stored
208
- curl http://localhost:3111/agentcache/sessions
209
- curl http://localhost:3111/agentcache/memories
210
-
211
- # Health check
212
- curl http://localhost:3111/agentcache/livez
213
- ```
214
-
215
- ## Troubleshooting
216
-
217
- | Symptom | Fix |
218
- |---------|-----|
219
- | `ModuleNotFoundError: No module named 'flask'` | Run `pip install -r requirements.txt` |
220
- | `Address already in use` on port 3111 | Set `III_REST_PORT=3112` in `~/.agentcache/.env` and restart |
221
- | `/livez` never returns | Check `python src/app.py` stderr for import errors |
222
- | 0 tools in agent | Confirm `AGENTCACHE_URL=http://localhost:3111` and the server is running |
223
- | `401 Unauthorized` | Set `AGENTCACHE_SECRET` env var in the MCP config to match `~/.agentcache/.env` |
224
- | Vector search not working | Add `GEMINI_API_KEY` to `~/.agentcache/.env` and restart |
225
- | Windows Python path issue | Use `python3` instead of `python`, or use WSL2 |
226
-
227
- ## Report success
228
-
229
- Report back:
230
-
231
- - agentcache-python server running on port 3111
232
- - MCP wired into the agent, tool count visible
233
- - Save and recall round-trip returned the probe memory
234
- - Viewer available at http://localhost:3111/viewer
235
- - Any optional features enabled (vector search, LLM compression)
236
-
237
- If any step failed, report the step, exact command, and error output.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MAINTAINERS.md DELETED
@@ -1,21 +0,0 @@
1
- # Maintainers
2
-
3
- The authoritative list of people with commit access. See [GOVERNANCE.md](./GOVERNANCE.md) for what a Maintainer is, what they do, and how someone becomes one.
4
-
5
- ## Active
6
-
7
- | Name | GitHub | Affiliation | Area of focus | Since |
8
- |-|-|-|-|-|
9
- | Rohit Ghumare | [@rohitg00](https://github.com/rohitg00) | Independent | Project lead, all subsystems | 2026-01 |
10
-
11
- ## Emeritus
12
-
13
- _None yet._
14
-
15
- ## Maintainer recruitment
16
-
17
- agentmemory is actively looking to diversify maintainership. The growth plan in [ROADMAP.md](./ROADMAP.md) commits to adding at least one additional Maintainer from a different organization by the end of the current growth cycle.
18
-
19
- If you have a sustained contribution track record and would like to be considered, open an issue tagged `governance`.
20
-
21
- The complete contributor graph, with commit counts and recent activity, lives at <https://github.com/rohitg00/agentmemory/graphs/contributors>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md DELETED
@@ -1,482 +0,0 @@
1
- ---
2
- title: AgentCache Python
3
- emoji: 🧠
4
- colorFrom: blue
5
- colorTo: indigo
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- <h1 align="center">agentcache-python</h1>
11
-
12
- <p align="center">
13
- <strong>Persistent memory for AI coding agents — pure Python, zero external databases.</strong><br/>
14
- Works with Claude Code, Cursor, Cline, Windsurf, Gemini CLI, and any MCP client.
15
- </p>
16
-
17
- <p align="center">
18
- <img src="https://img.shields.io/badge/Python-3.10%2B-3776AB?style=for-the-badge&logo=python&logoColor=white" alt="Python 3.10+" />
19
- <img src="https://img.shields.io/badge/SQLite-WAL-003B57?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite WAL" />
20
- <img src="https://img.shields.io/badge/Flask-3.0-000000?style=for-the-badge&logo=flask&logoColor=white" alt="Flask 3.0" />
21
- <img src="https://img.shields.io/badge/MCP-Compatible-6B21A8?style=for-the-badge" alt="MCP Compatible" />
22
- <img src="https://img.shields.io/badge/HuggingFace-Space-FF9D00?style=for-the-badge&logo=huggingface&logoColor=white" alt="HuggingFace Space" />
23
- </p>
24
-
25
- <p align="center">
26
- <a href="#quick-start">Quick Start</a> &bull;
27
- <a href="#features">Features</a> &bull;
28
- <a href="#mcp-integration">MCP</a> &bull;
29
- <a href="#api-reference">API</a> &bull;
30
- <a href="#configuration">Config</a> &bull;
31
- <a href="#deploy-to-huggingface">Deploy</a> &bull;
32
- <a href="#viewer">Viewer</a> &bull;
33
- <a href="#architecture">Architecture</a>
34
- </p>
35
-
36
- ---
37
-
38
- ## What Is This?
39
-
40
- **agentcache-python** is a Python reimplementation of the [agentcache](https://github.com/rohitg00/agentcache) persistent memory server. It exposes a REST API, WebSocket stream, and MCP tools endpoint that AI coding agents use to store and retrieve session observations, long-term memories, lessons, and pinned memory slots.
41
-
42
- Key differences from the Node.js original:
43
-
44
- - **No Node.js or iii-engine** — runs with plain `python src/app.py`
45
- - **SQLite instead of Dolt** — single file, WAL mode, instant startup
46
- - **HuggingFace Space ready** — deploys in one click, data synced to an HF dataset repo
47
- - **Same REST + MCP wire format** — drop-in for any agent already wired to agentcache
48
-
49
- Your agent captures every tool call, stores them as observations, compresses them into searchable memory, and injects the right context at the start of every new session — automatically.
50
-
51
- ---
52
-
53
- ## Quick Start
54
-
55
- ### Run locally
56
-
57
- ```bash
58
- # Clone
59
- git clone https://github.com/Yashwant00CR7/agentcache.git
60
- cd agentcache
61
-
62
- # Install dependencies (no build step)
63
- pip install -r requirements.txt
64
-
65
- # Start the server
66
- python src/app.py
67
- ```
68
-
69
- Server starts on **http://localhost:3111**. Open the viewer at http://localhost:3111/viewer.
70
-
71
- ### Verify it works
72
-
73
- ```bash
74
- # Health check
75
- curl http://localhost:3111/agentcache/livez
76
- # {"status": "ok"}
77
-
78
- # Save a memory
79
- curl -X POST http://localhost:3111/agentcache/remember \
80
- -H "Content-Type: application/json" \
81
- -d '{"content": "JWT auth uses jose middleware in src/middleware/auth.ts", "concepts": ["auth", "jwt"]}'
82
-
83
- # Recall it
84
- curl -X POST http://localhost:3111/agentcache/search \
85
- -H "Content-Type: application/json" \
86
- -d '{"query": "authentication middleware", "limit": 5}'
87
- ```
88
-
89
- ---
90
-
91
- ## Features
92
-
93
- | Feature | Status | Notes |
94
- |---------|--------|-------|
95
- | REST API — sessions, memories, observations | ✅ | Full surface |
96
- | WebSocket live stream | ✅ | `/stream/mem-live/viewer` |
97
- | MCP tools endpoint | ✅ | 31 tools |
98
- | Built-in HTML viewer | ✅ | Real-time dashboard at `/viewer` |
99
- | BM25 keyword search | ✅ | Always on, no API key needed |
100
- | Hybrid BM25 + vector search | ✅ | Requires `GEMINI_API_KEY` |
101
- | 4-tier memory consolidation | ⚙️ | `CONSOLIDATION_ENABLED=true` + LLM key |
102
- | Knowledge graph extraction | ⚙️ | `GRAPH_EXTRACTION_ENABLED=true` + LLM key |
103
- | LLM observation compression | ⚙️ | `AGENTCACHE_AUTO_COMPRESS=true` + LLM key |
104
- | Lessons with confidence decay | ✅ | Fingerprinted, auto-strengthen on repeat |
105
- | Memory slots (pinned context) | ✅ | CRUD + auto-reflect |
106
- | Session replay | ✅ | Full timeline in viewer |
107
- | Audit log | ✅ | Tracks every write with agent_id + timestamp |
108
- | HuggingFace Space deploy | ✅ | One-click, data synced to dataset repo |
109
- | Privacy filtering | ✅ | Strips API keys, tokens before storage |
110
-
111
- ### 4-Tier Memory Model
112
-
113
- Inspired by how human memory works — raw experience → compressed episodes → extracted facts → learned patterns.
114
-
115
- | Tier | What | When |
116
- |------|------|------|
117
- | **Working** | Raw observations from tool use | Every tool call |
118
- | **Episodic** | Compressed session summaries | Session end |
119
- | **Semantic** | Extracted facts and patterns | Consolidation |
120
- | **Procedural** | Workflows and decision patterns | Consolidation |
121
-
122
- ---
123
-
124
- ## MCP Integration
125
-
126
- Wire agentcache-python into your agent's MCP config. It speaks the same MCP protocol as the Node.js original.
127
-
128
- ### Most agents (Cursor, Claude Desktop, Cline, Windsurf)
129
-
130
- ```json
131
- {
132
- "mcpServers": {
133
- "agentcache": {
134
- "command": "npx",
135
- "args": ["-y", "@agentcache/mcp"],
136
- "env": {
137
- "AGENTCACHE_URL": "http://localhost:3111"
138
- }
139
- }
140
- }
141
- }
142
- ```
143
-
144
- ### Claude Code
145
-
146
- Paste this prompt and your agent will wire everything:
147
-
148
- ```
149
- Start agentcache-python: run `python src/app.py` from the agentcache-python directory.
150
- Then add this MCP server to ~/.claude.json under mcpServers:
151
- {
152
- "agentcache": {
153
- "command": "npx",
154
- "args": ["-y", "@agentcache/mcp"],
155
- "env": { "AGENTCACHE_URL": "http://localhost:3111" }
156
- }
157
- }
158
- Verify with: curl http://localhost:3111/agentcache/livez
159
- Open the viewer at: http://localhost:3111/viewer
160
- ```
161
-
162
- ### Available MCP Tools (31)
163
-
164
- | Tool | Description |
165
- |------|-------------|
166
- | `memory_save` | Save a long-term insight, decision, or pattern |
167
- | `memory_recall` | Search past observations by keyword |
168
- | `memory_smart_search` | Hybrid BM25 + vector semantic search |
169
- | `memory_sessions` | List recent sessions |
170
- | `memory_sessions_list` | Retrieve all memory sessions |
171
- | `memory_timeline` | Chronological observations for a session |
172
- | `memory_observations` | Observations for a session |
173
- | `memory_profile` | Per-project concept + file profile |
174
- | `memory_lessons` | List active lessons with confidence scores |
175
- | `memory_lesson_save` | Save a lesson (duplicate saves strengthen it) |
176
- | `memory_lesson_recall` | Search lessons by query |
177
- | `memory_lesson_search` | Search lessons by keywords |
178
- | `memory_consolidate` | Run 4-tier memory consolidation |
179
- | `memory_reflect` | Reflect on session, update context |
180
- | `memory_diagnose` | Health check across all subsystems |
181
- | `memory_forget` | Delete memory, session, or observations |
182
- | `memory_export` | Export all memory data as JSON |
183
- | `agent_observe` | Log agent execution observation |
184
- | `agent_remember` | Save agent cache to long-term storage |
185
- | `memory_antigravity_sync` | Sync Antigravity transcripts to memory |
186
- | `memory_antigravity_sync_all` | Master sync: transcript + crystallize + reflect |
187
- | `memory_slot_list` | List all pinned memory slots |
188
- | `memory_slot_get` | Retrieve a specific pinned memory slot |
189
- | `memory_slot_create` | Create/overwrite a pinned memory slot |
190
- | `memory_slot_append` | Append text content to a pinned memory slot |
191
- | `memory_slot_replace` | Replace pinned memory slot content |
192
- | `memory_slot_delete` | Delete a pinned memory slot |
193
- | `memory_action_create` | Create a new work item / action |
194
- | `memory_action_update` | Update fields of an existing action |
195
- | `memory_frontier` | Get active and pending actions sorted by priority |
196
- | `memory_crystallize` | Crystallize/summarize observations in a session |
197
-
198
- ---
199
-
200
- ## API Reference
201
-
202
- Base URL: `http://localhost:3111/agentcache`
203
-
204
- ### Health
205
-
206
- | Method | Path | Description |
207
- |--------|------|-------------|
208
- | `GET` | `/livez` | Liveness probe — no auth required |
209
-
210
- ### Sessions
211
-
212
- | Method | Path | Description |
213
- |--------|------|-------------|
214
- | `POST` | `/session/start` | Start a new session |
215
- | `POST` | `/session/end` | End a session |
216
- | `POST` | `/session/commit` | Commit session with summary |
217
- | `GET` | `/sessions` | List all sessions |
218
-
219
- ### Observations
220
-
221
- | Method | Path | Description |
222
- |--------|------|-------------|
223
- | `POST` | `/observe` | Ingest a hook event observation |
224
- | `POST` | `/agent/observe` | Simplified observe for direct agent use |
225
- | `GET` | `/observations` | List observations (`?session_id=`) |
226
- | `POST` | `/timeline` | Chronological observation window |
227
-
228
- ### Memories
229
-
230
- | Method | Path | Description |
231
- |--------|------|-------------|
232
- | `POST` | `/remember` | Save long-term memory |
233
- | `POST` | `/agent/remember` | Simplified remember |
234
- | `POST` | `/forget` | Delete memory / session / observations |
235
- | `POST` | `/search` | BM25 + vector search |
236
- | `POST` | `/context` | Compile context for a session + project |
237
- | `GET` | `/memories` | List memories (`?latest=true&limit=N`) |
238
- | `POST` | `/evolve` | Create a new memory version |
239
-
240
- ### Lessons
241
-
242
- | Method | Path | Description |
243
- |--------|------|-------------|
244
- | `GET` | `/lessons` | List lessons |
245
- | `POST` | `/lessons` | Create lesson |
246
- | `POST` | `/lessons/search` | Search lessons |
247
- | `POST` | `/lessons/strengthen` | Reinforce an existing lesson |
248
-
249
- ### Slots
250
-
251
- | Method | Path | Description |
252
- |--------|------|-------------|
253
- | `GET` | `/slots` | List all pinned slots |
254
- | `POST` | `/slot` | Create or update a slot |
255
- | `GET` | `/slot` | Get slot by name |
256
- | `DELETE` | `/slot` | Delete a slot |
257
- | `POST` | `/slot/reflect` | Auto-populate from session observations |
258
-
259
- ### Graph + Profile
260
-
261
- | Method | Path | Description |
262
- |--------|------|-------------|
263
- | `GET` | `/relations` | Knowledge graph edges |
264
- | `POST` | `/relations` | Add a relation |
265
- | `GET` | `/profile` | Project profile (top concepts, files) |
266
-
267
- ### Actions
268
-
269
- | Method | Path | Description |
270
- |--------|------|-------------|
271
- | `GET` | `/actions` | List actions |
272
- | `POST` | `/actions` | Create an action |
273
- | `PATCH` | `/actions/<id>` | Update action status / fields |
274
- | `GET` | `/frontier` | Pending actions sorted by priority |
275
- | `GET` | `/insights` | List insights |
276
-
277
- ### Replay
278
-
279
- | Method | Path | Description |
280
- |--------|------|-------------|
281
- | `GET` | `/replay/sessions` | Sessions list for replay tab |
282
- | `GET` | `/replay/load` | Full session + observations (`?sessionId=`) |
283
-
284
- ### MCP
285
-
286
- | Method | Path | Description |
287
- |--------|------|-------------|
288
- | `GET` | `/mcp/tools` | MCP tool schema list |
289
- | `POST` | `/mcp/tools` | MCP tool call dispatch |
290
-
291
- ---
292
-
293
- ## Configuration
294
-
295
- Create `~/.agentcache/.env` (no `export` prefix needed):
296
-
297
- ```env
298
- # Server port
299
- III_REST_PORT=3111
300
-
301
- # Vector search — enables Gemini 768-dim embeddings
302
- GEMINI_API_KEY=your-gemini-key
303
-
304
- # LLM for compression / consolidation / graph extraction
305
- # Any one of these enables LLM features:
306
- ANTHROPIC_API_KEY=your-anthropic-key
307
- # OPENAI_API_KEY=your-openai-key
308
- # GEMINI_API_KEY=your-key (same key as above works for both)
309
-
310
- # LLM-powered features (disabled by default — spend tokens)
311
- CONSOLIDATION_ENABLED=true
312
- GRAPH_EXTRACTION_ENABLED=true
313
- AGENTCACHE_AUTO_COMPRESS=true
314
-
315
- # Context injection limits
316
- TOKEN_BUDGET=2000
317
- MAX_OBS_PER_SESSION=500
318
-
319
- # Auth — set to require Bearer token on all endpoints
320
- AGENTCACHE_SECRET=your-secret
321
-
322
- # Agent scope isolation
323
- AGENT_ID=my-agent
324
- AGENTCACHE_AGENT_SCOPE=isolated # only see this agent's data
325
-
326
- # HuggingFace sync
327
- HF_TOKEN=your-hf-token
328
- AGENTCACHE_DATASET_REPO=username/agentcache-data
329
- ```
330
-
331
- ### Full Variable Reference
332
-
333
- | Variable | Default | Purpose |
334
- |----------|---------|---------|
335
- | `III_REST_PORT` / `PORT` | `3111` | API server port |
336
- | `GEMINI_API_KEY` / `GOOGLE_API_KEY` | — | Enables 768-dim vector search |
337
- | `AGENTCACHE_SECRET` | — | Bearer token auth on all endpoints |
338
- | `AGENT_ID` | — | Default agent ID for scope isolation |
339
- | `AGENTCACHE_AGENT_SCOPE=isolated` | — | Filters data to current `AGENT_ID` |
340
- | `MAX_OBS_PER_SESSION` | `500` | Hard cap on observations per session |
341
- | `TOKEN_BUDGET` | `2000` | Max tokens in compiled context |
342
- | `GRAPH_EXTRACTION_ENABLED` | `false` | Knowledge graph (needs LLM) |
343
- | `CONSOLIDATION_ENABLED` | `false` | Memory consolidation (needs LLM) |
344
- | `AGENTCACHE_AUTO_COMPRESS` | `false` | LLM observation compression |
345
-
346
- ---
347
-
348
- ## Viewer
349
-
350
- Built-in dashboard at **http://localhost:3111/viewer**.
351
-
352
- | Tab | What You See |
353
- |-----|-------------|
354
- | **Dashboard** | Session stats, memory counts, recent activity |
355
- | **Sessions** | Browse sessions, inspect observations |
356
- | **Memories** | Search, filter, and read long-term memories |
357
- | **Graph** | Project folder visualization — nodes = folders, edges = shared concepts or parent path |
358
- | **Timeline** | Per-session chronological observation view |
359
- | **Lessons** | Confidence-scored lessons with decay tracking |
360
- | **Slots** | Pinned memory slots editor |
361
- | **Replay** | Scrub through past sessions frame by frame |
362
-
363
- ---
364
-
365
- ## Deploy to HuggingFace
366
-
367
- This project is designed to run as a HuggingFace Space. Data is stored in an HF dataset repo and restored on every boot — so no persistent disk is needed.
368
-
369
- ### Setup
370
-
371
- 1. Fork this repo as a HuggingFace Space (SDK: Docker)
372
- 2. Create a dataset repo (e.g. `your-username/agentcache-data`)
373
- 3. Add Space secrets in the HF dashboard:
374
-
375
- | Secret | Value |
376
- |--------|-------|
377
- | `HF_TOKEN` | Your HF write token |
378
- | `AGENTCACHE_DATASET_REPO` | `your-username/agentcache-data` |
379
- | `AGENTCACHE_SECRET` | A random secret (optional but recommended) |
380
- | `GEMINI_API_KEY` | Gemini key (optional, enables vector search) |
381
-
382
- 4. The Space boots, restores `agentcache.db` from the dataset repo, and starts the server
383
-
384
- ### How sync works
385
-
386
- `sync.py` uses mtime fingerprinting — it only uploads when the database actually changed, so there are no unnecessary uploads during idle periods.
387
-
388
- ```bash
389
- # Manual backup
390
- python sync.py
391
-
392
- # Environment for sync
393
- HF_TOKEN=...
394
- AGENTCACHE_DATASET_REPO=username/agentcache-data
395
- ```
396
-
397
- ---
398
-
399
- ## Architecture
400
-
401
- ```
402
- agentcache-python/
403
- ├── src/
404
- │ ├── app.py Flask server — all endpoints, WebSocket broadcaster
405
- │ ├── db.py SQLite StateKV — WAL mode, audit_log table
406
- │ ├── functions.py Core logic — observe, remember, search, context
407
- │ ├── search.py BM25 + Gemini vector index + HybridSearch (RRF)
408
- │ └── viewer/
409
- │ └── index.html Single-file HTML dashboard (no build step)
410
- ├── sync.py HuggingFace dataset backup/restore
411
- ├── Dockerfile HF Space container
412
- ├── start.sh Boot script (restore → start server → start sync)
413
- └── requirements.txt 6 Python dependencies, no external DB required
414
- ```
415
-
416
- ### Database layout
417
-
418
- Two SQLite tables in `~/.agentcache/agentcache.db`:
419
-
420
- ```sql
421
- -- All data lives here, namespaced by scope
422
- kv_store (
423
- scope TEXT NOT NULL, -- e.g. "mem:sessions", "mem:obs:{session_id}"
424
- key TEXT NOT NULL,
425
- value TEXT NOT NULL, -- JSON-serialized
426
- PRIMARY KEY (scope, key)
427
- )
428
-
429
- -- Audit trail replaces Dolt git versioning
430
- audit_log (
431
- id INTEGER PRIMARY KEY AUTOINCREMENT,
432
- ts INTEGER NOT NULL, -- unix millis
433
- agent_id TEXT NOT NULL,
434
- message TEXT NOT NULL
435
- )
436
- ```
437
-
438
- ### Search pipeline
439
-
440
- ```
441
- Query
442
- → BM25 (always) — Porter-stemmed keyword matching
443
- → Vector (if Gemini key) — 768-dim cosine similarity
444
- → RRF fusion — Reciprocal Rank Fusion (k=60)
445
- → Session diversify — max 3 results per session
446
- → Return top-K
447
- ```
448
-
449
- ---
450
-
451
- ## vs Original agentcache
452
-
453
- | | agentcache (Node.js) | agentcache-python |
454
- |---|---|---|
455
- | Runtime | Node.js 20+ | Python 3.10+ |
456
- | Storage | Dolt SQL (git-versioned MySQL) | SQLite WAL (single file) |
457
- | Engine dependency | iii-engine (separate binary) | None — just Flask |
458
- | Embeddings | 6 providers + local `@xenova/transformers` | Gemini 768-dim |
459
- | MCP tools | 53 | 31 |
460
- | REST endpoints | 128 | ~50 |
461
- | Deploy | npm, Docker, fly.io, Railway, Render | Docker, HuggingFace Spaces |
462
- | Cold boot | ~7s (iii engine warm-up) | <2s |
463
- | Database size | ~232MB (417 Dolt chunk files) | ~20MB (single `.db` file) |
464
- | Setup | `npm install -g @agentcache/agentcache` | `pip install -r requirements.txt` |
465
-
466
- Choose the Python version for: simpler setup, HF Space deployment, single-file database, no Node.js, or Python ecosystem integration.
467
-
468
- Choose the Node.js version for: the full 53-tool MCP surface, iii-engine observability, production multi-agent deployments, or the full auto-hook suite.
469
-
470
- ---
471
-
472
- ## Contributing
473
-
474
- See [CONTRIBUTING.md](CONTRIBUTING.md). Issues and PRs welcome.
475
-
476
- Priority areas: test coverage, additional embedding providers, more agent hook scripts.
477
-
478
- ---
479
-
480
- ## License
481
-
482
- Apache-2.0 — see [LICENSE](LICENSE).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.de-DE.md DELETED
@@ -1,1377 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — Persistentes Gedächtnis für KI-Coding-Agenten" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- Ihr Coding-Agent merkt sich alles. Schluss mit dem ständigen Wiederholen.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Persistentes Gedächtnis für Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode und jeden MCP-Client.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- Deutsch
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design-Dokument: 1200 stars / 172 forks im Gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>Das Gist erweitert Karpathys LLM-Wiki-Muster um Confidence Scoring, Lifecycle, Knowledge Graphs und hybride Suche: agentmemory ist die Implementierung.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory-Demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">Installation</a> &bull;
73
- <a href="#quick-start">Schnellstart</a> &bull;
74
- <a href="#benchmarks">Benchmarks</a> &bull;
75
- <a href="#vs-competitors">Vergleich</a> &bull;
76
- <a href="#works-with-every-agent">Agenten</a> &bull;
77
- <a href="#how-it-works">Funktionsweise</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">Viewer</a> &bull;
80
- <a href="#iii-console">iii Console</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">Konfiguration</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Install
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # start the memory server on :3111
95
- agentmemory demo # seed sample sessions + prove recall
96
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- Oder per `npx` (keine Installation):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- Achtung — npx cached pro Version. Wenn ein nacktes `npx @agentmemory/agentmemory` eine ältere Version liefert, erzwingen Sie die neueste mit `npx -y @agentmemory/agentmemory@latest` oder leeren Sie den Cache einmalig mit `rm -rf ~/.npm/_npx` (macOS/Linux; unter Windows löschen Sie `%LOCALAPPDATA%\npm-cache\_npx`). Der erste npx-Lauf ab v0.9.16+ fordert eine globale Installation inline an, sodass der nackte Befehl `agentmemory` anschließend überall funktioniert.
106
-
107
- Vollständige Optionen unter [Schnellstart](#quick-start). Agenten­spezifische Verdrahtung unter [Funktioniert mit jedem Agenten](#works-with-every-agent).
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funktioniert mit jedem Agenten" height="32" /></picture></h2>
112
-
113
- agentmemory funktioniert mit jedem Agenten, der Hooks, MCP oder REST API unterstützt. Alle Agenten teilen sich denselben Memory-Server.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>natives Plugin + 12 Hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>natives Plugin + 6 Hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>natives Plugin + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>natives Plugin + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>natives Plugin + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>natives Memory-trait-Backend</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP-Server</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP-Server</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 Hooks + MCP + Plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP-Server</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP-Server</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP-Server</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP-Server</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP-Server</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP-Server</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>Funktioniert mit <strong>jedem</strong> Agenten, der MCP oder HTTP spricht. Ein Server, gemeinsame Erinnerungen für alle.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- Sie erklären in jeder Session dieselbe Architektur. Sie entdecken dieselben Bugs erneut. Sie bringen dem Agenten dieselben Präferenzen wieder bei. Eingebautes Gedächtnis (CLAUDE.md, .cursorrules) ist bei 200 Zeilen am Ende und veraltet. agentmemory behebt das. Es erfasst stillschweigend, was Ihr Agent tut, komprimiert das Ganze in durchsuchbares Gedächtnis und injiziert beim Start der nächsten Session den passenden Kontext. Ein Befehl. Funktioniert über Agenten hinweg.
209
-
210
- **Was sich ändert:** Session 1 richten Sie JWT-Authentifizierung ein. Session 2 fragen Sie nach Rate Limiting. Der Agent weiß bereits, dass Ihre Auth jose-Middleware in `src/middleware/auth.ts` verwendet, dass Ihre Tests Token-Validierung abdecken und dass Sie sich aus Gründen der Edge-Kompatibilität für jose statt jsonwebtoken entschieden haben. Kein Wiederholen. Kein Copy-Paste. Der Agent *weiß es einfach*.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **Neu in v0.9.0** — Landing-Site unter [agent-memory.dev](https://agent-memory.dev), Filesystem-Connector (`@agentmemory/fs-watcher`), das standalone MCP proxyt nun zum laufenden Server, sodass Hooks und Viewer übereinstimmen, Audit-Policy auf jedem Delete-Pfad kodifiziert, der Health-Check meldet `memory_critical` nicht mehr bei kleinen Node-Prozessen. Vollständige Hinweise in [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Retrieval-Genauigkeit
227
-
228
- **coding-agent-life-v1** (interner Korpus, Sandbox-reproduzierbar)
229
-
230
- | Adapter | P@5 | R@5 | Top-5-Trefferquote | p50-Latenz |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep-Baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100 % Top-5-Trefferquote. **2,2×** bessere Präzision als die grep-Baseline bei identischer Eingabe. Volle Aufschlüsselung pro Typ: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 Fragen)
238
-
239
- | System | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25-only Fallback | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Token-Einsparungen
248
-
249
- | Ansatz | Tokens/Jahr | Kosten/Jahr |
250
- |---|---|---|
251
- | Vollständigen Kontext einfügen | 19,5M+ | Unmöglich (überschreitet das Fenster) |
252
- | LLM-zusammengefasst | ~650K | ~500 $ |
253
- | **agentmemory** | **~170K** | **~10 $** |
254
- | agentmemory + lokale Embeddings | ~170K | **0 $** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Embedding-Modell: `all-MiniLM-L6-v2` (lokal, kostenlos, kein API-Schlüssel). Vollständige Berichte: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Konkurrenzvergleich: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
-
262
- **Lokal reproduzieren:** [`eval/README.md`](../eval/README.md) — Adapter-pluggable Harness für LongMemEval `_s` (öffentlich, 500 Fragen) + `coding-agent-life-v1` (interner 15-Session-Korpus). Adapter für grep / vector / agentmemory werden direkt verglichen, NDJSON-Ausgabe, veröffentlichte Scorecards landen in [`docs/benchmarks/`](../docs/benchmarks/).
263
-
264
- **Funktioniert kombiniert mit [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) und [Graphify](https://github.com/safishamsi/graphify).** Code-Graph-Indizierung, mehragentige Build-Pipelines und breitere Knowledge Graphs über Docs / PDFs / Bilder / Videos. agentmemory merkt sich die Arbeit; diese drei Projekte beleuchten den Rest der Kontextschicht. Rezepte + Frage-Routing-Tabelle: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Vergleich mit der Konkurrenz" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">Eingebaut (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>Typ</strong></td>
280
- <td>Memory-Engine + MCP-Server</td>
281
- <td>Memory-Layer-API</td>
282
- <td>Komplette Agenten-Runtime</td>
283
- <td>Statische Datei</td>
284
- </tr>
285
- <tr>
286
- <td><strong>Retrieval R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/V (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>Auto-Erfassung</strong></td>
294
- <td>12 Hooks (null manueller Aufwand)</td>
295
- <td>Manuelle <code>add()</code>-Aufrufe</td>
296
- <td>Agent bearbeitet sich selbst</td>
297
- <td>Manuelle Bearbeitung</td>
298
- </tr>
299
- <tr>
300
- <td><strong>Suche</strong></td>
301
- <td>BM25 + Vector + Graph (RRF-Fusion)</td>
302
- <td>Vector + Graph</td>
303
- <td>Vector (Archival)</td>
304
- <td>Lädt alles in den Kontext</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Multi-Agent</strong></td>
308
- <td>MCP + REST + Leases + Signals</td>
309
- <td>API (keine Koordination)</td>
310
- <td>Nur innerhalb der Letta-Runtime</td>
311
- <td>Dateien pro Agent</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Framework-Lock-in</strong></td>
315
- <td>Keiner (jeder MCP-Client)</td>
316
- <td>Keiner</td>
317
- <td>Hoch (Letta erforderlich)</td>
318
- <td>Format pro Agent</td>
319
- </tr>
320
- <tr>
321
- <td><strong>Externe Abhängigkeiten</strong></td>
322
- <td>Keine (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + Vector-DB</td>
325
- <td>Keine</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Memory-Lifecycle</strong></td>
329
- <td>4-stufige Konsolidierung + Decay + Auto-Forget</td>
330
- <td>Passive Extraktion</td>
331
- <td>Vom Agenten verwaltet</td>
332
- <td>Manuelles Pruning</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Token-Effizienz</strong></td>
336
- <td>~1.900 Tokens/Session (10 $/Jahr)</td>
337
- <td>Je nach Integration unterschiedlich</td>
338
- <td>Core Memory im Kontext</td>
339
- <td>22K+ Tokens bei 240 Beobachtungen</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Echtzeit-Viewer</strong></td>
343
- <td>Ja (Port 3113)</td>
344
- <td>Cloud-Dashboard</td>
345
- <td>Cloud-Dashboard</td>
346
- <td>Nein</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Self-hosted</strong></td>
350
- <td>Ja (Standard)</td>
351
- <td>Optional</td>
352
- <td>Optional</td>
353
- <td>Ja</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Schnellstart" height="32" /></picture></h2>
360
-
361
- Kompatibilität: Diese Version zielt auf stabiles `iii-sdk` `^0.11.0` und iii-engine v0.11.x ab.
362
-
363
- ### In 30 Sekunden ausprobieren
364
-
365
- ```bash
366
- # Terminal 1: start the server
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: seed sample data and see recall in action
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` befüllt 3 realistische Sessions (JWT-Auth, N+1-Query-Fix, Rate Limiting) und führt semantische Suchen darauf aus. Sie sehen, wie „N+1 query fix" gefunden wird, wenn Sie nach „database performance optimization" suchen — Keyword-Matching kann das nicht.
374
-
375
- Öffnen Sie `http://localhost:3113`, um das Memory in Echtzeit aufgebaut zu sehen.
376
-
377
- ### Empfohlen: global installieren
378
-
379
- `npx` cached pro Version. Wenn Sie letzte Woche `npx @agentmemory/agentmemory@0.9.14` ausgeführt haben, kann ein nacktes `npx @agentmemory/agentmemory` das veraltete 0.9.14 aus `~/.npm/_npx/` ausliefern und nicht die neueste Version. Einmal installieren, und der nackte Befehl `agentmemory` funktioniert überall:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # start the server (same as the npx form)
386
- agentmemory stop # tear it down
387
- agentmemory remove # uninstall everything we created
388
- agentmemory connect claude-code # wire one agent
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- Ab v0.9.16 fordert der erste npx-Lauf inline zu einer globalen Installation auf — einmal mit `Y` antworten, fertig. Wenn Sie das überspringen, greifen Sie für einen frischen Fetch auf eine dieser Möglichkeiten zurück:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
- ```
398
-
399
- Unter Windows / PowerShell lautet das Äquivalent zum Leeren des Caches `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — die plattformübergreifende Option ist `npx -y ...@latest` oben.
400
-
401
- ### Session-Replay
402
-
403
- Jede Session, die agentmemory aufzeichnet, ist abspielbar. Öffnen Sie den Viewer, wählen Sie den Reiter **Replay** und scrubben Sie durch die Timeline: Prompts, Tool-Aufrufe, Tool-Ergebnisse und Antworten werden als diskrete Events mit Play/Pause, Geschwindigkeitssteuerung (0,5×–4×) und Tastenkürzeln (Leertaste zum Umschalten, Pfeile zum Schrittweisen) gerendert.
404
-
405
- Haben Sie ältere Claude-Code-JSONL-Transkripte, die Sie übernehmen wollen?
406
-
407
- ```bash
408
- # Import everything under the default ~/.claude/projects
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Or import a single file
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- Importierte Sessions tauchen im Replay-Picker neben den nativen auf. Intern routet jeder Eintrag durch die iii-Funktionen `mem::replay::load`, `mem::replay::sessions` und `mem::replay::import-jsonl` — keine Seitenkanal-Server.
416
-
417
- ### Upgrade / Wartung
418
-
419
- Verwenden Sie den Wartungsbefehl, wenn Sie Ihr lokales Runtime bewusst aktualisieren wollen:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- Achtung: Dieser Befehl verändert den aktuellen Workspace/Runtime. Er kann JavaScript-Abhängigkeiten aktualisieren, ggf. `cargo install iii-engine --force` ausführen und Docker-Images ziehen.
426
-
427
- Implementierungsdetails in `src/cli.ts` (siehe `runUpgrade` rund um den Bereich `src/cli.ts:544-595`).
428
-
429
- ### Claude Code (ein Block, einfügen)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code ohne Plugin-Installation (MCP-Standalone-Pfad)
436
-
437
- Wenn Sie den MCP-Server von agentmemory direkt über `~/.claude.json` verdrahten anstatt über `/plugin install`, löst Claude Code `${CLAUDE_PLUGIN_ROOT}` niemals auf, und Sie müssen Hook-Skripte in `~/.claude/settings.json` auf absolute Pfade zeigen lassen. Diese Pfade enthalten typischerweise die agentmemory-Version (z. B. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), sodass das nächste Upgrade jeden Hook stillschweigend bricht ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- Workaround:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- Das mischt dieselben Hook-Befehle in `~/.claude/settings.json` ein, mit absoluten Pfaden, die in das mitgelieferte `plugin/`-Verzeichnis des aktuell installierten `@agentmemory/agentmemory`-Pakets auflösen. Führen Sie den Befehl nach einem agentmemory-Upgrade erneut aus, um die Pfade zu aktualisieren. Eigene Einträge in derselben Datei bleiben erhalten; nur frühere agentmemory-Einträge werden ersetzt. Den `/plugin install`-Pfad zu nutzen, bleibt der empfohlene Ansatz.
446
- Für entfernte oder geschützte Deployments starten Sie Claude Code mit gesetztem `AGENTMEMORY_URL` und `AGENTMEMORY_SECRET`. Das Plugin reicht beide Werte an seinen mitgelieferten MCP-Server weiter; ist `AGENTMEMORY_URL` leer, verwendet das MCP-Shim `http://localhost:3111`.
447
-
448
- ### Codex CLI (Codex-Plugin-Plattform)
449
-
450
- ```bash
451
- # 1. start the memory server in a separate terminal
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. register the agentmemory marketplace and install the plugin
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- Das Codex-Plugin wird aus demselben `plugin/`-Verzeichnis ausgeliefert wie das Claude-Code-Plugin. Es registriert:
460
-
461
- - `@agentmemory/mcp` als MCP-Server (proxyt alle 51 Tools, wenn `AGENTMEMORY_URL` auf einen laufenden agentmemory-Server zeigt; fällt lokal auf 7 Tools zurück, wenn kein Server erreichbar ist)
462
- - 6 Lifecycle-Hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 Skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- Codex' Hook-Engine injiziert `CLAUDE_PLUGIN_ROOT` in Hook-Subprozesse (siehe [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), sodass dieselben Hook-Skripte ohne Duplikation auf beiden Hosts laufen. Die Events Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure gibt es nur in Claude Code und werden für Codex nicht registriert.
466
-
467
- #### Codex Desktop: Plugin-Hooks derzeit lautlos (Workaround vorhanden)
468
-
469
- `CodexHooks` und `PluginHooks` sind beide stabil und standardmäßig aktiviert in [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), aber aktuelle Codex-Desktop-Builds dispatchen die plugin-lokale `hooks.json` nicht ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP-Tools funktionieren weiterhin; nur die Lifecycle-Beobachtungen fehlen.
470
-
471
- Solange der Fix upstream nicht gelandet ist, spiegeln Sie dieselben Hook-Befehle in die globale `~/.codex/hooks.json`:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- Das fügt einen idempotenten Block zu `~/.codex/hooks.json` hinzu, der absolute Pfade zu den mitgelieferten Skripten referenziert (keine `${CLAUDE_PLUGIN_ROOT}`-Expansion auf Benutzer-Scope nötig). Führen Sie denselben Befehl nach einem agentmemory-Upgrade erneut aus, um die Pfade zu aktualisieren. Eigene Einträge in derselben Datei bleiben erhalten; nur frühere agentmemory-Einträge werden ersetzt.
478
-
479
- <details>
480
- <summary><b>OpenClaw (diesen Prompt einfügen)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- Vollständiger Leitfaden: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (diesen Prompt einfügen)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- Vollständiger Leitfaden: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### Andere Agenten
526
-
527
- Starten Sie den Memory-Server: `npx @agentmemory/agentmemory`
528
-
529
- Der agentmemory-Eintrag ist der **gleiche MCP-Server-Block** für jeden Host, der das `mcpServers`-Format verwendet (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **Fügen Sie diesen Eintrag in das bestehende `mcpServers`-Objekt** in der Konfigurationsdatei des Hosts ein — ersetzen Sie nicht die Datei. Wenn die Datei bereits andere Server enthält, fügen Sie `agentmemory` als zusätzlichen Schlüssel innerhalb von `mcpServers` daneben ein. Fehlt `mcpServers` ganz, fügen Sie den Block innerhalb von `{ "mcpServers": { ... } }` ein. Die `${VAR}`-Platzhalter übernehmen `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` aus der Shell beim Start des MCP-Servers — nicht gesetzte Variablen werden als leere Strings übergeben, und das Shim fällt auf `http://localhost:3111` zurück. Ein einziger verdrahteter Eintrag deckt sowohl lokale als auch entfernte (k8s / reverse-proxied) Deployments ab.
543
-
544
- | Agent | Konfigurationsdatei | Hinweise |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | In `mcpServers` einfügen. Ein-Klick-Deeplink auch auf der Website. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | In `mcpServers` einfügen. Claude Desktop nach dem Editieren neu starten. |
548
- | **Cline / Roo Code / Kilo Code** | Cline-MCP-Einstellungen (Settings UI → MCP Servers → Edit) | Gleicher `mcpServers`-Block. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Gleicher `mcpServers`-Block. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (automatisches Mergen). |
551
- | **OpenClaw** | OpenClaw-MCP-Konfig | Gleicher `mcpServers`-Block oder das tiefer integrierte [Memory-Plugin](../integrations/openclaw/). |
552
- | **Codex CLI (nur MCP)** | `.codex/config.toml` | TOML-Form: `codex mcp add agentmemory -- npx -y @agentmemory/mcp` oder `[mcp_servers.agentmemory]` manuell hinzufügen. |
553
- | **Codex CLI (volles Plugin)** | Codex-Plugin-Marketplace | `codex plugin marketplace add rohitg00/agentmemory`, dann `codex plugin add agentmemory@agentmemory`. Registriert MCP + 6 Lifecycle-Hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 Skills. Auf Codex Desktop zusätzlich `agentmemory connect codex --with-hooks` ausführen, bis [openai/codex#16430](https://github.com/openai/codex/issues/16430) landet — Plugin-Hooks sind dort derzeit lautlos. |
554
- | **OpenCode (nur MCP)** | `opencode.json` | Anderes Format — `mcp`-Schlüssel auf oberster Ebene, Command als Array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (volles Plugin)** | `plugin/opencode/` | 22 Auto-Capture-Hooks für Session-Lifecycle, Messages, Tools, Fehler. Zwei Slash-Befehle (`/recall`, `/remember`). Kopieren Sie `plugin/opencode/` in Ihren OpenCode-Workspace und fügen Sie den Plugin-Eintrag zu `opencode.json` hinzu. Siehe [`plugin/opencode/README.md`](../plugin/opencode/README.md) für die vollständige Hook-Tabelle + Gap-Analyse. |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) kopieren und pi neu starten. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | Verwenden Sie das tiefer integrierte [Memory-Provider-Plugin](../integrations/hermes/) mit `memory.provider: agentmemory`. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` schreibt den standardmäßigen `mcpServers`-Block. Die Hook-Payload ist feldkompatibel mit Claude Code, sodass die bestehenden 12 Hook-Skripte ohne Änderung funktionieren — verdrahten Sie sie über den Abschnitt `hooks` in derselben `settings.json`. |
559
- | **Antigravity** (ersetzt Gemini CLI) | `mcp_config.json` (im User-Verzeichnis von Antigravity) | `agentmemory connect antigravity` schreibt den standardmäßigen `mcpServers`-Block. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Nach dem Sunset von Gemini CLI am 2026-06-18 zu nutzen. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` schreibt die Konfig auf Benutzerebene. Workspace-Overrides liegen in `.kiro/settings/mcp.json` neben Ihrem Code. |
561
- | **Goose** | Goose-MCP-Einstellungen-UI | Gleicher `mcpServers`-Block. |
562
- | **Aider** | n/v | Sprechen Sie direkt mit der REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **Jeder Agent (32+)** | n/v | `npx skillkit install agentmemory` erkennt den Host automatisch und merged. |
564
-
565
- **MCP-Clients in Sandboxen** (Flatpak / Snap / restriktive Container), die den `localhost` des Hosts nicht erreichen können: Setzen Sie zusätzlich `"AGENTMEMORY_FORCE_PROXY": "1"` im `env`-Block und lassen Sie `AGENTMEMORY_URL` auf eine Route zeigen, die die Sandbox tatsächlich erreichen kann (z. B. Ihre LAN-IP). Siehe [#234](https://github.com/rohitg00/agentmemory/issues/234) für den Diagnose-Walkthrough.
566
-
567
- ### Programmatischer Zugriff (Python / Rust / Node)
568
-
569
- agentmemory registriert seine Kernoperationen als iii-Funktionen (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Jede Sprache mit einem iii-SDK kann sie direkt über `ws://localhost:49134` aufrufen — kein separater REST-Client pro Sprache nötig.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- Vollständiges Beispiel: [`examples/python/`](../examples/python/) (Quickstart + Beobachtungs-/Recall-Fluss). REST auf `:3111` bleibt verfügbar für Hosts ohne iii-Runtime.
590
-
591
- ### Aus den Quellen
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- Das startet agentmemory mit einer lokalen `iii-engine`, falls `iii` bereits installiert ist, oder fällt auf Docker Compose zurück, falls Docker vorhanden ist. REST, Streams und der Viewer binden sich standardmäßig an `127.0.0.1`.
599
-
600
- `iii-engine` manuell installieren. **agentmemory pinnt `iii-engine` derzeit auf `v0.11.2`** — `v0.11.6` führt ein neues Modell ein, alles per `iii worker add` zu sandboxen, für das agentmemory noch nicht refaktoriert wurde. Der Pin wird aufgehoben, sobald die Refaktorierung erfolgt ist. Überschreiben Sie mit `AGENTMEMORY_III_VERSION=<version>`, wenn Sie manuell auf das Sandbox-Modell migriert sind.
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** `aarch64-apple-darwin` durch `x86_64-apple-darwin` ersetzen
604
- - **Linux x64:** durch `x86_64-unknown-linux-gnu` ersetzen
605
- - **Linux arm64:** durch `aarch64-unknown-linux-gnu` ersetzen
606
- - **Windows:** `iii-x86_64-pc-windows-msvc.zip` von [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) herunterladen, `iii.exe` extrahieren, zum PATH hinzufügen
607
-
608
- Oder Docker verwenden (die mitgelieferte `docker-compose.yml` zieht `iiidev/iii:0.11.2`). Vollständige Doku: [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory läuft auf Windows 10/11, aber das Node.js-Paket allein genügt nicht — Sie brauchen außerdem das `iii-engine`-Runtime (ein separates natives Binary) als Hintergrundprozess. Der offizielle Upstream-Installer ist ein `sh`-Skript, und es gibt heute weder einen PowerShell-Installer noch ein scoop/winget-Paket, daher haben Windows-Nutzer zwei Wege:
613
-
614
- **Option A — Vorgebautes Windows-Binary (empfohlen):**
615
-
616
- ```powershell
617
- # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
- # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
- # model that engine v0.11.6+ requires)
620
- # 2. Download iii-x86_64-pc-windows-msvc.zip
621
- # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
- # 3. Extract iii.exe somewhere on PATH, or place it at:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory checks that location automatically)
625
- # 4. Verify:
626
- iii --version
627
- # Should print: 0.11.2
628
-
629
- # 5. Then run agentmemory as usual:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **Option B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Install Docker Desktop for Windows
637
- # 2. Start Docker Desktop and make sure the engine is running
638
- # 3. Run agentmemory — it will auto-start the bundled compose file:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **Option C — Nur Standalone-MCP (ohne Engine):** Wenn Sie nur die MCP-Tools für Ihren Agenten brauchen und weder REST API, Viewer noch Cron-Jobs, überspringen Sie die Engine ganz:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # or via the shim package:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Diagnose unter Windows:** Wenn `npx @agentmemory/agentmemory` fehlschlägt, mit `--verbose` neu starten, um das tatsächliche Engine-stderr zu sehen. Häufige Fehlerbilder:
651
-
652
- | Symptom | Lösung |
653
- |---|---|
654
- | `iii-engine process started`, dann `did not become ready within 15s` | Engine ist beim Start abgestürzt — mit `--verbose` neu starten, stderr prüfen |
655
- | `Could not start iii-engine` | Weder `iii.exe` noch Docker installiert. Siehe Option A oder B oben |
656
- | Port-Konflikt | `netstat -ano \| findstr :3111`, um zu sehen, was gebunden ist, dann beenden oder `--port <N>` verwenden |
657
- | Docker-Fallback wird übersprungen, obwohl Docker installiert ist | Stellen Sie sicher, dass Docker Desktop tatsächlich läuft (Taskleisten-Icon) |
658
-
659
- > Hinweis: Es gibt kein `cargo install iii-engine` — `iii` ist nicht auf crates.io veröffentlicht. Die einzigen unterstützten Installationsmethoden sind das vorgebaute Binary oben, das Upstream-`sh`-Installationsskript (nur macOS/Linux) und das Docker-Image.
660
-
661
- ---
662
-
663
- <h2 id="deploy">Deployment</h2>
664
-
665
- Ein-Klick-Vorlagen für gemanagte Hosts. Jede liefert ein autonomes
666
- Dockerfile aus, das `@agentmemory/agentmemory` aus npm bezieht und das
667
- iii-engine-Binary aus dem offiziellen `iiidev/iii`-Image vom Docker Hub
668
- kopiert — keine vorgebaute agentmemory-Image-Erforderlichkeit. Persistenter
669
- Speicher wird unter `/data` gemountet; der Entrypoint beim ersten Boot
670
- überschreibt die per npm gelieferte iii-Konfig (die `127.0.0.1` bindet)
671
- mit einer deploy-tauglichen Variante, die `0.0.0.0` bindet und absolute
672
- `/data`-Pfade verwendet, generiert das HMAC-Secret und senkt die
673
- Privilegien von `root` auf `node` via `gosu`, bevor er die agentmemory-CLI
674
- exec't.
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- Der Ein-Klick-Deploy-Button von Render erfordert eine `render.yaml` im Repository-Root, das wir bewusst sauber halten. Verwenden Sie den Render-Blueprint-Fluss, dokumentiert in [`deploy/render/`](./deploy/render/README.md), um manuell auf das im Repo liegende Blueprint zu zeigen.
682
-
683
- Vollständige Setup-Details (HMAC-Capture, Viewer-SSH-Tunnel, Rotation, Backup, Kostenuntergrenzen) finden Sie in [`deploy/`](./deploy/README.md):
684
-
685
- - [`deploy/fly`](./deploy/fly/README.md) — Einzelmaschine mit
686
- `auto_stop_machines = "stop"`; am günstigsten im Leerlauf.
687
- - [`deploy/railway`](./deploy/railway/README.md) — Hobby-Plan mit Pauschalpreis,
688
- Volume im Dashboard.
689
- - [`deploy/render`](./deploy/render/README.md) — Blueprint-Fluss,
690
- automatische Disk-Snapshots auf bezahlten Plänen.
691
- - [`deploy/coolify`](./deploy/coolify/README.md) — self-hosted auf Ihrem
692
- eigenen VPS via [Coolify](https://coolify.io/self-hosted); derselbe
693
- Docker-Compose-Stack, Sie besitzen Host und Daten.
694
-
695
- Nur Port `3111` wird veröffentlicht. Der Viewer auf `3113` bleibt im
696
- Container an Loopback gebunden — jedes Template-README dokumentiert
697
- das SSH-Tunnel-Muster, um ihn zu erreichen.
698
-
699
- ---
700
-
701
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Warum agentmemory" height="32" /></picture></h2>
702
-
703
- Jeder Coding-Agent vergisst alles, wenn die Session endet. Sie verschwenden die ersten 5 Minuten jeder Session damit, Ihren Stack erneut zu erklären. agentmemory läuft im Hintergrund und beseitigt das vollständig.
704
-
705
- ```text
706
- Session 1: "Add auth to the API"
707
- Agent writes code, runs tests, fixes bugs
708
- agentmemory silently captures every tool use
709
- Session ends -> observations compressed into structured memory
710
-
711
- Session 2: "Now add rate limiting"
712
- Agent already knows:
713
- - Auth uses JWT middleware in src/middleware/auth.ts
714
- - Tests in test/auth.test.ts cover token validation
715
- - You chose jose over jsonwebtoken for Edge compatibility
716
- Zero re-explaining. Starts working immediately.
717
- ```
718
-
719
- ### vs. eingebautes Agent-Memory
720
-
721
- Jeder KI-Coding-Agent kommt mit eingebautem Memory — Claude Code hat `MEMORY.md`, Cursor hat Notepads, Cline hat Memory Bank. Das funktioniert wie Klebezettel. agentmemory ist die durchsuchbare Datenbank hinter den Klebezetteln.
722
-
723
- | | Eingebaut (CLAUDE.md) | agentmemory |
724
- |---|---|---|
725
- | Skalierung | 200-Zeilen-Limit | Unbegrenzt |
726
- | Suche | Lädt alles in den Kontext | BM25 + Vector + Graph (nur Top-K) |
727
- | Token-Kosten | 22K+ bei 240 Beobachtungen | ~1.900 Tokens (92 % weniger) |
728
- | Agentenübergreifend | Dateien pro Agent | MCP + REST (jeder Agent) |
729
- | Koordination | Keine | Leases, Signale, Actions, Routinen |
730
- | Observability | Dateien manuell lesen | Echtzeit-Viewer auf :3113 |
731
-
732
- ---
733
-
734
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Funktionsweise" height="32" /></picture></h2>
735
-
736
- ### Memory-Pipeline
737
-
738
- ```text
739
- PostToolUse hook fires
740
- -> SHA-256 dedup (5min window)
741
- -> Privacy filter (strip secrets, API keys)
742
- -> Store raw observation
743
- -> LLM compress -> structured facts + concepts + narrative
744
- -> Vector embedding (6 providers + local)
745
- -> Index in BM25 + vector
746
-
747
- Stop / SessionEnd hook fires
748
- -> Summarize session
749
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
750
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
751
-
752
- SessionStart hook fires
753
- -> Load project profile (top concepts, files, patterns)
754
- -> Hybrid search (BM25 + vector + graph)
755
- -> Token budget (default: 2000 tokens)
756
- -> Inject into conversation
757
- ```
758
-
759
- ### 4-stufige Memory-Konsolidierung
760
-
761
- Inspiriert davon, wie menschliche Gehirne Erinnerungen verarbeiten — nicht unähnlich der Schlafkonsolidierung.
762
-
763
- | Stufe | Was | Analogie |
764
- |------|------|---------|
765
- | **Working** | Rohbeobachtungen aus Tool-Nutzung | Kurzzeitgedächtnis |
766
- | **Episodic** | Komprimierte Session-Zusammenfassungen | „Was passiert ist" |
767
- | **Semantic** | Extrahierte Fakten und Muster | „Was ich weiß" |
768
- | **Procedural** | Workflows und Entscheidungsmuster | „Wie es geht" |
769
-
770
- Erinnerungen klingen mit der Zeit ab (Ebbinghaus-Kurve). Häufig abgerufene Erinnerungen werden verstärkt. Veraltete Erinnerungen werden automatisch evakuiert. Widersprüche werden erkannt und aufgelöst.
771
-
772
- ### Was erfasst wird
773
-
774
- | Hook | Erfasst |
775
- |------|----------|
776
- | `SessionStart` | Projektpfad, Session-ID |
777
- | `UserPromptSubmit` | Benutzer-Prompts (Privacy-gefiltert) |
778
- | `PreToolUse` | Datei-Zugriffsmuster + angereicherter Kontext |
779
- | `PostToolUse` | Tool-Name, Eingabe, Ausgabe |
780
- | `PostToolUseFailure` | Fehlerkontext |
781
- | `PreCompact` | Re-injiziert Memory vor der Kompaktierung |
782
- | `SubagentStart/Stop` | Sub-Agent-Lifecycle |
783
- | `Stop` | Zusammenfassung am Session-Ende |
784
- | `SessionEnd` | Session-Abschluss-Marker |
785
-
786
- ### Kernfähigkeiten
787
-
788
- | Fähigkeit | Beschreibung |
789
- |---|---|
790
- | **Automatische Erfassung** | Jede Tool-Nutzung via Hooks aufgezeichnet — null manueller Aufwand |
791
- | **Semantische Suche** | BM25 + Vector + Knowledge Graph mit RRF-Fusion |
792
- | **Memory-Evolution** | Versionierung, Supersession, Beziehungsgraphen |
793
- | **Auto-Vergessen** | TTL-Ablauf, Widerspruchserkennung, Wichtigkeits-Eviction |
794
- | **Privacy first** | API-Keys, Secrets, `<private>`-Tags vor Speicherung entfernt |
795
- | **Selbstheilung** | Circuit Breaker, Provider-Fallback-Kette, Health-Monitoring |
796
- | **Claude-Bridge** | Bidirektionale Synchronisierung mit MEMORY.md |
797
- | **Knowledge Graph** | Entitäten-Extraktion + BFS-Traversal |
798
- | **Team-Memory** | Namensraum-getrennt geteilt + privat über Teammitglieder hinweg |
799
- | **Zitations-Provenienz** | Jedes Memory bis zu Ursprungsbeobachtungen zurückverfolgen |
800
- | **Git-Snapshots** | Memory-Stand versionieren, zurückrollen und diffen |
801
-
802
- ---
803
-
804
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Suche" height="32" /></picture></h2>
805
-
806
- Triple-Stream-Retrieval, das drei Signale kombiniert:
807
-
808
- | Stream | Was es tut | Wann |
809
- |---|---|---|
810
- | **BM25** | Gestemmter Keyword-Abgleich mit Synonymerweiterung | Immer aktiv |
811
- | **Vector** | Cosinus-Ähnlichkeit über dichte Embeddings | Embedding-Provider konfiguriert |
812
- | **Graph** | Knowledge-Graph-Traversal via Entitäten-Abgleich | Entitäten in der Anfrage erkannt |
813
-
814
- Verschmolzen mit Reciprocal Rank Fusion (RRF, k=60) und session-diversifiziert (max. 3 Ergebnisse pro Session).
815
-
816
- BM25 tokenisiert Griechisch, Kyrillisch, Hebräisch, Arabisch und akzentuiertes Latein standardmäßig. Für Erinnerungen in Chinesisch / Japanisch / Koreanisch installieren Sie die optionalen Segmentierer (`npm install @node-rs/jieba tiny-segmenter`), um CJK-Folgen in Worttokens aufzuteilen; ohne sie fällt agentmemory weich auf eine Tokenisierung als gesamte Folge zurück und gibt einmalig einen Hinweis auf stderr aus.
817
-
818
- ### Embedding-Provider
819
-
820
- agentmemory erkennt Ihren Provider automatisch. Für die besten Ergebnisse installieren Sie lokale Embeddings (kostenlos):
821
-
822
- ```bash
823
- npm install @xenova/transformers
824
- ```
825
-
826
- | Provider | Modell | Kosten | Hinweise |
827
- |---|---|---|---|
828
- | **Lokal (empfohlen)** | `all-MiniLM-L6-v2` | Kostenlos | Offline, +8 pp Recall gegenüber BM25 allein |
829
- | Gemini | `gemini-embedding-001` | Free Tier | 100+ Sprachen, 768/1536/3072 Dims (MRL), 2048-Token-Eingabe. Ersetzt `text-embedding-004` ([deprecated, Abschaltung 14. Jan. 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
830
- | OpenAI | `text-embedding-3-small` | 0,02 $/1M | Höchste Qualität |
831
- | Voyage AI | `voyage-code-3` | Kostenpflichtig | Auf Code optimiert |
832
- | Cohere | `embed-english-v3.0` | Testzugang | Allzweck |
833
- | OpenRouter | Beliebiges Modell | Variabel | Multi-Modell-Proxy |
834
-
835
- ---
836
-
837
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP-Server" height="32" /></picture></h2>
838
-
839
- 53 Tools, 6 Resources, 3 Prompts und 4 Skills — das umfassendste MCP-Memory-Toolkit für jeden Agenten.
840
-
841
- > **MCP-Shim vs. voller Server:** Das veröffentlichte `@agentmemory/mcp`-Paket ist ein dünnes Shim. Es legt die volle 51-Tool-Oberfläche **nur dann** offen, wenn es per `AGENTMEMORY_URL` einen laufenden agentmemory-Server erreichen kann (Proxy-Modus). Ohne erreichbaren Server fällt das Shim auf einen lokalen 7-Tool-Satz zurück (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). Die Umgebungsvariable `AGENTMEMORY_TOOLS=core|all` ist ein *serverseitiger* Schalter — sie im `env`-Block des Shims zu setzen hat keinen Effekt. Wenn Sie in Cursor / OpenCode / Gemini CLI nur 7 Tools sehen, starten Sie `npx @agentmemory/agentmemory` (oder den Docker-Stack) und setzen Sie `AGENTMEMORY_URL=http://localhost:3111`.
842
-
843
- ### 51 Tools
844
-
845
- <details>
846
- <summary>Core-Tools (immer verfügbar)</summary>
847
-
848
- | Tool | Beschreibung |
849
- |------|-------------|
850
- | `memory_recall` | Vergangene Beobachtungen durchsuchen |
851
- | `memory_compress_file` | Markdown-Dateien unter Erhalt der Struktur komprimieren |
852
- | `memory_save` | Erkenntnis, Entscheidung oder Muster speichern |
853
- | `memory_patterns` | Wiederkehrende Muster erkennen |
854
- | `memory_smart_search` | Hybride semantische + Keyword-Suche |
855
- | `memory_file_history` | Vergangene Beobachtungen zu bestimmten Dateien |
856
- | `memory_sessions` | Letzte Sessions auflisten |
857
- | `memory_timeline` | Chronologische Beobachtungen |
858
- | `memory_profile` | Projektprofil (Konzepte, Dateien, Muster) |
859
- | `memory_export` | Alle Memory-Daten exportieren |
860
- | `memory_relations` | Beziehungsgraph abfragen |
861
-
862
- </details>
863
-
864
- <details>
865
- <summary>Erweiterte Tools (insgesamt 51 — AGENTMEMORY_TOOLS=all setzen)</summary>
866
-
867
- | Tool | Beschreibung |
868
- |------|-------------|
869
- | `memory_patterns` | Wiederkehrende Muster erkennen |
870
- | `memory_timeline` | Chronologische Beobachtungen |
871
- | `memory_relations` | Beziehungsgraph abfragen |
872
- | `memory_graph_query` | Knowledge-Graph-Traversal |
873
- | `memory_consolidate` | 4-stufige Konsolidierung ausführen |
874
- | `memory_claude_bridge_sync` | Mit MEMORY.md synchronisieren |
875
- | `memory_team_share` | Mit Teammitgliedern teilen |
876
- | `memory_team_feed` | Kürzlich geteilte Einträge |
877
- | `memory_audit` | Audit-Trail der Operationen |
878
- | `memory_governance_delete` | Mit Audit-Trail löschen |
879
- | `memory_snapshot_create` | Git-versionierter Snapshot |
880
- | `memory_action_create` | Arbeitspakete mit Abhängigkeiten anlegen |
881
- | `memory_action_update` | Action-Status aktualisieren |
882
- | `memory_frontier` | Entblockte Actions nach Priorität sortiert |
883
- | `memory_next` | Einzelne wichtigste nächste Action |
884
- | `memory_lease` | Exklusive Action-Leases (Multi-Agent) |
885
- | `memory_routine_run` | Workflow-Routinen instanziieren |
886
- | `memory_signal_send` | Inter-Agent-Messaging |
887
- | `memory_signal_read` | Nachrichten mit Empfangsquittungen lesen |
888
- | `memory_checkpoint` | Externe Bedingungs-Gates |
889
- | `memory_mesh_sync` | P2P-Sync zwischen Instanzen |
890
- | `memory_sentinel_create` | Ereignisgesteuerte Watcher |
891
- | `memory_sentinel_trigger` | Sentinels extern auslösen |
892
- | `memory_sketch_create` | Ephemere Action-Graphen |
893
- | `memory_sketch_promote` | In permanent überführen |
894
- | `memory_crystallize` | Action-Ketten kompaktieren |
895
- | `memory_diagnose` | Health-Checks |
896
- | `memory_heal` | Festsitzenden Zustand auto-fixen |
897
- | `memory_facet_tag` | Dimension:Wert-Tags |
898
- | `memory_facet_query` | Nach Facetten-Tags abfragen |
899
- | `memory_verify` | Provenienz nachverfolgen |
900
-
901
- </details>
902
-
903
- ### 6 Resources · 3 Prompts · 4 Skills
904
-
905
- | Typ | Name | Beschreibung |
906
- |------|------|-------------|
907
- | Resource | `agentmemory://status` | Health, Session-Anzahl, Memory-Anzahl |
908
- | Resource | `agentmemory://project/{name}/profile` | Projektspezifische Intelligenz |
909
- | Resource | `agentmemory://memories/latest` | Die 10 neuesten aktiven Erinnerungen |
910
- | Resource | `agentmemory://graph/stats` | Knowledge-Graph-Statistiken |
911
- | Prompt | `recall_context` | Suche + Rückgabe von Kontext-Nachrichten |
912
- | Prompt | `session_handoff` | Handoff-Daten zwischen Agenten |
913
- | Prompt | `detect_patterns` | Wiederkehrende Muster analysieren |
914
- | Skill | `/recall` | Memory durchsuchen |
915
- | Skill | `/remember` | Im Langzeit-Memory speichern |
916
- | Skill | `/session-history` | Zusammenfassungen letzter Sessions |
917
- | Skill | `/forget` | Beobachtungen / Sessions löschen |
918
-
919
- ### Standalone MCP
920
-
921
- Ohne den vollen Server laufen lassen — für jeden MCP-Client. Eines der folgenden geht:
922
-
923
- ```bash
924
- npx -y @agentmemory/agentmemory mcp # canonical (always available)
925
- npx -y @agentmemory/mcp # shim package alias
926
- ```
927
-
928
- Oder zur MCP-Konfig Ihres Agenten hinzufügen:
929
-
930
- Die meisten Agenten (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
931
- ```json
932
- {
933
- "mcpServers": {
934
- "agentmemory": {
935
- "command": "npx",
936
- "args": ["-y", "@agentmemory/mcp"],
937
- "env": {
938
- "AGENTMEMORY_URL": "http://localhost:3111"
939
- }
940
- }
941
- }
942
- }
943
- ```
944
-
945
- Fügen Sie den `agentmemory`-Eintrag in das vorhandene `mcpServers`-Objekt Ihres Hosts ein, statt die Datei zu ersetzen. Für Sandbox-Clients, die den `localhost` des Hosts nicht erreichen können, fügen Sie `"AGENTMEMORY_FORCE_PROXY": "1"` zum env-Block hinzu und lassen `AGENTMEMORY_URL` auf eine Route zeigen, die die Sandbox erreicht.
946
-
947
- OpenCode (`opencode.json`):
948
- ```json
949
- {
950
- "mcp": {
951
- "agentmemory": {
952
- "type": "local",
953
- "command": ["npx", "-y", "@agentmemory/mcp"],
954
- "enabled": true
955
- }
956
- },
957
- "plugin": ["./plugins/agentmemory-capture.ts"]
958
- }
959
- ```
960
-
961
- Plugin-Datei aus dem Repo kopieren:
962
- ```bash
963
- mkdir -p ~/.config/opencode/plugins
964
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
965
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
966
- ```
967
-
968
- ---
969
-
970
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Echtzeit-Viewer" height="32" /></picture></h2>
971
-
972
- Startet automatisch auf Port `3113`. Live-Beobachtungs-Stream, Session-Explorer, Memory-Browser, Knowledge-Graph-Visualisierung und Health-Dashboard.
973
-
974
- ```bash
975
- open http://localhost:3113
976
- ```
977
-
978
- Der Viewer-Server bindet sich standardmäßig an `127.0.0.1`. Der per REST ausgelieferte `/agentmemory/viewer`-Endpunkt folgt den üblichen `AGENTMEMORY_SECRET`-Bearer-Token-Regeln. CSP-Header verwenden eine Skript-Nonce pro Response und deaktivieren Inline-Handler-Attribute (`script-src-attr 'none'`).
979
-
980
- ---
981
-
982
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
983
-
984
- Der Viewer auf `:3113` zeigt, was Ihr Agent **gespeichert hat**. Die [iii console](https://iii.dev/docs/console) zeigt, was Ihr Agent **getan hat** — jede Memory-Operation als OpenTelemetry-Trace, jeden KV-Eintrag editierbar, jede Funktion aufrufbar, jeden Stream abgreifbar. Zwei Fenster auf dasselbe Memory: eines produktnah, eines engine-nah.
985
-
986
- Sehen Sie, wie ein `memory_smart_search` feuert, und beobachten Sie BM25-Scan → Embedding-Lookup → RRF-Fusion → Reranker als Wasserfall. Editieren Sie einen festsitzenden Konsolidierungs-Timer im KV-Browser. Spielen Sie einen `PostToolUse`-Hook mit angepasster Payload erneut ab. Pinnen Sie den WebSocket-Stream an und sehen Sie Beobachtungen live eintrudeln.
987
-
988
- agentmemory liefert das umsonst, weil jede Funktion, jeder Trigger, jeder State-Scope und jeder Stream eine iii-Primitive ist — nichts Eigenes, nichts zu instrumentieren.
989
-
990
- <p align="center">
991
- <img src="../assets/iii-console/workers.png" alt="iii console Workers-Seite — verbundene Worker, einschließlich agentmemory-Instanzen mit Live-Funktionszahlen und Runtime-Metadaten" width="720" />
992
- <br/>
993
- <em>Workers-Seite: jeder verbundene Worker — einschließlich agentmemory selbst — mit PID, Funktionsanzahl, Runtime und last-seen.</em>
994
- </p>
995
-
996
- **Bereits installiert.** Die Console wird mit `iii` ausgeliefert — kein separater Installer.
997
-
998
- **Neben agentmemory starten:**
999
-
1000
- ```bash
1001
- # agentmemory viewer holds port 3113, so run the console on 3114.
1002
- # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1003
- iii console --port 3114
1004
- ```
1005
-
1006
- Dann `http://localhost:3114` öffnen. `--enable-flow` ergänzen für die experimentelle Architektur-Graph-Seite.
1007
-
1008
- Engine-Endpunkte nur überschreiben, wenn Sie sie verschoben haben:
1009
-
1010
- ```bash
1011
- iii console --port 3114 \
1012
- --engine-port 3111 \
1013
- --ws-port 3112 \
1014
- --bridge-port 49134
1015
- ```
1016
-
1017
- **Was Sie aus der Console heraus tun können:**
1018
-
1019
- | Seite | Verwenden Sie sie für |
1020
- |------|-----------|
1021
- | **Workers** | Jeden verbundenen Worker und seine Live-Metriken sehen — einschließlich des agentmemory-Workers selbst. |
1022
- | **Functions** | Jede Funktion von agentmemory direkt mit einer JSON-Payload aufrufen — handlich zum Testen von `memory.recall`, `memory.consolidate`, `graph.query` ohne Client zu verdrahten. |
1023
- | **Triggers** | HTTP-, Cron-, Event- und State-Trigger erneut abspielen — den Konsolidierungs-Cron manuell auslösen, eine HTTP-Route wiederholen, einen State-Change emittieren. |
1024
- | **States** | KV-Browser mit vollem CRUD — Sessions, Memory-Slots, Lifecycle-Timer, Embedding-Index — Werte direkt bearbeiten. |
1025
- | **Streams** | Live-WebSocket-Monitor für Memory-Schreibvorgänge, Hook-Events und Beobachtungsupdates, wie sie durch iii-Streams fließen. |
1026
- | **Queues** | Durable Queue-Topics + Dead-Letter-Verwaltung. Fehlgeschlagene Embedding-/Kompressions-Jobs wiederholen oder verwerfen. |
1027
- | **Traces** | OpenTelemetry-Wasserfall- / Flame- / Service-Breakdown-Ansichten. Nach `trace_id` filtern, um exakt zu sehen, welche Funktionen, DB-Calls und Embedding-Anfragen eine einzelne `memory.search` ausgelöst hat. |
1028
- | **Logs** | Strukturierte OTEL-Logs, gefiltert und korreliert mit Trace-/Span-IDs. |
1029
- | **Config** | Runtime-Konfiguration — sehen Sie genau, mit welchen Workern, Providern und Ports Ihre Engine läuft. |
1030
- | **Flow** | (Optional, `--enable-flow`) Interaktiver Architekturgraph jedes Workers, Triggers und Streams. |
1031
-
1032
- <p align="center">
1033
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console Trace-Wasserfall-Ansicht mit Span-Dauer" width="720" />
1034
- <br/>
1035
- <em>Traces: Wasserfall / Flame / Service-Breakdown für jede Memory-Operation.</em>
1036
- </p>
1037
-
1038
- **Traces sind bereits aktiv:**
1039
-
1040
- `iii-config.yaml` wird mit aktiviertem `iii-observability`-Worker ausgeliefert (`exporter: memory`, `sampling_ratio: 1.0`, Metriken + Logs). Keine zusätzliche Konfig nötig — in dem Moment, in dem agentmemory startet, emittiert jede Memory-Operation einen Trace-Span und ein strukturiertes Log, das die Console lesen kann.
1041
-
1042
- Wenn Sie stattdessen zu Jaeger/Honeycomb/Grafana Tempo exportieren wollen, ändern Sie `exporter: memory` zu `exporter: otlp` und setzen den Collector-Endpunkt gemäß der iii-Observability-Doku.
1043
-
1044
- > **Achtung:** Auf der Console selbst wird keine Auth erzwungen — lassen Sie sie an `127.0.0.1` gebunden (Standard) und stellen Sie sie niemals öffentlich bereit.
1045
-
1046
- ---
1047
-
1048
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1049
-
1050
- agentmemory ist **bereits eine laufende [iii](https://iii.dev)-Instanz**. Funktionen, Trigger, KV-State, Streams, OTEL-Traces — alles sind iii-Primitiven. Sie haben weder Postgres noch Redis, Express, pm2 oder Prometheus installiert, weil iii sie ersetzt.
1051
-
1052
- Das bedeutet, ein weiterer Befehl erweitert agentmemory um eine komplett neue Fähigkeit.
1053
-
1054
- ### agentmemory mit einem Befehl erweitern
1055
-
1056
- ```bash
1057
- iii worker add iii-pubsub # fan memory writes out to every connected instance
1058
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1059
- iii worker add iii-queue # durable retries for embedding + compression jobs
1060
- iii worker add iii-observability # OTEL traces on every memory op (default on)
1061
- iii worker add iii-sandbox # run recalled code inside an isolated microVM
1062
- iii worker add iii-database # swap in a SQL-backed state adapter
1063
- iii worker add mcp # generic MCP host alongside the agentmemory MCP
1064
- ```
1065
-
1066
- Jedes `iii worker add` registriert neue Funktionen und Trigger im selben Engine, auf dem agentmemory bereits läuft. Viewer und Console übernehmen sie sofort — kein Reload, keine neue Integration, kein neuer Container.
1067
-
1068
- | `iii worker add` | Was Sie zusätzlich zu agentmemory erhalten |
1069
- |---|---|
1070
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-Instanz-Memory: jedes `remember` fächert auf, jedes `search` liest die Vereinigung |
1071
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Geplanter Lifecycle — nächtliche Konsolidierung, wöchentliche Snapshots, Decay nach fester Uhr |
1072
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable Retries: fehlgeschlagene Embedding-/Kompressions-Jobs überleben den Neustart, keine verlorenen Beobachtungen |
1073
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL-Traces, Metriken, Logs auf jeder Funktion — in `iii-config.yaml` ab dem ersten Tag verdrahtet |
1074
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Code, der aus `memory_recall` kommt, läuft in einer wegwerf-VM, nicht in Ihrer Shell |
1075
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | SQL-gestützter State-Adapter, wenn Sie die In-Memory-KV-Voreinstellungen überwachsen |
1076
- | [`mcp`](https://workers.iii.dev/workers/mcp) | Zusätzliche MCP-Server neben dem von agentmemory aufstellen, die sich denselben Engine teilen |
1077
-
1078
- Volle Registry: [workers.iii.dev](https://workers.iii.dev). Jeder Worker dort komponiert sich über dieselben Primitiven wie agentmemory — und das agentmemory, das Sie bereits haben, ist einer davon.
1079
-
1080
- ### Was iii ersetzt
1081
-
1082
- | Traditioneller Stack | agentmemory verwendet |
1083
- |---|---|
1084
- | Express.js / Fastify | iii HTTP Triggers |
1085
- | SQLite / Postgres + pgvector | iii KV State + In-Memory-Vector-Index |
1086
- | SSE / Socket.io | iii Streams (WebSocket) |
1087
- | pm2 / systemd | iii-Engine-Worker-Supervision |
1088
- | Prometheus / Grafana | iii OTEL + Health-Monitor |
1089
- | Eigene Plugin-Systeme | `iii worker add <name>` |
1090
-
1091
- **118 Quelldateien · ~21.800 LOC · 950+ Tests · 123 Funktionen · 34 KV-Scopes** — alles auf drei Primitiven. Kein `agentmemory plugin install`. Das Plugin-System ist iii selbst.
1092
-
1093
- ---
1094
-
1095
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Konfiguration" height="32" /></picture></h2>
1096
-
1097
- ### LLM-Provider
1098
-
1099
- agentmemory erkennt aus Ihrer Umgebung automatisch. Standardmäßig werden keine LLM-Aufrufe ausgeführt, solange Sie nicht einen Provider konfigurieren oder dem Claude-Abonnement-Fallback ausdrücklich zustimmen.
1100
-
1101
- | Provider | Konfig | Hinweise |
1102
- |----------|--------|-------|
1103
- | **No-op (Standard)** | Keine Konfig nötig | LLM-gestütztes Compress/Summarize ist DEAKTIVIERT. Synthetische BM25-Kompression + Recall funktionieren weiter. Siehe `AGENTMEMORY_ALLOW_AGENT_SDK` unten, falls Sie früher auf den Claude-Abonnement-Fallback gesetzt haben. |
1104
- | Anthropic API | `ANTHROPIC_API_KEY` | Abrechnung pro Token |
1105
- | MiniMax | `MINIMAX_API_KEY` | Anthropic-kompatibel |
1106
- | Gemini | `GEMINI_API_KEY` | Aktiviert zusätzlich Embeddings |
1107
- | OpenRouter | `OPENROUTER_API_KEY` | Beliebiges Modell |
1108
- | Claude-Abonnement-Fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Nur als Opt-in. Startet `@anthropic-ai/claude-agent-sdk`-Sessions — verursachte früher unbegrenzte Stop-Hook-Rekursion (Folge von #149), daher nicht mehr Standard. |
1109
-
1110
- ### Kostenbewusste Modellwahl
1111
-
1112
- Hintergrund-Kompression läuft bei jeder Beobachtung, daher beeinflusst die Modellwahl die monatlichen Kosten spürbar. Erfasste Lastdaten: 635 Requests / 888K Tokens / 35 Stunden aktive Nutzung, gegen drei OpenRouter-Modelle zu den Preisen vom 2026-05-23.
1113
-
1114
- | Stufe | Modell | Eingabe / 1M | Ausgabe / 1M | Kosten für die erfassten 35 h | Hinweise |
1115
- |------|-------|------------|-------------|---------------------------|-------|
1116
- | Empfohlen | `deepseek/deepseek-v4-pro` | 0,435 $ | 0,87 $ | ~0,46 $ | Solide Kompressions-/Summarize-Qualität zu ~10× geringeren Kosten als Sonnet. |
1117
- | Empfohlen | `deepseek/deepseek-chat` | 0,27 $ | 1,10 $ | ~0,40 $ | Älter, aber für reine Kompressions-Workloads weiterhin in Ordnung. |
1118
- | Empfohlen | `qwen/qwen3-coder` | 0,45 $ | 1,80 $ | ~0,55 $ | Starkes Code-Reasoning, wenn Ihre Sessions stark codelastig sind. |
1119
- | Premium | `anthropic/claude-sonnet-4.6` | 3,00 $ | 15,00 $ | ~5,02 $ | Hohe Qualität, aber teuer für dauerhafte Hintergrundarbeit. |
1120
- | Premium | `openai/gpt-4o` | 2,50 $ | 10,00 $ | ~4,20 $ | Ähnliche Stufe wie Sonnet. |
1121
- | Vermeiden | `anthropic/claude-opus-4.6` | 15,00 $ | 75,00 $ | ~25+ $ | Reasoning-Klasse-Modell; massive Überausgabe für Kompression. |
1122
-
1123
- agentmemory gibt eine Runtime-Warnung aus, wenn `OPENROUTER_MODEL` auf ein Premium-Tier-Muster passt. Setzen Sie `AGENTMEMORY_SUPPRESS_COST_WARNING=1`, um sie zum Schweigen zu bringen, sobald Sie eine bewusste Wahl getroffen haben.
1124
-
1125
- Qualitäts-Kosten-Abwägung für Memory-Arbeit: Kompression ist eine Summarize-Aufgabe mit eher lockerer Qualitätsanforderung (der Agent liest die Zusammenfassung erneut, nicht der Benutzer). DeepSeek-V4-Pro / Qwen3-Coder landen bei dieser Aufgabe innerhalb von Rundungsfehlern an Sonnet, bei ~10× weniger Kosten. Heben Sie Premium-Modelle für Anfragen auf, die Sie direkt lesen.
1126
-
1127
- Quellen: [OpenRouter-Preise für Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek-Preis-Hinweise](https://api-docs.deepseek.com/quick_start/pricing/).
1128
-
1129
- ### Multi-Agent-Memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1130
-
1131
- In Multi-Agent-Setups, in denen sich mehrere Rollen einen agentmemory-Server teilen (architect / developer / reviewer / researcher / support-agent), markiert `AGENT_ID` jede Schreibaktion mit der Rolle, die sie ausgelöst hat. `AGENTMEMORY_AGENT_SCOPE` steuert, ob der Recall nach diesem Tag filtert.
1132
-
1133
- ```env
1134
- TEAM_ID=company
1135
- USER_ID=engineering-team
1136
- AGENT_ID=architect
1137
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1138
- ```
1139
-
1140
- Zwei Modi:
1141
-
1142
- | Modus | Schreibvorgänge markieren | Recall filtern | Wann verwenden |
1143
- |------|------------|---------------|-------------|
1144
- | `shared` (Standard) | ja | nein | Agentenübergreifender Kontext mit Audit-Trail. Architect sieht, was Developer notiert hat, aber jede Zeile vermerkt, wer es gesagt hat. |
1145
- | `isolated` | ja | ja | Strikte Trennung. Architect sieht niemals Beobachtungen / Erinnerungen / Sessions von Developer. |
1146
-
1147
- Was getaggt wird, wenn `AGENT_ID` gesetzt ist: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Die Rolle fließt von `api::session::start` → `mem::observe` → `mem::compress` → KV.
1148
-
1149
- Was im Isolated-Modus gefiltert wird: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Jeder Endpunkt akzeptiert `?agentId=<role>` als Per-Request-Override und `?agentId=*`, um sich komplett aus dem env-Scope auszuklinken. `/memories` akzeptiert zudem `?includeOrphans=true`, um Pre-AGENT_ID-Erinnerungen, deren `agentId` undefiniert ist, sichtbar zu machen.
1150
-
1151
- Per-Call-Override auf SDK-/REST-Ebene: jeder mutierende Endpunkt (`/session/start`, `/remember`) akzeptiert ein `agentId`-Feld im Request-Body, das die env-Variable überschreibt. Nützlich für Runtimes, die viele Rollen durch einen einzelnen Serverprozess routen.
1152
-
1153
- Wenn `AGENT_ID` nicht gesetzt ist, bleibt Memory unscoped (Legacy-Verhalten, keine Tags, keine Filter).
1154
-
1155
- ### Ports
1156
-
1157
- agentmemory + iii-engine binden standardmäßig vier Ports. Wenn ein Neustart mit `port in use` fehlschlägt, sagt Ihnen diese Tabelle, nach welchem Prozess Sie suchen müssen.
1158
-
1159
- | Port | Prozess | Zweck | Env-Override |
1160
- |------|---------|---------|--------------|
1161
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1162
- | `3112` | iii-engine | Interner Streams-Worker (von agentmemory + Viewer verwendet) | `III_STREAMS_PORT` |
1163
- | `3113` | agentmemory | Echtzeit-Viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1164
- | `49134` | iii-engine | WebSocket — Worker registrieren sich hier, OTel-Telemetrie fließt darüber | `III_ENGINE_URL` (volle URL, Standard `ws://localhost:49134`) |
1165
-
1166
- Aufräumen veralteter Prozesse, wenn Ports nach einem abgestürzten Lauf gebunden bleiben:
1167
-
1168
- ```bash
1169
- # macOS / Linux — find whatever is on each port and kill it
1170
- lsof -i :3111,3112,3113,49134
1171
- pkill -f agentmemory || true
1172
- pkill -f 'iii ' || true
1173
-
1174
- # Windows
1175
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1176
- taskkill /F /PID <pid>
1177
- ```
1178
-
1179
- `agentmemory stop` räumt sowohl den Worker als auch das Engine-Pidfile bei einem geordneten Shutdown sauber auf (#640, #474). Das manuelle Cleanup oben ist nur für den Post-Crash-Fall nötig, in dem kein Pidfile zurückbleibt.
1180
-
1181
- ### Konfigurationsdatei
1182
-
1183
- Legen Sie die agentmemory-Runtime-Konfiguration in `~/.agentmemory/.env` ab, statt Variablen in jeder Shell zu exportieren. Wenn der Viewer einen Setup-Hinweis wie `export ANTHROPIC_API_KEY=...` zeigt, kopieren Sie ihn als `ANTHROPIC_API_KEY=...` ohne `export`-Präfix in diese Datei und starten Sie agentmemory neu.
1184
-
1185
- Prozess-Umgebungsvariablen funktionieren weiterhin und haben Vorrang vor Werten in der Datei.
1186
-
1187
- Unter Windows liegt dieselbe Datei unter `%USERPROFILE%\.agentmemory\.env`:
1188
-
1189
- ```powershell
1190
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1191
- notepad $HOME\.agentmemory\.env
1192
- ```
1193
-
1194
- Um mit einem Claude Code Pro/Max-Abonnement statt eines API-Schlüssels zu testen, stimmen Sie explizit zu:
1195
-
1196
- ```env
1197
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1198
- AGENTMEMORY_AUTO_COMPRESS=true
1199
- ```
1200
-
1201
- Aktivieren Sie Graph- oder Konsolidierungs-Features in derselben Datei, falls gewünscht:
1202
-
1203
- ```env
1204
- GRAPH_EXTRACTION_ENABLED=true
1205
- CONSOLIDATION_ENABLED=true
1206
- ```
1207
-
1208
- ### Umgebungsvariablen
1209
-
1210
- `~/.agentmemory/.env` anlegen:
1211
-
1212
- ```env
1213
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1214
- # ANTHROPIC_API_KEY=sk-ant-...
1215
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1216
- # GEMINI_API_KEY=...
1217
- # OPENROUTER_API_KEY=...
1218
- # MINIMAX_API_KEY=...
1219
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1220
- # # OpenAI LLM provider (here) AND the OpenAI
1221
- # # embedding provider (further below). Set
1222
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1223
- # # to embeddings only.
1224
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1225
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1226
- # # Auto-detected from `.openai.azure.com` hostname; uses
1227
- # # api-key header + api-version query param.
1228
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1229
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1230
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1231
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1232
- # # for back-compat with v0.9.17. New configs should
1233
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1234
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1235
- # # Honored only by OpenAI's reasoning models (o1, o3,
1236
- # # gpt-*-reasoning) and providers that mirror that
1237
- # # schema (Ollama Cloud thinking models). Standard
1238
- # # chat models reject this field with 400. Set to
1239
- # # "none" for thinking models that return reasoning
1240
- # # but no content.
1241
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1242
- # # for LLM (useful if you only want OpenAI for embeddings)
1243
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1244
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1245
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1246
-
1247
- # Embedding provider (auto-detected, or override)
1248
- # EMBEDDING_PROVIDER=local
1249
- # VOYAGE_API_KEY=...
1250
- # OPENAI_API_KEY=sk-...
1251
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1252
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1253
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1254
-
1255
- # Outbound LLM / embedding timeout
1256
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1257
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1258
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1259
- # embedding). For the OpenAI LLM path, the
1260
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1261
- # takes precedence when set, for back-compat
1262
- # with v0.9.17.
1263
- # Increase for slow networks or large batch calls;
1264
- # decrease to fail-fast on rate-limit holds.
1265
-
1266
- # Search tuning
1267
- # BM25_WEIGHT=0.4
1268
- # VECTOR_WEIGHT=0.6
1269
- # TOKEN_BUDGET=2000
1270
-
1271
- # Auth
1272
- # AGENTMEMORY_SECRET=your-secret
1273
-
1274
- # Ports (defaults: 3111 API, 3113 viewer)
1275
- # III_REST_PORT=3111
1276
-
1277
- # Features
1278
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1279
- # every PostToolUse hook calls your
1280
- # LLM provider to compress the
1281
- # observation — expect significant
1282
- # token spend on active sessions.
1283
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1284
- # memory slots — persona,
1285
- # user_preferences, tool_guidelines,
1286
- # project_context, guidance,
1287
- # pending_items, session_patterns,
1288
- # self_notes. Size-limited; agent
1289
- # edits via memory_slot_* tools.
1290
- # Pinned slots addressable for
1291
- # SessionStart injection.
1292
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1293
- # Stop hook fires mem::slot-reflect:
1294
- # scans recent observations, auto-
1295
- # appends TODOs to pending_items,
1296
- # counts patterns in
1297
- # session_patterns, records touched
1298
- # files in project_context. Fire-
1299
- # and-forget; does not block.
1300
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1301
- # - SessionStart may inject ~1-2K
1302
- # chars of project context into
1303
- # the first turn of each session
1304
- # (this is what actually reaches
1305
- # the model — Claude Code treats
1306
- # SessionStart stdout as context)
1307
- # - PreToolUse fires /agentmemory/enrich
1308
- # on every file-touching tool call
1309
- # (resource cleanup, not a token
1310
- # fix — PreToolUse stdout is debug
1311
- # log only per Claude Code docs)
1312
- # Observations are still captured via
1313
- # PostToolUse regardless of this flag.
1314
- # GRAPH_EXTRACTION_ENABLED=false
1315
- # CONSOLIDATION_ENABLED=true
1316
- # LESSON_DECAY_ENABLED=true
1317
- # OBSIDIAN_AUTO_EXPORT=false
1318
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1319
- # CLAUDE_MEMORY_BRIDGE=false
1320
- # SNAPSHOT_ENABLED=false
1321
-
1322
- # Team
1323
- # TEAM_ID=
1324
- # USER_ID=
1325
- # TEAM_MODE=private
1326
-
1327
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1328
- # AGENTMEMORY_TOOLS=core
1329
- ```
1330
-
1331
- ---
1332
-
1333
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1334
-
1335
- 124 Endpunkte auf Port `3111`. Die REST API bindet sich standardmäßig an `127.0.0.1`. Geschützte Endpunkte verlangen `Authorization: Bearer <secret>`, wenn `AGENTMEMORY_SECRET` gesetzt ist, und Mesh-Sync-Endpunkte erfordern `AGENTMEMORY_SECRET` auf beiden Peers.
1336
-
1337
- <details>
1338
- <summary>Wichtige Endpunkte</summary>
1339
-
1340
- | Methode | Pfad | Beschreibung |
1341
- |--------|------|-------------|
1342
- | `GET` | `/agentmemory/health` | Health-Check (immer öffentlich) |
1343
- | `POST` | `/agentmemory/session/start` | Session starten + Kontext holen |
1344
- | `POST` | `/agentmemory/session/end` | Session beenden |
1345
- | `POST` | `/agentmemory/observe` | Beobachtung erfassen |
1346
- | `POST` | `/agentmemory/smart-search` | Hybride Suche |
1347
- | `POST` | `/agentmemory/context` | Kontext erzeugen |
1348
- | `POST` | `/agentmemory/remember` | In Langzeit-Memory speichern |
1349
- | `POST` | `/agentmemory/forget` | Beobachtungen löschen |
1350
- | `POST` | `/agentmemory/enrich` | Dateikontext + Erinnerungen + Bugs |
1351
- | `GET` | `/agentmemory/profile` | Projektprofil |
1352
- | `GET` | `/agentmemory/export` | Alle Daten exportieren |
1353
- | `POST` | `/agentmemory/import` | Aus JSON importieren |
1354
- | `POST` | `/agentmemory/graph/query` | Knowledge-Graph-Anfrage |
1355
- | `POST` | `/agentmemory/team/share` | Mit Team teilen |
1356
- | `GET` | `/agentmemory/audit` | Audit-Trail |
1357
-
1358
- Volle Endpunktliste: [`src/triggers/api.ts`](../src/triggers/api.ts)
1359
-
1360
- </details>
1361
-
1362
- ---
1363
-
1364
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Entwicklung" height="32" /></picture></h2>
1365
-
1366
- ```bash
1367
- npm run dev # Hot reload
1368
- npm run build # Production build
1369
- npm test # 950+ tests
1370
- npm run test:integration # API tests (requires running services)
1371
- ```
1372
-
1373
- **Voraussetzungen:** Node.js >= 20, [iii-engine](https://iii.dev/docs) oder Docker
1374
-
1375
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Lizenz" height="32" /></picture></h2>
1376
-
1377
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.es-ES.md DELETED
@@ -1,1370 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — Memoria persistente para agentes de codificación con IA" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- Tu agente de codificación lo recuerda todo. Se acabó volver a explicarlo.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Memoria persistente para Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode y cualquier cliente MCP.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- Español |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Documento de diseño: 1200 stars / 172 forks en el gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>El gist extiende el patrón LLM Wiki de Karpathy con puntuación de confianza, ciclo de vida, grafos de conocimiento y búsqueda híbrida: agentmemory es la implementación.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="Demostración de agentmemory" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">Instalación</a> &bull;
73
- <a href="#quick-start">Inicio rápido</a> &bull;
74
- <a href="#benchmarks">Benchmarks</a> &bull;
75
- <a href="#vs-competitors">Comparativa</a> &bull;
76
- <a href="#works-with-every-agent">Agentes</a> &bull;
77
- <a href="#how-it-works">Cómo funciona</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">Visor</a> &bull;
80
- <a href="#iii-console">iii Console</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">Configuración</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Install
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # start the memory server on :3111
95
- agentmemory demo # seed sample sessions + prove recall
96
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- O mediante `npx` (sin instalación):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- Aviso — npx cachea por versión. Si un simple `npx @agentmemory/agentmemory` sirve una versión antigua, fuerza la última con `npx -y @agentmemory/agentmemory@latest`, o limpia la caché una vez con `rm -rf ~/.npm/_npx` (macOS/Linux; en Windows borra `%LOCALAPPDATA%\npm-cache\_npx`). La primera ejecución vía npx desde la v0.9.16+ pregunta si deseas instalar globalmente, de modo que el comando `agentmemory` quede disponible en cualquier lugar.
106
-
107
- Todas las opciones en [Inicio rápido](#quick-start) más abajo. Conexión específica por agente en [Funciona con cualquier agente](#works-with-every-agent).
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funciona con cualquier agente" height="32" /></picture></h2>
112
-
113
- agentmemory funciona con cualquier agente que soporte hooks, MCP o REST API. Todos los agentes comparten el mismo servidor de memoria.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>native plugin + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>native plugin + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>native plugin + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>native plugin + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>native plugin + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>native Memory trait backend</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP server</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP server</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP server</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP server</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP server</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP server</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP server</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP server</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>Funciona con <strong>cualquier</strong> agente que hable MCP o HTTP. Un único servidor, memorias compartidas entre todos ellos.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- Vuelves a explicar la misma arquitectura cada sesión. Vuelves a descubrir los mismos bugs. Vuelves a enseñar las mismas preferencias. La memoria integrada (CLAUDE.md, .cursorrules) se topa con un techo de 200 líneas y se queda obsoleta. agentmemory soluciona esto. Captura silenciosamente lo que hace tu agente, lo comprime en una memoria buscable e inyecta el contexto correcto al inicio de la siguiente sesión. Un único comando. Funciona en todos los agentes.
209
-
210
- **Qué cambia:** En la sesión 1 configuras autenticación JWT. En la sesión 2 pides rate limiting. El agente ya sabe que tu autenticación usa el middleware jose en `src/middleware/auth.ts`, que tus pruebas cubren la validación de tokens y que elegiste jose en lugar de jsonwebtoken por compatibilidad con Edge. Sin volver a explicar. Sin copiar y pegar. El agente simplemente lo *sabe*.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **Novedad en v0.9.0** — Sitio de aterrizaje en [agent-memory.dev](https://agent-memory.dev), conector de sistema de ficheros (`@agentmemory/fs-watcher`), el MCP standalone ahora hace de proxy al servidor en ejecución, por lo que los hooks y el visor coinciden, política de auditoría codificada en cada ruta de borrado, y health deja de marcar `memory_critical` en procesos Node pequeños. Notas completas en [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Precisión de recuperación
227
-
228
- **coding-agent-life-v1** (corpus interno, reproducible en sandbox)
229
-
230
- | Adaptador | P@5 | R@5 | Tasa de aciertos top-5 | Latencia p50 |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- Tasa de aciertos top-5 del 100%. Precisión **2,2×** mejor que la baseline grep con la misma entrada. Desglose completo por tipo: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 preguntas)
238
-
239
- | Sistema | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Ahorro de tokens
248
-
249
- | Enfoque | Tokens/año | Coste/año |
250
- |---|---|---|
251
- | Pegar todo el contexto | 19.5M+ | Imposible (excede la ventana) |
252
- | Resumido por LLM | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + embeddings locales | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Modelo de embedding: `all-MiniLM-L6-v2` (local, gratuito, sin API key). Informes completos: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparativa con la competencia: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory frente a mem0, Letta, Khoj, claude-mem, Hippo.
261
-
262
- **Reproduce en local:** [`eval/README.md`](../eval/README.md) — un harness con adaptadores intercambiables para LongMemEval `_s` (500-Q públicas) y `coding-agent-life-v1` (corpus interno de 15 sesiones). Los adaptadores grep / vector / agentmemory se puntúan en paralelo, salida NDJSON, y las scorecards publicadas quedan en [`docs/benchmarks/`](../docs/benchmarks/).
263
-
264
- **Funciona muy bien con [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) y [Graphify](https://github.com/safishamsi/graphify).** Indexado de grafos de código, pipelines de build multiagente y grafos de conocimiento más amplios sobre documentos / PDFs / imágenes / vídeos. agentmemory recuerda el trabajo; esos tres proyectos iluminan el resto de la capa de contexto. Recetas y tabla de enrutamiento por pregunta: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Comparativa" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">Built-in (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>Tipo</strong></td>
280
- <td>Motor de memoria + servidor MCP</td>
281
- <td>API de capa de memoria</td>
282
- <td>Runtime de agente completo</td>
283
- <td>Fichero estático</td>
284
- </tr>
285
- <tr>
286
- <td><strong>Retrieval R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>Captura automática</strong></td>
294
- <td>12 hooks (esfuerzo manual cero)</td>
295
- <td>Llamadas manuales a <code>add()</code></td>
296
- <td>El agente se edita a sí mismo</td>
297
- <td>Edición manual</td>
298
- </tr>
299
- <tr>
300
- <td><strong>Búsqueda</strong></td>
301
- <td>BM25 + Vector + Graph (fusión RRF)</td>
302
- <td>Vector + Graph</td>
303
- <td>Vector (archival)</td>
304
- <td>Carga todo en contexto</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Multiagente</strong></td>
308
- <td>MCP + REST + leases + signals</td>
309
- <td>API (sin coordinación)</td>
310
- <td>Solo dentro del runtime de Letta</td>
311
- <td>Ficheros por agente</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Dependencia de framework</strong></td>
315
- <td>Ninguna (cualquier cliente MCP)</td>
316
- <td>Ninguna</td>
317
- <td>Alta (obliga a usar Letta)</td>
318
- <td>Formato por agente</td>
319
- </tr>
320
- <tr>
321
- <td><strong>Dependencias externas</strong></td>
322
- <td>Ninguna (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + BD vectorial</td>
325
- <td>Ninguna</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Ciclo de vida de memoria</strong></td>
329
- <td>Consolidación de 4 niveles + decaimiento + auto-olvido</td>
330
- <td>Extracción pasiva</td>
331
- <td>Gestionado por el agente</td>
332
- <td>Poda manual</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Eficiencia de tokens</strong></td>
336
- <td>~1.900 tokens/sesión ($10/año)</td>
337
- <td>Varía según la integración</td>
338
- <td>Memoria principal en contexto</td>
339
- <td>22K+ tokens con 240 obs</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Visor en tiempo real</strong></td>
343
- <td>Sí (port 3113)</td>
344
- <td>Dashboard en la nube</td>
345
- <td>Dashboard en la nube</td>
346
- <td>No</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Self-hosted</strong></td>
350
- <td>Sí (por defecto)</td>
351
- <td>Opcional</td>
352
- <td>Opcional</td>
353
- <td>Sí</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Inicio rápido" height="32" /></picture></h2>
360
-
361
- Compatibilidad: esta release apunta a `iii-sdk` estable `^0.11.0` e iii-engine v0.11.x.
362
-
363
- ### Pruébalo en 30 segundos
364
-
365
- ```bash
366
- # Terminal 1: start the server
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: seed sample data and see recall in action
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` siembra 3 sesiones realistas (autenticación JWT, corrección de N+1 queries, rate limiting) y ejecuta búsquedas semánticas sobre ellas. Verás cómo encuentra "N+1 query fix" al buscar "database performance optimization" — algo que la coincidencia por palabra clave no puede hacer.
374
-
375
- Abre `http://localhost:3113` para ver cómo se construye la memoria en directo.
376
-
377
- ### Recomendado: instala globalmente
378
-
379
- `npx` cachea por versión. Si la semana pasada ejecutaste `npx @agentmemory/agentmemory@0.9.14`, un simple `npx @agentmemory/agentmemory` puede servir la versión obsoleta 0.9.14 desde `~/.npm/_npx/`, y no la última. Instala una vez y el comando `agentmemory` funciona en cualquier sitio:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # start the server (same as the npx form)
386
- agentmemory stop # tear it down
387
- agentmemory remove # uninstall everything we created
388
- agentmemory connect claude-code # wire one agent
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- A partir de v0.9.16, la primera ejecución vía npx pregunta si deseas instalar globalmente — responde `Y` una vez y listo. Si lo saltas, recurre a cualquiera de estos para un fetch limpio:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
- ```
398
-
399
- En Windows / PowerShell, el equivalente para limpiar caché es `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — la opción `npx -y ...@latest` de arriba es la alternativa multiplataforma.
400
-
401
- ### Session Replay
402
-
403
- Toda sesión que agentmemory registra es reproducible. Abre el visor, elige la pestaña **Replay** y desplázate por la línea de tiempo: prompts, llamadas a herramientas, resultados y respuestas se renderizan como eventos discretos con play/pause, control de velocidad (0,5×–4×) y atajos de teclado (espacio para alternar, flechas para avanzar paso a paso).
404
-
405
- ¿Ya tienes transcripciones JSONL antiguas de Claude Code que quieras importar?
406
-
407
- ```bash
408
- # Import everything under the default ~/.claude/projects
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Or import a single file
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- Las sesiones importadas aparecen en el selector de Replay junto a las nativas. Por debajo, cada entrada se enruta a través de las funciones iii `mem::replay::load`, `mem::replay::sessions` y `mem::replay::import-jsonl` — sin servidores side-channel.
416
-
417
- ### Actualización / Mantenimiento
418
-
419
- Usa el comando de mantenimiento cuando intencionadamente quieras actualizar tu runtime local:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- Aviso: este comando muta el workspace/runtime actual. Puede actualizar dependencias de JavaScript, puede ejecutar `cargo install iii-engine --force`, y puede traer imágenes Docker.
426
-
427
- Los detalles de implementación están en `src/cli.ts` (ver `runUpgrade` en torno a la región `src/cli.ts:544-595`).
428
-
429
- ### Claude Code (un bloque, pégalo)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code sin instalar el plugin (ruta MCP standalone)
436
-
437
- Si conectas el servidor MCP de agentmemory directamente vía `~/.claude.json` en lugar de usar `/plugin install`, Claude Code nunca resuelve `${CLAUDE_PLUGIN_ROOT}` y tienes que apuntar los scripts de hook a rutas absolutas en `~/.claude/settings.json`. Esas rutas suelen incluir la versión de agentmemory (p. ej. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), por lo que la siguiente actualización rompe silenciosamente todos los hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- Solución:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- Esto fusiona los mismos comandos de hook en `~/.claude/settings.json` con rutas absolutas que apuntan al directorio `plugin/` empaquetado del paquete `@agentmemory/agentmemory` actualmente instalado. Vuelve a ejecutar el comando tras actualizar agentmemory para refrescar las rutas. Las entradas de usuario en el mismo fichero se preservan; solo se reemplazan las entradas previas de agentmemory. La ruta vía `/plugin install` sigue siendo la recomendada.
446
- Para despliegues remotos o protegidos, lanza Claude Code con `AGENTMEMORY_URL` y `AGENTMEMORY_SECRET` definidos. El plugin pasa ambos valores a su servidor MCP empaquetado; cuando `AGENTMEMORY_URL` está vacío, el shim MCP usa `http://localhost:3111`.
447
-
448
- ### Codex CLI (plataforma de plugins Codex)
449
-
450
- ```bash
451
- # 1. start the memory server in a separate terminal
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. register the agentmemory marketplace and install the plugin
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- El plugin de Codex se sirve desde el mismo directorio `plugin/` que el de Claude Code. Registra:
460
-
461
- - `@agentmemory/mcp` como servidor MCP (hace de proxy a las 51 tools cuando `AGENTMEMORY_URL` apunta a un servidor agentmemory en ejecución; cae a 7 tools en local cuando no hay servidor accesible)
462
- - 6 hooks de ciclo de vida: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- El motor de hooks de Codex inyecta `CLAUDE_PLUGIN_ROOT` en los subprocesos de hook (según [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), por lo que los mismos scripts de hook funcionan en ambos hosts sin duplicación. Los eventos Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure son exclusivos de Claude Code y no se registran para Codex.
466
-
467
- #### Codex Desktop: los hooks del plugin están silenciados (con workaround)
468
-
469
- `CodexHooks` y `PluginHooks` son estables y están activados por defecto en [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), pero las builds actuales de Codex Desktop no despachan el `hooks.json` local del plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). Las tools MCP siguen funcionando; solo faltan las observaciones del ciclo de vida.
470
-
471
- Hasta que se solucione upstream, replica los mismos comandos de hook en el `~/.codex/hooks.json` global:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- Esto añade un bloque idempotente a `~/.codex/hooks.json` que referencia rutas absolutas a los scripts empaquetados (no hace falta expandir `${CLAUDE_PLUGIN_ROOT}` en el ámbito de usuario). Vuelve a ejecutar el mismo comando tras actualizar agentmemory para refrescar las rutas. Las entradas de usuario en el mismo fichero se preservan; solo se reemplazan las entradas previas de agentmemory.
478
-
479
- <details>
480
- <summary><b>OpenClaw (pega este prompt)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- Guía completa: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (pega este prompt)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- Guía completa: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### Otros agentes
526
-
527
- Arranca el servidor de memoria: `npx @agentmemory/agentmemory`
528
-
529
- La entrada de agentmemory es el **mismo bloque de servidor MCP** en cada host que use la forma `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **Fusiona esta entrada en el objeto `mcpServers` existente** en el fichero de configuración del host — no reemplaces el fichero. Si el fichero ya contiene otros servidores, añade `agentmemory` junto a ellos como otra clave dentro de `mcpServers`. Si `mcpServers` no existe, pega el bloque dentro de `{ "mcpServers": { ... } }`. Los marcadores `${VAR}` heredan `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` del shell al lanzar el servidor MCP — si no están definidas se pasan como cadena vacía y el shim cae a `http://localhost:3111`. Una sola entrada cubre tanto despliegues locales como remotos (k8s / con reverse-proxy).
543
-
544
- | Agente | Fichero de configuración | Notas |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | Fusiona en `mcpServers`. También hay deeplink de un clic en el sitio web. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Fusiona en `mcpServers`. Reinicia Claude Desktop tras editar. |
548
- | **Cline / Roo Code / Kilo Code** | Ajustes MCP de Cline (Settings UI → MCP Servers → Edit) | Mismo bloque `mcpServers`. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Mismo bloque `mcpServers`. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (fusión automática). |
551
- | **OpenClaw** | Configuración MCP de OpenClaw | Mismo bloque `mcpServers`, o usa el [memory plugin](../integrations/openclaw/) más profundo. |
552
- | **Codex CLI (solo MCP)** | `.codex/config.toml` | Forma TOML: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, o añade `[mcp_servers.agentmemory]` a mano. |
553
- | **Codex CLI (plugin completo)** | Marketplace de plugins Codex | `codex plugin marketplace add rohitg00/agentmemory` y luego `codex plugin add agentmemory@agentmemory`. Registra MCP + 6 hooks de ciclo de vida (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. En Codex Desktop, ejecuta también `agentmemory connect codex --with-hooks` hasta que se mergee [openai/codex#16430](https://github.com/openai/codex/issues/16430) — los hooks de plugin están silenciados allí. |
554
- | **OpenCode (solo MCP)** | `opencode.json` | Forma distinta — clave `mcp` en el nivel superior, comando como array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (plugin completo)** | `plugin/opencode/` | 22 hooks de captura automática que cubren ciclo de vida de sesión, mensajes, tools y errores. Dos comandos slash (`/recall`, `/remember`). Copia `plugin/opencode/` a tu workspace de OpenCode y añade la entrada del plugin a `opencode.json`. Tabla completa de hooks + análisis de gaps en [`plugin/opencode/README.md`](../plugin/opencode/README.md). |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | Copia [`integrations/pi`](../integrations/pi/) y reinicia pi. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | Usa el [memory provider plugin](../integrations/hermes/) más profundo con `memory.provider: agentmemory`. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` escribe el bloque `mcpServers` estándar. El payload de los hooks es compatible a nivel de campo con Claude Code, así que los scripts de los 12 hooks existentes funcionan sin modificación — conéctalos en la sección `hooks` del mismo `settings.json`. |
559
- | **Antigravity** (sustituye a Gemini CLI) | `mcp_config.json` (en el directorio User de Antigravity) | `agentmemory connect antigravity` escribe el bloque `mcpServers` estándar. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Úsalo tras el sunset de Gemini CLI del 2026-06-18. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` escribe la configuración de nivel usuario. Los overrides por workspace van en `.kiro/settings/mcp.json` junto a tu código. |
561
- | **Goose** | UI de ajustes MCP de Goose | Mismo bloque `mcpServers`. |
562
- | **Aider** | n/a | Habla directamente con la REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **Cualquier agente (32+)** | n/a | `npx skillkit install agentmemory` auto-detecta el host y fusiona. |
564
-
565
- **Clientes MCP en sandbox** (Flatpak / Snap / contenedores restrictivos) que no pueden alcanzar el `localhost` del host: añade también `"AGENTMEMORY_FORCE_PROXY": "1"` al bloque `env`, y apunta `AGENTMEMORY_URL` a una ruta que el sandbox sí pueda alcanzar (p. ej. tu IP de LAN). Consulta [#234](https://github.com/rohitg00/agentmemory/issues/234) para el walkthrough de diagnóstico.
566
-
567
- ### Acceso programático (Python / Rust / Node)
568
-
569
- agentmemory registra sus operaciones principales como funciones iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Cualquier lenguaje con un SDK iii puede llamarlas directamente sobre `ws://localhost:49134` — sin un cliente REST separado por lenguaje.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- Ejemplo trabajado: [`examples/python/`](../examples/python/) (quickstart + flujo de observación/recall). La REST en `:3111` sigue disponible para hosts sin runtime iii.
590
-
591
- ### Desde el código fuente
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- Esto arranca agentmemory con un `iii-engine` local si `iii` ya está instalado, o cae a Docker Compose si hay Docker disponible. REST, streams y el visor se enlazan a `127.0.0.1` por defecto.
599
-
600
- Instala `iii-engine` manualmente. **agentmemory actualmente fija `iii-engine` a `v0.11.2`** — `v0.11.6` introduce un nuevo modelo que sandboxea todo vía `iii worker add`, y agentmemory aún no se ha refactorizado para él. La fijación se levantará cuando aterrice el refactor. Sobrescribe con `AGENTMEMORY_III_VERSION=<version>` si has migrado al modelo sandbox manualmente.
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** cambia `aarch64-apple-darwin` por `x86_64-apple-darwin`
604
- - **Linux x64:** cambia por `x86_64-unknown-linux-gnu`
605
- - **Linux arm64:** cambia por `aarch64-unknown-linux-gnu`
606
- - **Windows:** descarga `iii-x86_64-pc-windows-msvc.zip` desde [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extrae `iii.exe`, añádelo al PATH
607
-
608
- O usa Docker (el `docker-compose.yml` empaquetado descarga `iiidev/iii:0.11.2`). Documentación completa: [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory funciona en Windows 10/11, pero el paquete de Node.js por sí solo no es suficiente — también necesitas el runtime `iii-engine` (un binario nativo aparte) como proceso en segundo plano. El instalador oficial upstream es un script `sh` y hoy no existe un instalador PowerShell ni paquete scoop/winget, así que los usuarios de Windows tienen dos rutas:
613
-
614
- **Opción A — Binario Windows preconstruido (recomendado):**
615
-
616
- ```powershell
617
- # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
- # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
- # model that engine v0.11.6+ requires)
620
- # 2. Download iii-x86_64-pc-windows-msvc.zip
621
- # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
- # 3. Extract iii.exe somewhere on PATH, or place it at:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory checks that location automatically)
625
- # 4. Verify:
626
- iii --version
627
- # Should print: 0.11.2
628
-
629
- # 5. Then run agentmemory as usual:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **Opción B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Install Docker Desktop for Windows
637
- # 2. Start Docker Desktop and make sure the engine is running
638
- # 3. Run agentmemory — it will auto-start the bundled compose file:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **Opción C — Solo MCP standalone (sin engine):** si solo necesitas las tools MCP para tu agente y no necesitas la REST API, el visor ni los cron jobs, sáltate el engine por completo:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # or via the shim package:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Diagnóstico para Windows:** si `npx @agentmemory/agentmemory` falla, vuelve a ejecutar con `--verbose` para ver el stderr real del engine. Modos de fallo habituales:
651
-
652
- | Síntoma | Solución |
653
- |---|---|
654
- | `iii-engine process started` seguido de `did not become ready within 15s` | El engine ha crasheado al arrancar — reejecuta con `--verbose` y revisa stderr |
655
- | `Could not start iii-engine` | Ni `iii.exe` ni Docker están instalados. Ver Opción A o B |
656
- | Conflicto de puerto | `netstat -ano \| findstr :3111` para ver qué está vinculado, mátalo o usa `--port <N>` |
657
- | Se omite el fallback a Docker aunque Docker esté instalado | Asegúrate de que Docker Desktop esté efectivamente en ejecución (icono en la bandeja del sistema) |
658
-
659
- > Nota: no existe `cargo install iii-engine` — `iii` no está publicado en crates.io. Los únicos métodos de instalación soportados son el binario preconstruido de arriba, el script `sh` upstream (solo macOS/Linux) y la imagen Docker.
660
-
661
- ---
662
-
663
- <h2 id="deploy">Deploy</h2>
664
-
665
- Plantillas de un clic para hosts gestionados. Cada una incluye un
666
- Dockerfile autocontenido que descarga `@agentmemory/agentmemory` desde npm
667
- y copia el binario del iii engine desde la imagen oficial `iiidev/iii` de
668
- Docker Hub — no se requiere una imagen preconstruida de agentmemory. El
669
- almacenamiento persistente se monta en `/data`; el entrypoint del primer
670
- arranque sobrescribe la configuración iii empaquetada por npm (que se
671
- enlaza a `127.0.0.1`) por una afinada para despliegue que se enlaza a
672
- `0.0.0.0` y usa rutas absolutas `/data`, genera el secreto HMAC y
673
- baja privilegios de `root` a `node` con `gosu` antes de hacer exec
674
- del CLI de agentmemory.
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- El botón de despliegue de un clic de Render requiere un `render.yaml` en la raíz del repo, que mantenemos limpio a propósito. Usa el flujo Render Blueprint documentado en [`deploy/render/`](../deploy/render/README.md) para apuntar al blueprint del repo manualmente.
682
-
683
- Los detalles completos de configuración (captura HMAC, túnel SSH del visor, rotación, backup, mínimos de coste) están en [`deploy/`](../deploy/README.md):
684
-
685
- - [`deploy/fly`](../deploy/fly/README.md) — máquina única con `auto_stop_machines = "stop"`; más barato en idle.
686
- - [`deploy/railway`](../deploy/railway/README.md) — tarifa plana del plan Hobby, volumen en el dashboard.
687
- - [`deploy/render`](../deploy/render/README.md) — flujo Blueprint, snapshots automáticos de disco en planes de pago.
688
- - [`deploy/coolify`](../deploy/coolify/README.md) — self-hosted en tu propio VPS vía [Coolify](https://coolify.io/self-hosted); misma stack Docker Compose, tú eres dueño del host y los datos.
689
-
690
- Solo se publica el puerto `3111`. El visor en `3113` permanece enlazado a loopback dentro del contenedor — el README de cada plantilla documenta el patrón de túnel SSH para alcanzarlo.
691
-
692
- ---
693
-
694
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Por qué agentmemory" height="32" /></picture></h2>
695
-
696
- Todo agente de codificación olvida todo al terminar la sesión. Pierdes los primeros 5 minutos de cada sesión re-explicando tu stack. agentmemory corre en segundo plano y lo elimina por completo.
697
-
698
- ```text
699
- Session 1: "Add auth to the API"
700
- Agent writes code, runs tests, fixes bugs
701
- agentmemory silently captures every tool use
702
- Session ends -> observations compressed into structured memory
703
-
704
- Session 2: "Now add rate limiting"
705
- Agent already knows:
706
- - Auth uses JWT middleware in src/middleware/auth.ts
707
- - Tests in test/auth.test.ts cover token validation
708
- - You chose jose over jsonwebtoken for Edge compatibility
709
- Zero re-explaining. Starts working immediately.
710
- ```
711
-
712
- ### Frente a la memoria integrada del agente
713
-
714
- Todo agente de codificación con IA viene con memoria integrada — Claude Code tiene `MEMORY.md`, Cursor tiene notepads, Cline tiene memory bank. Funcionan como notas adhesivas. agentmemory es la base de datos buscable que hay detrás de esas notas adhesivas.
715
-
716
- | | Integrada (CLAUDE.md) | agentmemory |
717
- |---|---|---|
718
- | Escala | tope de 200 líneas | Ilimitado |
719
- | Búsqueda | Carga todo en contexto | BM25 + vector + graph (solo top-K) |
720
- | Coste en tokens | 22K+ con 240 observaciones | ~1.900 tokens (92% menos) |
721
- | Cross-agent | Ficheros por agente | MCP + REST (cualquier agente) |
722
- | Coordinación | Ninguna | Leases, signals, actions, routines |
723
- | Observabilidad | Lectura manual de ficheros | Visor en tiempo real en :3113 |
724
-
725
- ---
726
-
727
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Cómo funciona" height="32" /></picture></h2>
728
-
729
- ### Pipeline de memoria
730
-
731
- ```text
732
- PostToolUse hook fires
733
- -> SHA-256 dedup (5min window)
734
- -> Privacy filter (strip secrets, API keys)
735
- -> Store raw observation
736
- -> LLM compress -> structured facts + concepts + narrative
737
- -> Vector embedding (6 providers + local)
738
- -> Index in BM25 + vector
739
-
740
- Stop / SessionEnd hook fires
741
- -> Summarize session
742
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
743
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
744
-
745
- SessionStart hook fires
746
- -> Load project profile (top concepts, files, patterns)
747
- -> Hybrid search (BM25 + vector + graph)
748
- -> Token budget (default: 2000 tokens)
749
- -> Inject into conversation
750
- ```
751
-
752
- ### Consolidación de memoria en 4 niveles
753
-
754
- Inspirada en cómo el cerebro humano procesa la memoria — no muy diferente de la consolidación del sueño.
755
-
756
- | Nivel | Qué | Analogía |
757
- |------|------|---------|
758
- | **Working** | Observaciones crudas a partir del uso de tools | Memoria a corto plazo |
759
- | **Episodic** | Resúmenes de sesión comprimidos | "Qué pasó" |
760
- | **Semantic** | Hechos y patrones extraídos | "Lo que sé" |
761
- | **Procedural** | Workflows y patrones de decisión | "Cómo hacerlo" |
762
-
763
- Las memorias decaen con el tiempo (curva de Ebbinghaus). Las memorias accedidas con frecuencia se refuerzan. Las memorias obsoletas se evictan automáticamente. Las contradicciones se detectan y resuelven.
764
-
765
- ### Qué se captura
766
-
767
- | Hook | Captura |
768
- |------|----------|
769
- | `SessionStart` | Ruta de proyecto, ID de sesión |
770
- | `UserPromptSubmit` | Prompts del usuario (con filtro de privacidad) |
771
- | `PreToolUse` | Patrones de acceso a ficheros + contexto enriquecido |
772
- | `PostToolUse` | Nombre de la tool, entrada, salida |
773
- | `PostToolUseFailure` | Contexto del error |
774
- | `PreCompact` | Re-inyecta memoria antes de la compactación |
775
- | `SubagentStart/Stop` | Ciclo de vida de sub-agentes |
776
- | `Stop` | Resumen de fin de sesión |
777
- | `SessionEnd` | Marcador de sesión completa |
778
-
779
- ### Capacidades clave
780
-
781
- | Capacidad | Descripción |
782
- |---|---|
783
- | **Captura automática** | Cada uso de tool registrado vía hooks — esfuerzo manual cero |
784
- | **Búsqueda semántica** | BM25 + vector + grafo de conocimiento con fusión RRF |
785
- | **Evolución de memoria** | Versionado, supersesión, grafos de relaciones |
786
- | **Auto-olvido** | Expiración por TTL, detección de contradicciones, evicción por importancia |
787
- | **Privacy first** | API keys, secretos y etiquetas `<private>` se eliminan antes del almacenado |
788
- | **Self-healing** | Circuit breaker, cadena de fallback de proveedores, monitorización de salud |
789
- | **Puente Claude** | Sincronización bidireccional con MEMORY.md |
790
- | **Grafo de conocimiento** | Extracción de entidades + recorrido BFS |
791
- | **Memoria de equipo** | Espacios compartidos y privados con namespace por miembro |
792
- | **Provenance de citas** | Traza cualquier memoria de vuelta a las observaciones origen |
793
- | **Snapshots de Git** | Versiona, revierte y diffea el estado de memoria |
794
-
795
- ---
796
-
797
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Búsqueda" height="32" /></picture></h2>
798
-
799
- Recuperación de triple stream combinando tres señales:
800
-
801
- | Stream | Qué hace | Cuándo |
802
- |---|---|---|
803
- | **BM25** | Coincidencia por palabras con stemming y expansión de sinónimos | Siempre activo |
804
- | **Vector** | Similitud coseno sobre embeddings densos | Proveedor de embeddings configurado |
805
- | **Graph** | Recorrido del grafo de conocimiento vía coincidencia de entidades | Entidades detectadas en la consulta |
806
-
807
- Fusionado con Reciprocal Rank Fusion (RRF, k=60) y diversificado por sesión (máximo 3 resultados por sesión).
808
-
809
- BM25 tokeniza griego, cirílico, hebreo, árabe y latín con tildes de serie. Para memorias en chino / japonés / coreano, instala los segmentadores opcionales (`npm install @node-rs/jieba tiny-segmenter`) para partir los runs CJK en tokens a nivel de palabra; sin ellos, agentmemory hace soft-fallback a tokenización por run completo y muestra una pista única en stderr.
810
-
811
- ### Proveedores de embedding
812
-
813
- agentmemory autodetecta tu proveedor. Para mejores resultados, instala embeddings locales (gratis):
814
-
815
- ```bash
816
- npm install @xenova/transformers
817
- ```
818
-
819
- | Proveedor | Modelo | Coste | Notas |
820
- |---|---|---|---|
821
- | **Local (recomendado)** | `all-MiniLM-L6-v2` | Gratis | Offline, +8pp de recall sobre BM25-only |
822
- | Gemini | `gemini-embedding-001` | Free tier | 100+ idiomas, 768/1536/3072 dims (MRL), entrada de 2048 tokens. Sustituye a `text-embedding-004` ([deprecado, cierre el 14 ene 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
823
- | OpenAI | `text-embedding-3-small` | $0.02/1M | Máxima calidad |
824
- | Voyage AI | `voyage-code-3` | De pago | Optimizado para código |
825
- | Cohere | `embed-english-v3.0` | Trial gratis | Uso general |
826
- | OpenRouter | Cualquier modelo | Varía | Proxy multi-modelo |
827
-
828
- ---
829
-
830
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Servidor MCP" height="32" /></picture></h2>
831
-
832
- 53 tools, 6 recursos, 3 prompts y 4 skills — el toolkit MCP de memoria más completo para cualquier agente.
833
-
834
- > **Shim MCP vs servidor completo:** el paquete publicado `@agentmemory/mcp` es un shim ligero. Expone la superficie completa de 51 tools **solo cuando puede alcanzar un servidor agentmemory en ejecución** vía `AGENTMEMORY_URL` (modo proxy). Sin servidor accesible, el shim cae a un set local de 7 tools (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). La variable de entorno `AGENTMEMORY_TOOLS=core|all` es un flag *del lado del servidor* — definirla en el bloque `env` del shim no tiene efecto. Si ves solo 7 tools en Cursor / OpenCode / Gemini CLI, arranca `npx @agentmemory/agentmemory` (o la stack Docker) y define `AGENTMEMORY_URL=http://localhost:3111`.
835
-
836
- ### 51 Tools
837
-
838
- <details>
839
- <summary>Tools principales (siempre disponibles)</summary>
840
-
841
- | Tool | Descripción |
842
- |------|-------------|
843
- | `memory_recall` | Busca observaciones pasadas |
844
- | `memory_compress_file` | Comprime ficheros markdown preservando la estructura |
845
- | `memory_save` | Guarda un insight, decisión o patrón |
846
- | `memory_patterns` | Detecta patrones recurrentes |
847
- | `memory_smart_search` | Búsqueda híbrida semántica + por palabras |
848
- | `memory_file_history` | Observaciones pasadas sobre ficheros concretos |
849
- | `memory_sessions` | Lista sesiones recientes |
850
- | `memory_timeline` | Observaciones cronológicas |
851
- | `memory_profile` | Perfil de proyecto (conceptos, ficheros, patrones) |
852
- | `memory_export` | Exporta todos los datos de memoria |
853
- | `memory_relations` | Consulta el grafo de relaciones |
854
-
855
- </details>
856
-
857
- <details>
858
- <summary>Tools extendidas (51 en total — define AGENTMEMORY_TOOLS=all)</summary>
859
-
860
- | Tool | Descripción |
861
- |------|-------------|
862
- | `memory_patterns` | Detecta patrones recurrentes |
863
- | `memory_timeline` | Observaciones cronológicas |
864
- | `memory_relations` | Consulta el grafo de relaciones |
865
- | `memory_graph_query` | Recorrido del grafo de conocimiento |
866
- | `memory_consolidate` | Ejecuta la consolidación de 4 niveles |
867
- | `memory_claude_bridge_sync` | Sincroniza con MEMORY.md |
868
- | `memory_team_share` | Comparte con miembros del equipo |
869
- | `memory_team_feed` | Elementos compartidos recientes |
870
- | `memory_audit` | Pista de auditoría de operaciones |
871
- | `memory_governance_delete` | Borrado con pista de auditoría |
872
- | `memory_snapshot_create` | Snapshot versionado en Git |
873
- | `memory_action_create` | Crea ítems de trabajo con dependencias |
874
- | `memory_action_update` | Actualiza estado de una action |
875
- | `memory_frontier` | Actions desbloqueadas, ordenadas por prioridad |
876
- | `memory_next` | La única acción más importante a continuación |
877
- | `memory_lease` | Leases exclusivos de actions (multiagente) |
878
- | `memory_routine_run` | Instancia rutinas de workflow |
879
- | `memory_signal_send` | Mensajería entre agentes |
880
- | `memory_signal_read` | Lee mensajes con acuse de recibo |
881
- | `memory_checkpoint` | Gates de condiciones externas |
882
- | `memory_mesh_sync` | Sincronización P2P entre instancias |
883
- | `memory_sentinel_create` | Watchers dirigidos por eventos |
884
- | `memory_sentinel_trigger` | Dispara sentinels desde fuera |
885
- | `memory_sketch_create` | Grafos de actions efímeros |
886
- | `memory_sketch_promote` | Promociona a permanente |
887
- | `memory_crystallize` | Compacta cadenas de actions |
888
- | `memory_diagnose` | Health checks |
889
- | `memory_heal` | Repara automáticamente estado atascado |
890
- | `memory_facet_tag` | Tags dimension:value |
891
- | `memory_facet_query` | Consulta por tags de facet |
892
- | `memory_verify` | Traza provenance |
893
-
894
- </details>
895
-
896
- ### 6 Recursos · 3 Prompts · 4 Skills
897
-
898
- | Tipo | Nombre | Descripción |
899
- |------|------|-------------|
900
- | Resource | `agentmemory://status` | Salud, conteo de sesiones, conteo de memorias |
901
- | Resource | `agentmemory://project/{name}/profile` | Inteligencia por proyecto |
902
- | Resource | `agentmemory://memories/latest` | Las 10 memorias activas más recientes |
903
- | Resource | `agentmemory://graph/stats` | Estadísticas del grafo de conocimiento |
904
- | Prompt | `recall_context` | Búsqueda + devuelve mensajes de contexto |
905
- | Prompt | `session_handoff` | Datos de traspaso entre agentes |
906
- | Prompt | `detect_patterns` | Analiza patrones recurrentes |
907
- | Skill | `/recall` | Busca en memoria |
908
- | Skill | `/remember` | Guarda en memoria a largo plazo |
909
- | Skill | `/session-history` | Resúmenes recientes de sesiones |
910
- | Skill | `/forget` | Borra observaciones/sesiones |
911
-
912
- ### MCP standalone
913
-
914
- Ejecútalo sin el servidor completo — para cualquier cliente MCP. Cualquiera de estos funciona:
915
-
916
- ```bash
917
- npx -y @agentmemory/agentmemory mcp # canonical (always available)
918
- npx -y @agentmemory/mcp # shim package alias
919
- ```
920
-
921
- O añádelo a la configuración MCP de tu agente:
922
-
923
- La mayoría de los agentes (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
924
- ```json
925
- {
926
- "mcpServers": {
927
- "agentmemory": {
928
- "command": "npx",
929
- "args": ["-y", "@agentmemory/mcp"],
930
- "env": {
931
- "AGENTMEMORY_URL": "http://localhost:3111"
932
- }
933
- }
934
- }
935
- }
936
- ```
937
-
938
- Fusiona la entrada `agentmemory` en el objeto `mcpServers` existente del host en lugar de reemplazar el fichero. Para clientes en sandbox que no pueden alcanzar el `localhost` del host, añade `"AGENTMEMORY_FORCE_PROXY": "1"` al bloque env y define `AGENTMEMORY_URL` a una ruta a la que el sandbox sí pueda llegar.
939
-
940
- OpenCode (`opencode.json`):
941
- ```json
942
- {
943
- "mcp": {
944
- "agentmemory": {
945
- "type": "local",
946
- "command": ["npx", "-y", "@agentmemory/mcp"],
947
- "enabled": true
948
- }
949
- },
950
- "plugin": ["./plugins/agentmemory-capture.ts"]
951
- }
952
- ```
953
-
954
- Copia el fichero del plugin desde el repo:
955
- ```bash
956
- mkdir -p ~/.config/opencode/plugins
957
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
958
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
959
- ```
960
-
961
- ---
962
-
963
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Visor en tiempo real" height="32" /></picture></h2>
964
-
965
- Se inicia automáticamente en el puerto `3113`. Stream de observaciones en vivo, explorador de sesiones, navegador de memoria, visualización del grafo de conocimiento y dashboard de salud.
966
-
967
- ```bash
968
- open http://localhost:3113
969
- ```
970
-
971
- El servidor del visor se enlaza a `127.0.0.1` por defecto. El endpoint servido por REST `/agentmemory/viewer` sigue las reglas habituales de bearer-token `AGENTMEMORY_SECRET`. Las cabeceras CSP usan un nonce de script por respuesta y desactivan los atributos handler inline (`script-src-attr 'none'`).
972
-
973
- ---
974
-
975
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
976
-
977
- El visor en `:3113` muestra lo que tu agente **recordó**. La [iii console](https://iii.dev/docs/console) muestra lo que tu agente **hizo** — cada operación de memoria como una traza OpenTelemetry, cada entrada KV editable, cada función invocable, cada stream tappable. Dos ventanas sobre la misma memoria: una con forma de producto, otra con forma de motor.
978
-
979
- Mira cómo se dispara `memory_smart_search` y observa el escaneo BM25 → consulta de embedding → fusión RRF → reranker como un waterfall. Edita un temporizador de consolidación atascado en el navegador KV. Reproduce un hook `PostToolUse` con un payload ajustado. Fija el stream WebSocket y mira cómo aterrizan las observaciones en vivo.
980
-
981
- agentmemory ofrece esto gratis porque cada función, trigger, scope de estado y stream es un primitivo de iii — nada custom, nada que instrumentar.
982
-
983
- <p align="center">
984
- <img src="../assets/iii-console/workers.png" alt="Página Workers de iii console — workers conectados incluyendo instancias de agentmemory con conteo de funciones en vivo y metadatos de runtime" width="720" />
985
- <br/>
986
- <em>Página Workers: cada worker conectado — incluida agentmemory — con PID, conteo de funciones, runtime y last-seen.</em>
987
- </p>
988
-
989
- **Ya instalada.** La console se incluye con `iii` — sin instalador aparte.
990
-
991
- **Lánzala junto a agentmemory:**
992
-
993
- ```bash
994
- # agentmemory viewer holds port 3113, so run the console on 3114.
995
- # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
996
- iii console --port 3114
997
- ```
998
-
999
- Luego abre `http://localhost:3114`. Añade `--enable-flow` para la página experimental de grafo de arquitectura.
1000
-
1001
- Sobrescribe endpoints del engine solo si los has movido:
1002
-
1003
- ```bash
1004
- iii console --port 3114 \
1005
- --engine-port 3111 \
1006
- --ws-port 3112 \
1007
- --bridge-port 49134
1008
- ```
1009
-
1010
- **Qué puedes hacer desde la console:**
1011
-
1012
- | Página | Úsala para |
1013
- |------|-----------|
1014
- | **Workers** | Ver todos los workers conectados y sus métricas en vivo — incluyendo el propio worker de agentmemory. |
1015
- | **Functions** | Invocar cualquier función de agentmemory directamente con un payload JSON — útil para probar `memory.recall`, `memory.consolidate`, `graph.query` sin cablear un cliente. |
1016
- | **Triggers** | Reproducir triggers HTTP, cron, event y state — disparar manualmente el cron de consolidación, reintentar una ruta HTTP, emitir un cambio de estado. |
1017
- | **States** | Navegador KV con CRUD completo — sesiones, slots de memoria, temporizadores del ciclo de vida, índice de embeddings — edita valores in-place. |
1018
- | **Streams** | Monitor WebSocket en vivo para escrituras de memoria, eventos de hooks y actualizaciones de observaciones a medida que fluyen por los streams de iii. |
1019
- | **Queues** | Topics de cola duraderas + gestión de dead-letter. Reproduce o descarta jobs fallidos de embedding / compresión. |
1020
- | **Traces** | Vistas OpenTelemetry waterfall / flame / desglose por servicio. Filtra por `trace_id` para ver exactamente qué funciones, llamadas a BD y peticiones de embedding produjo un único `memory.search`. |
1021
- | **Logs** | Logs OTEL estructurados, filtrados y correlados con trace/span IDs. |
1022
- | **Config** | Configuración de runtime — ve exactamente con qué workers, proveedores y puertos está ejecutando tu engine. |
1023
- | **Flow** | (Opcional, `--enable-flow`) Grafo de arquitectura interactivo de cada worker, trigger y stream. |
1024
-
1025
- <p align="center">
1026
- <img src="../assets/iii-console/traces-waterfall.png" alt="Vista de waterfall de trazas de iii console mostrando duración por span" width="720" />
1027
- <br/>
1028
- <em>Traces: waterfall / flame / desglose por servicio para cada operación de memoria.</em>
1029
- </p>
1030
-
1031
- **Las trazas ya están activas:**
1032
-
1033
- `iii-config.yaml` se sirve con el worker `iii-observability` habilitado (`exporter: memory`, `sampling_ratio: 1.0`, métricas + logs). No se necesita configuración adicional — desde el momento en que agentmemory arranca, cada operación de memoria emite una traza-span y un log estructurado que la console puede leer.
1034
-
1035
- Si quieres exportar a Jaeger/Honeycomb/Grafana Tempo en su lugar, cambia `exporter: memory` por `exporter: otlp` y define el endpoint del collector según la documentación de observabilidad de iii.
1036
-
1037
- > **Aviso:** la console en sí no impone auth — mantenla enlazada a `127.0.0.1` (por defecto) y nunca la expongas públicamente.
1038
-
1039
- ---
1040
-
1041
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1042
-
1043
- agentmemory **ya es una instancia [iii](https://iii.dev) en ejecución**. Funciones, triggers, estado KV, streams, trazas OTEL — todo son primitivos de iii. No has instalado Postgres, Redis, Express, pm2 ni Prometheus, porque iii los reemplaza.
1044
-
1045
- Eso significa que un comando más extiende agentmemory con una capacidad completamente nueva.
1046
-
1047
- ### Extiende agentmemory con un comando
1048
-
1049
- ```bash
1050
- iii worker add iii-pubsub # fan memory writes out to every connected instance
1051
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1052
- iii worker add iii-queue # durable retries for embedding + compression jobs
1053
- iii worker add iii-observability # OTEL traces on every memory op (default on)
1054
- iii worker add iii-sandbox # run recalled code inside an isolated microVM
1055
- iii worker add iii-database # swap in a SQL-backed state adapter
1056
- iii worker add mcp # generic MCP host alongside the agentmemory MCP
1057
- ```
1058
-
1059
- Cada `iii worker add` registra nuevas funciones y triggers en el mismo engine en el que agentmemory ya está corriendo. El visor y la console los detectan al instante — sin recargar, sin nueva integración, sin nuevo contenedor.
1060
-
1061
- | `iii worker add` | Qué obtienes encima de agentmemory |
1062
- |---|---|
1063
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Memoria multi-instancia: cada `remember` se difunde, cada `search` lee la unión |
1064
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Ciclo de vida programado — consolidación nocturna, snapshots semanales, decaimiento en un reloj fijo |
1065
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Reintentos duraderos: los jobs de embedding + compresión fallidos sobreviven al reinicio, sin observaciones perdidas |
1066
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Trazas OTEL, métricas y logs en cada función — cableado en `iii-config.yaml` desde el primer día |
1067
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | El código salido de `memory_recall` corre dentro de una VM desechable, no en tu shell |
1068
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptador de estado respaldado por SQL cuando te quedas pequeño con el KV in-memory por defecto |
1069
- | [`mcp`](https://workers.iii.dev/workers/mcp) | Levanta servidores MCP adicionales junto al MCP de agentmemory, compartiendo el mismo engine |
1070
-
1071
- Registro completo: [workers.iii.dev](https://workers.iii.dev). Cada worker allí se compone a través de los mismos primitivos que usa agentmemory — y el agentmemory que ya tienes es uno de ellos.
1072
-
1073
- ### Qué reemplaza iii
1074
-
1075
- | Stack tradicional | agentmemory usa |
1076
- |---|---|
1077
- | Express.js / Fastify | iii HTTP Triggers |
1078
- | SQLite / Postgres + pgvector | iii KV State + índice vectorial in-memory |
1079
- | SSE / Socket.io | iii Streams (WebSocket) |
1080
- | pm2 / systemd | Supervisión de workers del iii engine |
1081
- | Prometheus / Grafana | iii OTEL + monitor de salud |
1082
- | Sistemas de plugins propios | `iii worker add <name>` |
1083
-
1084
- **118 ficheros de código · ~21.800 LOC · 950+ tests · 123 funciones · 34 scopes KV** — todo sobre tres primitivos. No hay `agentmemory plugin install`. El sistema de plugins es iii mismo.
1085
-
1086
- ---
1087
-
1088
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuración" height="32" /></picture></h2>
1089
-
1090
- ### Proveedores de LLM
1091
-
1092
- agentmemory autodetecta desde tu entorno. Por defecto no se hacen llamadas LLM a menos que configures un proveedor o aceptes explícitamente el fallback de suscripción de Claude.
1093
-
1094
- | Proveedor | Configuración | Notas |
1095
- |----------|--------|-------|
1096
- | **No-op (por defecto)** | Sin configuración | Compresión/resumen vía LLM DESACTIVADA. La compresión sintética BM25 + recall siguen funcionando. Mira `AGENTMEMORY_ALLOW_AGENT_SDK` más abajo si dependías del fallback de suscripción de Claude. |
1097
- | Anthropic API | `ANTHROPIC_API_KEY` | Facturación por token |
1098
- | MiniMax | `MINIMAX_API_KEY` | Compatible con Anthropic |
1099
- | Gemini | `GEMINI_API_KEY` | También habilita embeddings |
1100
- | OpenRouter | `OPENROUTER_API_KEY` | Cualquier modelo |
1101
- | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Solo opt-in. Lanza sesiones de `@anthropic-ai/claude-agent-sdk` — solía causar recursión sin límite en el Stop-hook (seguimiento de #149), por eso ya no es el comportamiento por defecto. |
1102
-
1103
- ### Selección de modelo con conciencia de coste
1104
-
1105
- La compresión en background corre en cada observación, así que la elección de modelo cambia el gasto mensual de forma significativa. Datos de carga capturados: 635 peticiones / 888K tokens / 35 horas de uso activo, sobre tres modelos de OpenRouter con precios del 2026-05-23.
1106
-
1107
- | Tier | Modelo | Input / 1M | Output / 1M | Coste para las 35h capturadas | Notas |
1108
- |------|-------|------------|-------------|---------------------------|-------|
1109
- | Recomendado | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Calidad de compresión + resumen sólida a ~10× menos coste que Sonnet. |
1110
- | Recomendado | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Más antiguo pero aún correcto para cargas solo de compresión. |
1111
- | Recomendado | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Buen razonamiento de código si tus sesiones son muy code-centric. |
1112
- | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Alta calidad pero caro para trabajo de background siempre activo. |
1113
- | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Tier similar a Sonnet. |
1114
- | Evitar | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Modelo de reasoning; sobrecoste enorme para compresión. |
1115
-
1116
- agentmemory imprime un aviso en runtime cuando `OPENROUTER_MODEL` coincide con un patrón de tier premium. Define `AGENTMEMORY_SUPPRESS_COST_WARNING=1` para silenciarlo una vez que hayas tomado una decisión informada.
1117
-
1118
- Trade-off de calidad vs coste en trabajo de memoria: la compresión es una tarea de resumen con un listón de calidad relativamente flexible (quien re-lee el resumen es el agente, no el usuario). DeepSeek-V4-Pro / Qwen3-Coder se quedan dentro del error de redondeo respecto a Sonnet en esta tarea, costando ~10× menos. Reserva los modelos de tier premium para las consultas que leas directamente.
1119
-
1120
- Fuentes: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1121
-
1122
- ### Memoria multiagente (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1123
-
1124
- En montajes multiagente donde varios roles comparten un servidor agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` etiqueta cada escritura con el rol que la hizo. `AGENTMEMORY_AGENT_SCOPE` controla si el recall filtra por esa etiqueta.
1125
-
1126
- ```env
1127
- TEAM_ID=company
1128
- USER_ID=engineering-team
1129
- AGENT_ID=architect
1130
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1131
- ```
1132
-
1133
- Dos modos:
1134
-
1135
- | Modo | Etiqueta escrituras | Filtra recall | Cuándo usarlo |
1136
- |------|------------|---------------|-------------|
1137
- | `shared` (por defecto) | sí | no | Contexto cross-agent con pista de auditoría. El architect puede ver lo que el developer apuntó, pero cada fila registra quién lo dijo. |
1138
- | `isolated` | sí | sí | Separación estricta. El architect nunca ve observaciones / memorias / sesiones del developer. |
1139
-
1140
- Qué se etiqueta cuando `AGENT_ID` está definido: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. El rol fluye `api::session::start` → `mem::observe` → `mem::compress` → KV.
1141
-
1142
- Qué se filtra en modo isolated: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Cada endpoint acepta `?agentId=<role>` para sobreescribir por petición, y `?agentId=*` para optar por salir del scope del entorno por completo. `/memories` también acepta `?includeOrphans=true` para sacar memorias previas a AGENT_ID cuyo `agentId` es undefined.
1143
-
1144
- Sobrescritura por llamada en la capa SDK / REST: cada endpoint que muta (`/session/start`, `/remember`) acepta un campo `agentId` en el body que gana frente al entorno. Útil para runtimes que enrutan muchos roles a un único proceso de servidor.
1145
-
1146
- Cuando `AGENT_ID` no está definido, la memoria permanece sin scope (comportamiento legacy, sin etiquetas, sin filtros).
1147
-
1148
- ### Puertos
1149
-
1150
- agentmemory + iii-engine enlazan cuatro puertos por defecto. Si un reinicio falla con `port in use`, esta tabla te dice qué proceso buscar.
1151
-
1152
- | Puerto | Proceso | Propósito | Override por env |
1153
- |------|---------|---------|--------------|
1154
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1155
- | `3112` | iii-engine | Worker de streams interno (consumido por agentmemory + visor) | `III_STREAMS_PORT` |
1156
- | `3113` | agentmemory | Visor en tiempo real (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1157
- | `49134` | iii-engine | WebSocket — los workers se registran aquí, la telemetría OTel fluye por encima | `III_ENGINE_URL` (URL completa, por defecto `ws://localhost:49134`) |
1158
-
1159
- Limpieza de procesos zombi cuando los puertos quedan ocupados tras una ejecución crasheada:
1160
-
1161
- ```bash
1162
- # macOS / Linux — find whatever is on each port and kill it
1163
- lsof -i :3111,3112,3113,49134
1164
- pkill -f agentmemory || true
1165
- pkill -f 'iii ' || true
1166
-
1167
- # Windows
1168
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1169
- taskkill /F /PID <pid>
1170
- ```
1171
-
1172
- `agentmemory stop` recoge limpiamente tanto el worker como el pidfile del engine en un shutdown graceful (#640, #474). La limpieza manual de arriba solo aplica al caso post-crash en el que no queda ningún pidfile.
1173
-
1174
- ### Fichero de configuración
1175
-
1176
- Coloca la configuración de runtime de agentmemory en `~/.agentmemory/.env` en lugar de exportar variables en cada shell. Si el visor muestra una pista de setup tipo `export ANTHROPIC_API_KEY=...`, cópiala a este fichero como `ANTHROPIC_API_KEY=...` sin el prefijo `export`, y reinicia agentmemory.
1177
-
1178
- Las variables de entorno del proceso siguen funcionando y tienen prioridad sobre los valores del fichero.
1179
-
1180
- En Windows, el mismo fichero vive en `%USERPROFILE%\.agentmemory\.env`:
1181
-
1182
- ```powershell
1183
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1184
- notepad $HOME\.agentmemory\.env
1185
- ```
1186
-
1187
- Para probar con una suscripción Claude Code Pro/Max en lugar de una API key, acepta opt-in explícito:
1188
-
1189
- ```env
1190
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1191
- AGENTMEMORY_AUTO_COMPRESS=true
1192
- ```
1193
-
1194
- Activa graph o consolidation en el mismo fichero si las quieres:
1195
-
1196
- ```env
1197
- GRAPH_EXTRACTION_ENABLED=true
1198
- CONSOLIDATION_ENABLED=true
1199
- ```
1200
-
1201
- ### Variables de entorno
1202
-
1203
- Crea `~/.agentmemory/.env`:
1204
-
1205
- ```env
1206
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1207
- # ANTHROPIC_API_KEY=sk-ant-...
1208
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1209
- # GEMINI_API_KEY=...
1210
- # OPENROUTER_API_KEY=...
1211
- # MINIMAX_API_KEY=...
1212
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1213
- # # OpenAI LLM provider (here) AND the OpenAI
1214
- # # embedding provider (further below). Set
1215
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1216
- # # to embeddings only.
1217
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1218
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1219
- # # Auto-detected from `.openai.azure.com` hostname; uses
1220
- # # api-key header + api-version query param.
1221
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1222
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1223
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1224
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1225
- # # for back-compat with v0.9.17. New configs should
1226
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1227
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1228
- # # Honored only by OpenAI's reasoning models (o1, o3,
1229
- # # gpt-*-reasoning) and providers that mirror that
1230
- # # schema (Ollama Cloud thinking models). Standard
1231
- # # chat models reject this field with 400. Set to
1232
- # # "none" for thinking models that return reasoning
1233
- # # but no content.
1234
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1235
- # # for LLM (useful if you only want OpenAI for embeddings)
1236
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1237
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1238
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1239
-
1240
- # Embedding provider (auto-detected, or override)
1241
- # EMBEDDING_PROVIDER=local
1242
- # VOYAGE_API_KEY=...
1243
- # OPENAI_API_KEY=sk-...
1244
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1245
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1246
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1247
-
1248
- # Outbound LLM / embedding timeout
1249
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1250
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1251
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1252
- # embedding). For the OpenAI LLM path, the
1253
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1254
- # takes precedence when set, for back-compat
1255
- # with v0.9.17.
1256
- # Increase for slow networks or large batch calls;
1257
- # decrease to fail-fast on rate-limit holds.
1258
-
1259
- # Search tuning
1260
- # BM25_WEIGHT=0.4
1261
- # VECTOR_WEIGHT=0.6
1262
- # TOKEN_BUDGET=2000
1263
-
1264
- # Auth
1265
- # AGENTMEMORY_SECRET=your-secret
1266
-
1267
- # Ports (defaults: 3111 API, 3113 viewer)
1268
- # III_REST_PORT=3111
1269
-
1270
- # Features
1271
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1272
- # every PostToolUse hook calls your
1273
- # LLM provider to compress the
1274
- # observation — expect significant
1275
- # token spend on active sessions.
1276
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1277
- # memory slots — persona,
1278
- # user_preferences, tool_guidelines,
1279
- # project_context, guidance,
1280
- # pending_items, session_patterns,
1281
- # self_notes. Size-limited; agent
1282
- # edits via memory_slot_* tools.
1283
- # Pinned slots addressable for
1284
- # SessionStart injection.
1285
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1286
- # Stop hook fires mem::slot-reflect:
1287
- # scans recent observations, auto-
1288
- # appends TODOs to pending_items,
1289
- # counts patterns in
1290
- # session_patterns, records touched
1291
- # files in project_context. Fire-
1292
- # and-forget; does not block.
1293
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1294
- # - SessionStart may inject ~1-2K
1295
- # chars of project context into
1296
- # the first turn of each session
1297
- # (this is what actually reaches
1298
- # the model — Claude Code treats
1299
- # SessionStart stdout as context)
1300
- # - PreToolUse fires /agentmemory/enrich
1301
- # on every file-touching tool call
1302
- # (resource cleanup, not a token
1303
- # fix — PreToolUse stdout is debug
1304
- # log only per Claude Code docs)
1305
- # Observations are still captured via
1306
- # PostToolUse regardless of this flag.
1307
- # GRAPH_EXTRACTION_ENABLED=false
1308
- # CONSOLIDATION_ENABLED=true
1309
- # LESSON_DECAY_ENABLED=true
1310
- # OBSIDIAN_AUTO_EXPORT=false
1311
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1312
- # CLAUDE_MEMORY_BRIDGE=false
1313
- # SNAPSHOT_ENABLED=false
1314
-
1315
- # Team
1316
- # TEAM_ID=
1317
- # USER_ID=
1318
- # TEAM_MODE=private
1319
-
1320
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1321
- # AGENTMEMORY_TOOLS=core
1322
- ```
1323
-
1324
- ---
1325
-
1326
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1327
-
1328
- 124 endpoints en el puerto `3111`. La REST API se enlaza a `127.0.0.1` por defecto. Los endpoints protegidos requieren `Authorization: Bearer <secret>` cuando `AGENTMEMORY_SECRET` está definido, y los endpoints de mesh sync requieren `AGENTMEMORY_SECRET` en ambos peers.
1329
-
1330
- <details>
1331
- <summary>Endpoints principales</summary>
1332
-
1333
- | Method | Path | Descripción |
1334
- |--------|------|-------------|
1335
- | `GET` | `/agentmemory/health` | Health check (siempre público) |
1336
- | `POST` | `/agentmemory/session/start` | Inicia sesión + obtiene contexto |
1337
- | `POST` | `/agentmemory/session/end` | Finaliza sesión |
1338
- | `POST` | `/agentmemory/observe` | Captura observación |
1339
- | `POST` | `/agentmemory/smart-search` | Búsqueda híbrida |
1340
- | `POST` | `/agentmemory/context` | Genera contexto |
1341
- | `POST` | `/agentmemory/remember` | Guarda en memoria a largo plazo |
1342
- | `POST` | `/agentmemory/forget` | Borra observaciones |
1343
- | `POST` | `/agentmemory/enrich` | Contexto de fichero + memorias + bugs |
1344
- | `GET` | `/agentmemory/profile` | Perfil de proyecto |
1345
- | `GET` | `/agentmemory/export` | Exporta todos los datos |
1346
- | `POST` | `/agentmemory/import` | Importa desde JSON |
1347
- | `POST` | `/agentmemory/graph/query` | Consulta del grafo de conocimiento |
1348
- | `POST` | `/agentmemory/team/share` | Comparte con el equipo |
1349
- | `GET` | `/agentmemory/audit` | Pista de auditoría |
1350
-
1351
- Lista completa de endpoints: [`src/triggers/api.ts`](../src/triggers/api.ts)
1352
-
1353
- </details>
1354
-
1355
- ---
1356
-
1357
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Desarrollo" height="32" /></picture></h2>
1358
-
1359
- ```bash
1360
- npm run dev # Hot reload
1361
- npm run build # Production build
1362
- npm test # 950+ tests
1363
- npm run test:integration # API tests (requires running services)
1364
- ```
1365
-
1366
- **Requisitos previos:** Node.js >= 20, [iii-engine](https://iii.dev/docs) o Docker
1367
-
1368
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licencia" height="32" /></picture></h2>
1369
-
1370
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.fr-FR.md DELETED
@@ -1,1377 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — Mémoire persistante pour les agents de codage IA" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- Votre agent de codage se souvient de tout. Fini de tout réexpliquer.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Mémoire persistante pour Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode et tout client MCP.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- Français |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Document de conception : 1200 stars / 172 forks sur le gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>Le gist étend le motif LLM Wiki de Karpathy avec scoring de confiance, cycle de vie, graphes de connaissances et recherche hybride : agentmemory en est l'implémentation.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="Démo agentmemory" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">Installation</a> &bull;
73
- <a href="#quick-start">Démarrage rapide</a> &bull;
74
- <a href="#benchmarks">Benchmarks</a> &bull;
75
- <a href="#vs-competitors">vs Concurrents</a> &bull;
76
- <a href="#works-with-every-agent">Agents</a> &bull;
77
- <a href="#how-it-works">Fonctionnement</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">Visualiseur</a> &bull;
80
- <a href="#iii-console">iii Console</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">Configuration</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Install
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # start the memory server on :3111
95
- agentmemory demo # seed sample sessions + prove recall
96
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- Ou via `npx` (sans installation) :
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- À noter — npx met en cache par version. Si un simple `npx @agentmemory/agentmemory` sert une version plus ancienne, forcez la dernière avec `npx -y @agentmemory/agentmemory@latest`, ou videz le cache une fois avec `rm -rf ~/.npm/_npx` (macOS/Linux ; sur Windows, supprimez `%LOCALAPPDATA%\npm-cache\_npx`). Depuis v0.9.16+, la première exécution npx propose une installation globale inline pour que la commande `agentmemory` soit ensuite disponible partout.
106
-
107
- Toutes les options dans [Démarrage rapide](#quick-start) ci-dessous. Câblage spécifique par agent dans [Compatible avec tous les agents](#works-with-every-agent).
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Compatible avec tous les agents" height="32" /></picture></h2>
112
-
113
- agentmemory fonctionne avec tout agent qui prend en charge les hooks, MCP ou l'API REST. Tous les agents partagent le même serveur de mémoire.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>plugin natif + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>plugin natif + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>plugin natif + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>plugin natif + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>plugin natif + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>backend natif trait Memory</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>serveur MCP</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>serveur MCP</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>serveur MCP</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>serveur MCP</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>serveur MCP</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>API REST</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>serveur MCP</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>serveur MCP</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>serveur MCP</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>Fonctionne avec <strong>n'importe quel</strong> agent qui parle MCP ou HTTP. Un seul serveur, des mémoires partagées entre tous.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- Vous expliquez la même architecture à chaque session. Vous redécouvrez les mêmes bugs. Vous réenseignez les mêmes préférences. La mémoire intégrée (CLAUDE.md, .cursorrules) plafonne à 200 lignes et devient obsolète. agentmemory règle ce problème. Il capture silencieusement ce que fait votre agent, le compresse dans une mémoire interrogeable, puis injecte le bon contexte au démarrage de la session suivante. Une seule commande. Compatible entre agents.
209
-
210
- **Ce qui change :** Session 1, vous mettez en place l'authentification JWT. Session 2, vous demandez une limitation de débit. L'agent sait déjà que votre authentification utilise le middleware jose dans `src/middleware/auth.ts`, que vos tests couvrent la validation des tokens, et que vous avez choisi jose plutôt que jsonwebtoken pour la compatibilité Edge. Pas de réexplication. Pas de copier-coller. L'agent *sait*, point.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **Nouveau en v0.9.0** — Site d'accueil sur [agent-memory.dev](https://agent-memory.dev), connecteur système de fichiers (`@agentmemory/fs-watcher`), le MCP standalone fait désormais proxy vers le serveur en cours d'exécution afin que les hooks et le visualiseur soient cohérents, politique d'audit codifiée sur tous les chemins de suppression, l'état de santé ne signale plus `memory_critical` sur les petits processus Node. Notes complètes dans [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Précision de récupération
227
-
228
- **coding-agent-life-v1** (corpus interne, reproductible en sandbox)
229
-
230
- | Adaptateur | P@5 | R@5 | Taux de hit top-5 | Latence p50 |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | Référence grep | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100 % de taux de hit top-5. **2,2×** meilleure précision que la référence grep sur entrée identique. Ventilation complète par type : [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 questions)
238
-
239
- | Système | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | Repli BM25 seul | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Économies de tokens
248
-
249
- | Approche | Tokens/an | Coût/an |
250
- |---|---|---|
251
- | Coller le contexte complet | 19,5M+ | Impossible (dépasse la fenêtre) |
252
- | Résumé par LLM | ~650K | ~500 $ |
253
- | **agentmemory** | **~170K** | **~10 $** |
254
- | agentmemory + embeddings locaux | ~170K | **0 $** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Modèle d'embedding : `all-MiniLM-L6-v2` (local, gratuit, aucune clé d'API). Rapports complets : [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparaison avec les concurrents : [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
-
262
- **Reproduire localement :** [`eval/README.md`](../eval/README.md) — harnais à adaptateurs pluggables pour LongMemEval `_s` (public, 500 questions) + `coding-agent-life-v1` (corpus interne de 15 sessions). Les adaptateurs grep / vectoriel / agentmemory sont scorés côte à côte, sortie NDJSON, scorecards publiés dans [`docs/benchmarks/`](../docs/benchmarks/).
263
-
264
- **À associer à [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) et [Graphify](https://github.com/safishamsi/graphify).** Indexation de graphe de code, pipelines de build multi-agents et graphes de connaissances étendus sur docs / PDFs / images / vidéos. agentmemory mémorise le travail ; ces trois projets éclairent le reste de la couche de contexte. Recettes et tableau de routage des questions : [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Concurrents" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">Intégré (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>Type</strong></td>
280
- <td>Moteur de mémoire + serveur MCP</td>
281
- <td>API de couche mémoire</td>
282
- <td>Runtime d'agent complet</td>
283
- <td>Fichier statique</td>
284
- </tr>
285
- <tr>
286
- <td><strong>R@5 de récupération</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>Capture automatique</strong></td>
294
- <td>12 hooks (zéro effort manuel)</td>
295
- <td>Appels <code>add()</code> manuels</td>
296
- <td>L'agent s'édite lui-même</td>
297
- <td>Édition manuelle</td>
298
- </tr>
299
- <tr>
300
- <td><strong>Recherche</strong></td>
301
- <td>BM25 + Vectoriel + Graphe (fusion RRF)</td>
302
- <td>Vectoriel + Graphe</td>
303
- <td>Vectoriel (archival)</td>
304
- <td>Charge tout en contexte</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Multi-agents</strong></td>
308
- <td>MCP + REST + leases + signaux</td>
309
- <td>API (sans coordination)</td>
310
- <td>Uniquement dans le runtime Letta</td>
311
- <td>Fichiers par agent</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Verrouillage framework</strong></td>
315
- <td>Aucun (tout client MCP)</td>
316
- <td>Aucun</td>
317
- <td>Élevé (Letta obligatoire)</td>
318
- <td>Format par agent</td>
319
- </tr>
320
- <tr>
321
- <td><strong>Dépendances externes</strong></td>
322
- <td>Aucune (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + base vectorielle</td>
325
- <td>Aucune</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Cycle de vie mémoire</strong></td>
329
- <td>Consolidation à 4 niveaux + décroissance + oubli automatique</td>
330
- <td>Extraction passive</td>
331
- <td>Gérée par l'agent</td>
332
- <td>Élagage manuel</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Efficacité en tokens</strong></td>
336
- <td>~1 900 tokens/session (10 $/an)</td>
337
- <td>Variable selon l'intégration</td>
338
- <td>Mémoire centrale dans le contexte</td>
339
- <td>22K+ tokens à 240 observations</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Visualiseur temps réel</strong></td>
343
- <td>Oui (port 3113)</td>
344
- <td>Tableau de bord cloud</td>
345
- <td>Tableau de bord cloud</td>
346
- <td>Non</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Auto-hébergé</strong></td>
350
- <td>Oui (par défaut)</td>
351
- <td>Optionnel</td>
352
- <td>Optionnel</td>
353
- <td>Oui</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Démarrage rapide" height="32" /></picture></h2>
360
-
361
- Compatibilité : cette version cible `iii-sdk` stable `^0.11.0` et iii-engine v0.11.x.
362
-
363
- ### Essayez en 30 secondes
364
-
365
- ```bash
366
- # Terminal 1: start the server
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: seed sample data and see recall in action
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` amorce 3 sessions réalistes (auth JWT, correctif de requêtes N+1, limitation de débit) et lance des recherches sémantiques dessus. Vous verrez le système trouver « N+1 query fix » quand vous cherchez « database performance optimization » — la correspondance par mots-clés en est incapable.
374
-
375
- Ouvrez `http://localhost:3113` pour voir la mémoire se construire en direct.
376
-
377
- ### Recommandé : installation globale
378
-
379
- `npx` met en cache par version. Si vous avez lancé `npx @agentmemory/agentmemory@0.9.14` la semaine dernière, un simple `npx @agentmemory/agentmemory` peut servir le 0.9.14 obsolète depuis `~/.npm/_npx/`, pas la dernière version. Installez une fois et la commande `agentmemory` est disponible partout :
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # start the server (same as the npx form)
386
- agentmemory stop # tear it down
387
- agentmemory remove # uninstall everything we created
388
- agentmemory connect claude-code # wire one agent
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- À partir de v0.9.16, la première exécution npx propose une installation globale inline — répondez `Y` une fois et c'est réglé. Si vous passez l'étape, repliez sur l'une de ces options pour un fetch frais :
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
- ```
398
-
399
- Sur Windows / PowerShell, l'équivalent pour vider le cache est `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — le `npx -y ...@latest` ci-dessus reste l'option multiplateforme.
400
-
401
- ### Replay de session
402
-
403
- Chaque session enregistrée par agentmemory est rejouable. Ouvrez le visualiseur, choisissez l'onglet **Replay**, et parcourez la chronologie : prompts, appels d'outils, résultats d'outils et réponses s'affichent comme événements discrets avec play/pause, contrôle de vitesse (0,5×–4×) et raccourcis clavier (espace pour basculer, flèches pour avancer).
404
-
405
- Vous avez déjà d'anciennes transcriptions JSONL Claude Code à importer ?
406
-
407
- ```bash
408
- # Import everything under the default ~/.claude/projects
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Or import a single file
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- Les sessions importées apparaissent dans le sélecteur Replay aux côtés des natives. Sous le capot, chaque entrée passe par les fonctions iii `mem::replay::load`, `mem::replay::sessions` et `mem::replay::import-jsonl` — aucun serveur secondaire.
416
-
417
- ### Mise à niveau / Maintenance
418
-
419
- Utilisez la commande de maintenance lorsque vous voulez intentionnellement mettre à jour votre runtime local :
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- Avertissement : cette commande modifie l'espace de travail / runtime courant. Elle peut mettre à jour les dépendances JavaScript, exécuter `cargo install iii-engine --force` et tirer des images Docker.
426
-
427
- Détails d'implémentation dans `src/cli.ts` (voir `runUpgrade` autour de la zone `src/cli.ts:544-595`).
428
-
429
- ### Claude Code (un seul bloc, à coller)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code sans installation du plugin (chemin MCP-standalone)
436
-
437
- Si vous câblez le serveur MCP d'agentmemory via `~/.claude.json` directement plutôt que via `/plugin install`, Claude Code ne résout jamais `${CLAUDE_PLUGIN_ROOT}` et vous devez pointer les scripts de hooks vers des chemins absolus dans `~/.claude/settings.json`. Ces chemins embarquent typiquement la version d'agentmemory (par ex. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), si bien que la mise à niveau suivante casse silencieusement tous les hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- Contournement :
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- Cela fusionne les mêmes commandes de hooks dans `~/.claude/settings.json` avec des chemins absolus résolus vers le répertoire `plugin/` du paquet `@agentmemory/agentmemory` actuellement installé. Relancez la commande après une mise à niveau d'agentmemory pour rafraîchir les chemins. Les entrées de l'utilisateur dans le même fichier sont préservées ; seules les entrées agentmemory précédentes sont remplacées. Utiliser le chemin `/plugin install` reste l'approche recommandée.
446
- Pour des déploiements distants ou protégés, lancez Claude Code avec `AGENTMEMORY_URL` et `AGENTMEMORY_SECRET` définis. Le plugin transmet les deux valeurs à son serveur MCP intégré ; quand `AGENTMEMORY_URL` est vide, le shim MCP utilise `http://localhost:3111`.
447
-
448
- ### Codex CLI (plateforme de plugins Codex)
449
-
450
- ```bash
451
- # 1. start the memory server in a separate terminal
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. register the agentmemory marketplace and install the plugin
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- Le plugin Codex est livré depuis le même répertoire `plugin/` que le plugin Claude Code. Il enregistre :
460
-
461
- - `@agentmemory/mcp` comme serveur MCP (proxie les 51 outils lorsque `AGENTMEMORY_URL` pointe vers un serveur agentmemory actif ; retombe sur 7 outils en local si aucun serveur n'est accessible)
462
- - 6 hooks de cycle de vie : `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 skills : `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- Le moteur de hooks de Codex injecte `CLAUDE_PLUGIN_ROOT` dans les sous-processus de hooks (cf. [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), donc les mêmes scripts de hooks fonctionnent sur les deux hôtes sans duplication. Les événements Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure sont propres à Claude Code et ne sont pas enregistrés pour Codex.
466
-
467
- #### Codex Desktop : hooks de plugin actuellement silencieux (contournement disponible)
468
-
469
- `CodexHooks` et `PluginHooks` sont tous deux stables + activés par défaut dans [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), mais les builds Codex Desktop actuels ne dispatchent pas les `hooks.json` locaux au plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). Les outils MCP fonctionnent toujours ; seules les observations de cycle de vie manquent.
470
-
471
- En attendant le correctif amont, dupliquez les mêmes commandes de hooks dans le `~/.codex/hooks.json` global :
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- Cela ajoute un bloc idempotent à `~/.codex/hooks.json` qui référence des chemins absolus vers les scripts intégrés (pas besoin d'expansion `${CLAUDE_PLUGIN_ROOT}` au scope utilisateur). Relancez la même commande après une mise à niveau d'agentmemory pour rafraîchir les chemins. Les entrées de l'utilisateur dans le même fichier sont préservées ; seules les entrées agentmemory précédentes sont remplacées.
478
-
479
- <details>
480
- <summary><b>OpenClaw (collez ce prompt)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- Guide complet : [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (collez ce prompt)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- Guide complet : [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### Autres agents
526
-
527
- Démarrez le serveur de mémoire : `npx @agentmemory/agentmemory`
528
-
529
- L'entrée agentmemory est le **même bloc serveur MCP** pour tous les hôtes utilisant le format `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw) :
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **Fusionnez cette entrée dans l'objet `mcpServers` existant** du fichier de config de l'hôte — ne remplacez pas le fichier. Si le fichier contient déjà d'autres serveurs, ajoutez `agentmemory` à côté d'eux comme nouvelle clé dans `mcpServers`. Si `mcpServers` est totalement absent, collez le bloc dans `{ "mcpServers": { ... } }`. Les placeholders `${VAR}` héritent de `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` depuis le shell au lancement du serveur MCP — des vars non définies passent des chaînes vides et le shim retombe sur `http://localhost:3111`. Une seule entrée câblée couvre à la fois les déploiements locaux et distants (k8s / reverse-proxy).
543
-
544
- | Agent | Fichier de config | Notes |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | Fusionner dans `mcpServers`. Deeplink en un clic également disponible sur le site web. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Fusionner dans `mcpServers`. Redémarrer Claude Desktop après modification. |
548
- | **Cline / Roo Code / Kilo Code** | Paramètres MCP de Cline (Settings UI → MCP Servers → Edit) | Même bloc `mcpServers`. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Même bloc `mcpServers`. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (fusion automatique). |
551
- | **OpenClaw** | Config MCP d'OpenClaw | Même bloc `mcpServers`, ou utilisez le [plugin mémoire plus poussé](../integrations/openclaw/). |
552
- | **Codex CLI (MCP seul)** | `.codex/config.toml` | Format TOML : `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, ou ajoutez `[mcp_servers.agentmemory]` à la main. |
553
- | **Codex CLI (plugin complet)** | Marketplace de plugins Codex | `codex plugin marketplace add rohitg00/agentmemory` puis `codex plugin add agentmemory@agentmemory`. Enregistre MCP + 6 hooks de cycle de vie (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. Sur Codex Desktop, lancez également `agentmemory connect codex --with-hooks` en attendant que [openai/codex#16430](https://github.com/openai/codex/issues/16430) soit corrigé — les hooks de plugin y sont actuellement silencieux. |
554
- | **OpenCode (MCP seul)** | `opencode.json` | Format différent — clé `mcp` au niveau racine, commande sous forme de tableau : `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (plugin complet)** | `plugin/opencode/` | 22 hooks de capture automatique couvrant cycle de vie de session, messages, outils, erreurs. Deux commandes slash (`/recall`, `/remember`). Copiez `plugin/opencode/` dans votre workspace OpenCode et ajoutez l'entrée du plugin à `opencode.json`. Voir [`plugin/opencode/README.md`](../plugin/opencode/README.md) pour le tableau complet des hooks et l'analyse des manques. |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | Copiez [`integrations/pi`](../integrations/pi/) et redémarrez pi. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | Utilisez le [plugin de fournisseur de mémoire plus poussé](../integrations/hermes/) avec `memory.provider: agentmemory`. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` écrit le bloc `mcpServers` standard. La charge utile des hooks est compatible champ-à-champ avec Claude Code, donc les 12 scripts de hooks existants fonctionnent sans modification — câblez-les via la section `hooks` du même `settings.json`. |
559
- | **Antigravity** (remplace Gemini CLI) | `mcp_config.json` (dans le répertoire User d'Antigravity) | `agentmemory connect antigravity` écrit le bloc `mcpServers` standard. macOS : `~/Library/Application Support/Antigravity/User/`. Linux : `~/.config/Antigravity/User/`. À utiliser après l'arrêt de Gemini CLI au 2026-06-18. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` écrit la config au niveau utilisateur. Les overrides de workspace vont dans `.kiro/settings/mcp.json` à côté de votre code. |
561
- | **Goose** | UI des paramètres MCP de Goose | Même bloc `mcpServers`. |
562
- | **Aider** | n/a | Parlez directement à l'API REST : `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **Tout agent (32+)** | n/a | `npx skillkit install agentmemory` détecte l'hôte automatiquement et fusionne. |
564
-
565
- **Clients MCP en sandbox** (Flatpak / Snap / conteneurs restrictifs) qui ne peuvent pas joindre le `localhost` de l'hôte : définissez également `"AGENTMEMORY_FORCE_PROXY": "1"` dans le bloc `env` et pointez `AGENTMEMORY_URL` vers une route que la sandbox peut effectivement atteindre (par ex. votre IP LAN). Voir [#234](https://github.com/rohitg00/agentmemory/issues/234) pour la démarche de diagnostic.
566
-
567
- ### Accès programmatique (Python / Rust / Node)
568
-
569
- agentmemory enregistre ses opérations principales en tant que fonctions iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). N'importe quel langage doté d'un SDK iii peut les appeler directement sur `ws://localhost:49134` — pas besoin de client REST séparé par langage.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- Exemple complet : [`examples/python/`](../examples/python/) (quickstart + flux observation/recall). REST sur `:3111` reste disponible pour les hôtes sans runtime iii.
590
-
591
- ### Depuis les sources
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- Cela démarre agentmemory avec un `iii-engine` local si `iii` est déjà installé, ou retombe sur Docker Compose si Docker est disponible. REST, streams et visualiseur se lient à `127.0.0.1` par défaut.
599
-
600
- Installer `iii-engine` manuellement. **agentmemory épingle actuellement `iii-engine` à `v0.11.2`** — `v0.11.6` introduit un nouveau modèle de sandboxing systématique via `iii worker add` pour lequel agentmemory n'a pas encore été refactorisé. L'épinglage sera levé une fois la refonte effectuée. Surchargez avec `AGENTMEMORY_III_VERSION=<version>` si vous avez migré au modèle sandbox manuellement.
601
-
602
- - **macOS arm64 :** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64 :** remplacez `aarch64-apple-darwin` par `x86_64-apple-darwin`
604
- - **Linux x64 :** remplacez par `x86_64-unknown-linux-gnu`
605
- - **Linux arm64 :** remplacez par `aarch64-unknown-linux-gnu`
606
- - **Windows :** téléchargez `iii-x86_64-pc-windows-msvc.zip` depuis [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extrayez `iii.exe`, ajoutez-le au PATH
607
-
608
- Ou utilisez Docker (le `docker-compose.yml` fourni tire `iiidev/iii:0.11.2`). Documentation complète : [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory tourne sur Windows 10/11, mais le paquet Node.js seul ne suffit pas — il vous faut aussi le runtime `iii-engine` (un binaire natif séparé) comme processus en arrière-plan. L'installeur amont officiel est un script `sh` et il n'existe à ce jour ni installeur PowerShell ni paquet scoop/winget, donc les utilisateurs Windows ont deux chemins :
613
-
614
- **Option A — Binaire Windows précompilé (recommandé) :**
615
-
616
- ```powershell
617
- # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
- # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
- # model that engine v0.11.6+ requires)
620
- # 2. Download iii-x86_64-pc-windows-msvc.zip
621
- # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
- # 3. Extract iii.exe somewhere on PATH, or place it at:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory checks that location automatically)
625
- # 4. Verify:
626
- iii --version
627
- # Should print: 0.11.2
628
-
629
- # 5. Then run agentmemory as usual:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **Option B — Docker Desktop :**
634
-
635
- ```powershell
636
- # 1. Install Docker Desktop for Windows
637
- # 2. Start Docker Desktop and make sure the engine is running
638
- # 3. Run agentmemory — it will auto-start the bundled compose file:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **Option C — MCP standalone uniquement (sans moteur) :** si vous n'avez besoin que des outils MCP pour votre agent et pas de l'API REST, du visualiseur ou des jobs cron, sautez le moteur :
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # or via the shim package:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Diagnostics pour Windows :** si `npx @agentmemory/agentmemory` échoue, relancez avec `--verbose` pour voir le stderr réel du moteur. Modes de défaillance courants :
651
-
652
- | Symptôme | Correctif |
653
- |---|---|
654
- | `iii-engine process started` puis `did not become ready within 15s` | Le moteur a planté au démarrage — relancez avec `--verbose`, vérifiez stderr |
655
- | `Could not start iii-engine` | Ni `iii.exe` ni Docker installés. Voir les options A ou B ci-dessus |
656
- | Conflit de port | `netstat -ano \| findstr :3111` pour voir ce qui est lié, puis tuez-le ou utilisez `--port <N>` |
657
- | Fallback Docker ignoré bien que Docker soit installé | Assurez-vous que Docker Desktop tourne effectivement (icône de la barre d'état système) |
658
-
659
- > Note : il n'y a pas de `cargo install iii-engine` — `iii` n'est pas publié sur crates.io. Les seules méthodes d'installation supportées sont le binaire précompilé ci-dessus, le script d'installation amont en `sh` (macOS/Linux uniquement) et l'image Docker.
660
-
661
- ---
662
-
663
- <h2 id="deploy">Déploiement</h2>
664
-
665
- Templates en un clic pour les hébergeurs managés. Chacun livre un Dockerfile
666
- autonome qui récupère `@agentmemory/agentmemory` depuis npm et copie le
667
- binaire iii engine depuis l'image officielle `iiidev/iii` du Docker
668
- Hub — pas d'image agentmemory précompilée requise. Le stockage
669
- persistant se monte sur `/data` ; le point d'entrée au premier
670
- démarrage réécrit la config iii livrée par npm (qui se lie à
671
- `127.0.0.1`) par une version réglée pour le déploiement qui se lie à
672
- `0.0.0.0` et utilise des chemins absolus `/data`, génère le secret HMAC,
673
- puis abaisse les privilèges de `root` à `node` via `gosu` avant
674
- d'exec'er la CLI agentmemory.
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- Le bouton de déploiement en un clic de Render exige un `render.yaml` à la racine du dépôt, que nous gardons délibérément propre. Utilisez le flux Render Blueprint documenté dans [`deploy/render/`](./deploy/render/README.md) pour pointer manuellement vers le blueprint dans le dépôt.
682
-
683
- Détails complets de configuration (capture HMAC, tunnel SSH du visualiseur, rotation, sauvegarde, plafonds de coût) dans [`deploy/`](./deploy/README.md) :
684
-
685
- - [`deploy/fly`](./deploy/fly/README.md) — machine unique avec
686
- `auto_stop_machines = "stop"` ; le moins cher à l'arrêt.
687
- - [`deploy/railway`](./deploy/railway/README.md) — forfait Hobby à tarif fixe,
688
- volume dans le tableau de bord.
689
- - [`deploy/render`](./deploy/render/README.md) — flux Blueprint,
690
- snapshots disque automatiques sur les forfaits payants.
691
- - [`deploy/coolify`](./deploy/coolify/README.md) — auto-hébergé sur votre
692
- propre VPS via [Coolify](https://coolify.io/self-hosted) ; même stack
693
- Docker Compose, vous possédez l'hôte et les données.
694
-
695
- Seul le port `3111` est publié. Le visualiseur sur `3113` reste lié à la
696
- boucle locale dans le conteneur — chaque README de template documente
697
- le motif tunnel SSH pour y accéder.
698
-
699
- ---
700
-
701
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Pourquoi agentmemory" height="32" /></picture></h2>
702
-
703
- Chaque agent de codage oublie tout quand la session se termine. Vous perdez les 5 premières minutes de chaque session à réexpliquer votre stack. agentmemory tourne en arrière-plan et élimine totalement cette perte.
704
-
705
- ```text
706
- Session 1: "Add auth to the API"
707
- Agent writes code, runs tests, fixes bugs
708
- agentmemory silently captures every tool use
709
- Session ends -> observations compressed into structured memory
710
-
711
- Session 2: "Now add rate limiting"
712
- Agent already knows:
713
- - Auth uses JWT middleware in src/middleware/auth.ts
714
- - Tests in test/auth.test.ts cover token validation
715
- - You chose jose over jsonwebtoken for Edge compatibility
716
- Zero re-explaining. Starts working immediately.
717
- ```
718
-
719
- ### vs mémoire d'agent intégrée
720
-
721
- Chaque agent de codage IA est livré avec une mémoire intégrée — Claude Code a `MEMORY.md`, Cursor a des notepads, Cline a memory bank. Cela fonctionne comme des post-it. agentmemory est la base de données interrogeable derrière les post-it.
722
-
723
- | | Intégrée (CLAUDE.md) | agentmemory |
724
- |---|---|---|
725
- | Échelle | Plafond de 200 lignes | Illimitée |
726
- | Recherche | Charge tout en contexte | BM25 + vecteur + graphe (top-K seul) |
727
- | Coût en tokens | 22K+ à 240 observations | ~1 900 tokens (92 % de moins) |
728
- | Inter-agents | Fichiers par agent | MCP + REST (n'importe quel agent) |
729
- | Coordination | Aucune | Leases, signaux, actions, routines |
730
- | Observabilité | Lire les fichiers à la main | Visualiseur temps réel sur :3113 |
731
-
732
- ---
733
-
734
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Fonctionnement" height="32" /></picture></h2>
735
-
736
- ### Pipeline mémoire
737
-
738
- ```text
739
- PostToolUse hook fires
740
- -> SHA-256 dedup (5min window)
741
- -> Privacy filter (strip secrets, API keys)
742
- -> Store raw observation
743
- -> LLM compress -> structured facts + concepts + narrative
744
- -> Vector embedding (6 providers + local)
745
- -> Index in BM25 + vector
746
-
747
- Stop / SessionEnd hook fires
748
- -> Summarize session
749
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
750
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
751
-
752
- SessionStart hook fires
753
- -> Load project profile (top concepts, files, patterns)
754
- -> Hybrid search (BM25 + vector + graph)
755
- -> Token budget (default: 2000 tokens)
756
- -> Inject into conversation
757
- ```
758
-
759
- ### Consolidation mémoire à 4 niveaux
760
-
761
- Inspirée de la façon dont le cerveau humain traite la mémoire — pas si éloignée de la consolidation pendant le sommeil.
762
-
763
- | Niveau | Quoi | Analogie |
764
- |------|------|---------|
765
- | **Working** | Observations brutes issues de l'usage des outils | Mémoire à court terme |
766
- | **Episodic** | Résumés de session compressés | « Ce qui s'est passé » |
767
- | **Semantic** | Faits et motifs extraits | « Ce que je sais » |
768
- | **Procedural** | Workflows et motifs de décision | « Comment faire » |
769
-
770
- Les mémoires décroissent dans le temps (courbe d'Ebbinghaus). Les mémoires fréquemment consultées se renforcent. Les mémoires obsolètes sont évincées automatiquement. Les contradictions sont détectées et résolues.
771
-
772
- ### Ce qui est capturé
773
-
774
- | Hook | Capture |
775
- |------|----------|
776
- | `SessionStart` | Chemin de projet, ID de session |
777
- | `UserPromptSubmit` | Prompts utilisateur (filtrés pour la vie privée) |
778
- | `PreToolUse` | Motifs d'accès fichier + contexte enrichi |
779
- | `PostToolUse` | Nom de l'outil, entrée, sortie |
780
- | `PostToolUseFailure` | Contexte d'erreur |
781
- | `PreCompact` | Réinjecte la mémoire avant compaction |
782
- | `SubagentStart/Stop` | Cycle de vie des sous-agents |
783
- | `Stop` | Résumé de fin de session |
784
- | `SessionEnd` | Marqueur de fin de session |
785
-
786
- ### Capacités clés
787
-
788
- | Capacité | Description |
789
- |---|---|
790
- | **Capture automatique** | Chaque usage d'outil enregistré via hooks — zéro effort manuel |
791
- | **Recherche sémantique** | BM25 + vecteur + graphe de connaissances avec fusion RRF |
792
- | **Évolution de la mémoire** | Versioning, supersession, graphes de relations |
793
- | **Oubli automatique** | Expiration TTL, détection de contradictions, éviction par importance |
794
- | **Vie privée d'abord** | Clés d'API, secrets, balises `<private>` retirés avant stockage |
795
- | **Auto-réparation** | Circuit breaker, chaîne de repli de fournisseur, surveillance de santé |
796
- | **Pont Claude** | Synchronisation bidirectionnelle avec MEMORY.md |
797
- | **Graphe de connaissances** | Extraction d'entités + parcours BFS |
798
- | **Mémoire d'équipe** | Partagée + privée par namespace entre membres de l'équipe |
799
- | **Provenance des citations** | Tracer toute mémoire jusqu'aux observations sources |
800
- | **Snapshots git** | Version, rollback et diff de l'état mémoire |
801
-
802
- ---
803
-
804
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Recherche" height="32" /></picture></h2>
805
-
806
- Récupération triple-flux combinant trois signaux :
807
-
808
- | Flux | Ce qu'il fait | Quand |
809
- |---|---|---|
810
- | **BM25** | Correspondance par mots-clés racinisés avec expansion par synonymes | Toujours actif |
811
- | **Vector** | Similarité cosinus sur embeddings denses | Fournisseur d'embedding configuré |
812
- | **Graph** | Parcours du graphe de connaissances par correspondance d'entités | Entités détectées dans la requête |
813
-
814
- Fusionnés par Reciprocal Rank Fusion (RRF, k=60) et diversifiés par session (max 3 résultats par session).
815
-
816
- BM25 tokenise nativement le grec, le cyrillique, l'hébreu, l'arabe et le latin accentué. Pour des mémoires en chinois / japonais / coréen, installez les segmenteurs optionnels (`npm install @node-rs/jieba tiny-segmenter`) afin de découper les suites CJK en tokens au niveau du mot ; sans eux, agentmemory retombe doucement sur une tokenisation par suite entière et imprime un message indicatif unique sur stderr.
817
-
818
- ### Fournisseurs d'embedding
819
-
820
- agentmemory détecte automatiquement votre fournisseur. Pour de meilleurs résultats, installez les embeddings locaux (gratuits) :
821
-
822
- ```bash
823
- npm install @xenova/transformers
824
- ```
825
-
826
- | Fournisseur | Modèle | Coût | Notes |
827
- |---|---|---|---|
828
- | **Local (recommandé)** | `all-MiniLM-L6-v2` | Gratuit | Hors-ligne, +8 pp de rappel par rapport à BM25 seul |
829
- | Gemini | `gemini-embedding-001` | Niveau gratuit | 100+ langues, dimensions 768/1536/3072 (MRL), entrée 2048 tokens. Remplace `text-embedding-004` ([déprécié, arrêt le 14 jan. 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
830
- | OpenAI | `text-embedding-3-small` | 0,02 $/1M | Meilleure qualité |
831
- | Voyage AI | `voyage-code-3` | Payant | Optimisé pour le code |
832
- | Cohere | `embed-english-v3.0` | Essai gratuit | Polyvalent |
833
- | OpenRouter | N'importe quel modèle | Variable | Proxy multi-modèles |
834
-
835
- ---
836
-
837
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Serveur MCP" height="32" /></picture></h2>
838
-
839
- 53 outils, 6 ressources, 3 prompts et 4 skills — la boîte à outils mémoire MCP la plus complète pour tout agent.
840
-
841
- > **Shim MCP vs serveur complet :** le paquet publié `@agentmemory/mcp` est un shim léger. Il expose la surface complète de 51 outils **uniquement quand il peut joindre un serveur agentmemory actif** via `AGENTMEMORY_URL` (mode proxy). Sans serveur joignable, le shim retombe sur un jeu local de 7 outils (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). La variable d'env `AGENTMEMORY_TOOLS=core|all` est un drapeau *côté serveur* — la définir dans le bloc `env` du shim n'a aucun effet. Si vous ne voyez que 7 outils dans Cursor / OpenCode / Gemini CLI, lancez `npx @agentmemory/agentmemory` (ou la stack Docker) et définissez `AGENTMEMORY_URL=http://localhost:3111`.
842
-
843
- ### 51 outils
844
-
845
- <details>
846
- <summary>Outils de base (toujours disponibles)</summary>
847
-
848
- | Outil | Description |
849
- |------|-------------|
850
- | `memory_recall` | Rechercher dans les observations passées |
851
- | `memory_compress_file` | Compresser des fichiers markdown en préservant la structure |
852
- | `memory_save` | Sauvegarder un insight, une décision ou un motif |
853
- | `memory_patterns` | Détecter des motifs récurrents |
854
- | `memory_smart_search` | Recherche hybride sémantique + mots-clés |
855
- | `memory_file_history` | Observations passées sur des fichiers spécifiques |
856
- | `memory_sessions` | Lister les sessions récentes |
857
- | `memory_timeline` | Observations chronologiques |
858
- | `memory_profile` | Profil de projet (concepts, fichiers, motifs) |
859
- | `memory_export` | Exporter toutes les données mémoire |
860
- | `memory_relations` | Interroger le graphe de relations |
861
-
862
- </details>
863
-
864
- <details>
865
- <summary>Outils étendus (51 au total — définissez AGENTMEMORY_TOOLS=all)</summary>
866
-
867
- | Outil | Description |
868
- |------|-------------|
869
- | `memory_patterns` | Détecter des motifs récurrents |
870
- | `memory_timeline` | Observations chronologiques |
871
- | `memory_relations` | Interroger le graphe de relations |
872
- | `memory_graph_query` | Parcours du graphe de connaissances |
873
- | `memory_consolidate` | Lancer la consolidation à 4 niveaux |
874
- | `memory_claude_bridge_sync` | Synchroniser avec MEMORY.md |
875
- | `memory_team_share` | Partager avec les membres de l'équipe |
876
- | `memory_team_feed` | Éléments partagés récemment |
877
- | `memory_audit` | Piste d'audit des opérations |
878
- | `memory_governance_delete` | Supprimer avec piste d'audit |
879
- | `memory_snapshot_create` | Snapshot versionné git |
880
- | `memory_action_create` | Créer des éléments de travail avec dépendances |
881
- | `memory_action_update` | Mettre à jour le statut d'une action |
882
- | `memory_frontier` | Actions débloquées classées par priorité |
883
- | `memory_next` | Seule action suivante la plus importante |
884
- | `memory_lease` | Leases d'action exclusifs (multi-agents) |
885
- | `memory_routine_run` | Instancier des routines de workflow |
886
- | `memory_signal_send` | Messagerie inter-agents |
887
- | `memory_signal_read` | Lire des messages avec accusés |
888
- | `memory_checkpoint` | Portes de condition externes |
889
- | `memory_mesh_sync` | Sync P2P entre instances |
890
- | `memory_sentinel_create` | Watchers événementiels |
891
- | `memory_sentinel_trigger` | Déclencher des sentinelles depuis l'extérieur |
892
- | `memory_sketch_create` | Graphes d'action éphémères |
893
- | `memory_sketch_promote` | Promouvoir en permanent |
894
- | `memory_crystallize` | Compacter les chaînes d'actions |
895
- | `memory_diagnose` | Vérifications de santé |
896
- | `memory_heal` | Auto-correction d'état bloqué |
897
- | `memory_facet_tag` | Tags dimension:valeur |
898
- | `memory_facet_query` | Interroger par tags de facettes |
899
- | `memory_verify` | Tracer la provenance |
900
-
901
- </details>
902
-
903
- ### 6 Ressources · 3 Prompts · 4 Skills
904
-
905
- | Type | Nom | Description |
906
- |------|------|-------------|
907
- | Ressource | `agentmemory://status` | Santé, nombre de sessions, nombre de mémoires |
908
- | Ressource | `agentmemory://project/{name}/profile` | Intelligence par projet |
909
- | Ressource | `agentmemory://memories/latest` | 10 dernières mémoires actives |
910
- | Ressource | `agentmemory://graph/stats` | Statistiques du graphe de connaissances |
911
- | Prompt | `recall_context` | Recherche + retour de messages de contexte |
912
- | Prompt | `session_handoff` | Données de passation entre agents |
913
- | Prompt | `detect_patterns` | Analyser les motifs récurrents |
914
- | Skill | `/recall` | Rechercher la mémoire |
915
- | Skill | `/remember` | Sauvegarder en mémoire long-terme |
916
- | Skill | `/session-history` | Résumés de sessions récentes |
917
- | Skill | `/forget` | Supprimer observations / sessions |
918
-
919
- ### MCP autonome
920
-
921
- Tourne sans le serveur complet — pour n'importe quel client MCP. L'une ou l'autre marche :
922
-
923
- ```bash
924
- npx -y @agentmemory/agentmemory mcp # canonical (always available)
925
- npx -y @agentmemory/mcp # shim package alias
926
- ```
927
-
928
- Ou ajoutez à la config MCP de votre agent :
929
-
930
- La plupart des agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI) :
931
- ```json
932
- {
933
- "mcpServers": {
934
- "agentmemory": {
935
- "command": "npx",
936
- "args": ["-y", "@agentmemory/mcp"],
937
- "env": {
938
- "AGENTMEMORY_URL": "http://localhost:3111"
939
- }
940
- }
941
- }
942
- }
943
- ```
944
-
945
- Fusionnez l'entrée `agentmemory` dans l'objet `mcpServers` existant de votre hôte plutôt que de remplacer le fichier. Pour des clients en sandbox qui ne peuvent pas joindre le `localhost` de l'hôte, ajoutez `"AGENTMEMORY_FORCE_PROXY": "1"` au bloc env et pointez `AGENTMEMORY_URL` vers une route que la sandbox peut atteindre.
946
-
947
- OpenCode (`opencode.json`) :
948
- ```json
949
- {
950
- "mcp": {
951
- "agentmemory": {
952
- "type": "local",
953
- "command": ["npx", "-y", "@agentmemory/mcp"],
954
- "enabled": true
955
- }
956
- },
957
- "plugin": ["./plugins/agentmemory-capture.ts"]
958
- }
959
- ```
960
-
961
- Copiez le fichier plugin depuis le dépôt :
962
- ```bash
963
- mkdir -p ~/.config/opencode/plugins
964
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
965
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
966
- ```
967
-
968
- ---
969
-
970
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Visualiseur temps réel" height="32" /></picture></h2>
971
-
972
- Démarre automatiquement sur le port `3113`. Flux d'observations en direct, explorateur de sessions, navigateur mémoire, visualisation du graphe de connaissances et tableau de bord de santé.
973
-
974
- ```bash
975
- open http://localhost:3113
976
- ```
977
-
978
- Le serveur du visualiseur se lie à `127.0.0.1` par défaut. Le point d'entrée `/agentmemory/viewer` servi par REST suit les règles normales de bearer-token `AGENTMEMORY_SECRET`. Les en-têtes CSP utilisent un nonce de script par réponse et désactivent les attributs gestionnaires inline (`script-src-attr 'none'`).
979
-
980
- ---
981
-
982
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
983
-
984
- Le visualiseur sur `:3113` montre ce que votre agent **a mémorisé**. La [iii console](https://iii.dev/docs/console) montre ce que votre agent **a fait** — chaque op mémoire comme trace OpenTelemetry, chaque entrée KV éditable, chaque fonction invocable, chaque flux taps-able. Deux fenêtres sur la même mémoire : l'une orientée produit, l'autre orientée moteur.
985
-
986
- Regardez un `memory_smart_search` se déclencher et voyez le scan BM25 → recherche d'embeddings → fusion RRF → reranker comme un waterfall. Éditez un timer de consolidation bloqué dans le navigateur KV. Rejouez un hook `PostToolUse` avec une charge utile modifiée. ��pinglez le flux WebSocket et regardez les observations arriver en direct.
987
-
988
- agentmemory livre cela gratuitement parce que chaque fonction, trigger, scope d'état et flux est une primitive iii — rien de personnalisé, rien à instrumenter.
989
-
990
- <p align="center">
991
- <img src="../assets/iii-console/workers.png" alt="iii console — page Workers montrant les workers connectés, dont les instances agentmemory avec compteurs de fonctions en direct et métadonnées de runtime" width="720" />
992
- <br/>
993
- <em>Page Workers : chaque worker connecté — y compris agentmemory lui-même — avec PID, nombre de fonctions, runtime et last-seen.</em>
994
- </p>
995
-
996
- **Déjà installé.** La console est livrée avec `iii` — pas d'installeur séparé.
997
-
998
- **Lancer aux côtés d'agentmemory :**
999
-
1000
- ```bash
1001
- # agentmemory viewer holds port 3113, so run the console on 3114.
1002
- # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1003
- iii console --port 3114
1004
- ```
1005
-
1006
- Puis ouvrez `http://localhost:3114`. Ajoutez `--enable-flow` pour la page expérimentale de graphe d'architecture.
1007
-
1008
- Surchargez les endpoints du moteur uniquement si vous les avez déplacés :
1009
-
1010
- ```bash
1011
- iii console --port 3114 \
1012
- --engine-port 3111 \
1013
- --ws-port 3112 \
1014
- --bridge-port 49134
1015
- ```
1016
-
1017
- **Ce que vous pouvez faire depuis la console :**
1018
-
1019
- | Page | Pour |
1020
- |------|-----------|
1021
- | **Workers** | Voir chaque worker connecté et ses métriques en direct — y compris le worker agentmemory lui-même. |
1022
- | **Functions** | Invoquer n'importe quelle fonction d'agentmemory avec une charge utile JSON — pratique pour tester `memory.recall`, `memory.consolidate`, `graph.query` sans câbler un client. |
1023
- | **Triggers** | Rejouer les triggers HTTP, cron, event et state — déclencher manuellement le cron de consolidation, retenter une route HTTP, émettre un changement d'état. |
1024
- | **States** | Navigateur KV avec CRUD complet — sessions, slots mémoire, timers de cycle de vie, index d'embeddings — éditer les valeurs sur place. |
1025
- | **Streams** | Moniteur WebSocket en direct pour les écritures mémoire, événements de hooks et mises à jour d'observations à mesure qu'ils circulent dans les iii streams. |
1026
- | **Queues** | Topics de files durables + gestion de la dead-letter. Rejouer ou abandonner les jobs d'embedding / compression échoués. |
1027
- | **Traces** | Vues waterfall / flame / décomposition par service OpenTelemetry. Filtrez par `trace_id` pour voir exactement quelles fonctions, appels DB et requêtes d'embedding une seule `memory.search` a produits. |
1028
- | **Logs** | Logs OTEL structurés filtrés et corrélés aux IDs de trace/span. |
1029
- | **Config** | Configuration runtime — voir exactement quels workers, fournisseurs et ports tourne votre moteur. |
1030
- | **Flow** | (Optionnel, `--enable-flow`) Graphe d'architecture interactif de chaque worker, trigger et flux. |
1031
-
1032
- <p align="center">
1033
- <img src="../assets/iii-console/traces-waterfall.png" alt="vue waterfall de traces dans iii console montrant la durée par span" width="720" />
1034
- <br/>
1035
- <em>Traces : waterfall / flame / décomposition par service pour chaque opération mémoire.</em>
1036
- </p>
1037
-
1038
- **Les traces sont déjà actives :**
1039
-
1040
- `iii-config.yaml` est livré avec le worker `iii-observability` activé (`exporter: memory`, `sampling_ratio: 1.0`, métriques + logs). Aucune config supplémentaire — dès qu'agentmemory démarre, chaque opération mémoire émet un span de trace et un log structuré que la console peut lire.
1041
-
1042
- Si vous voulez exporter vers Jaeger/Honeycomb/Grafana Tempo à la place, changez `exporter: memory` en `exporter: otlp` et définissez l'endpoint du collecteur selon la documentation d'observabilité d'iii.
1043
-
1044
- > **Attention :** aucune auth n'est appliquée sur la console elle-même — gardez-la liée à `127.0.0.1` (par défaut) et ne l'exposez jamais publiquement.
1045
-
1046
- ---
1047
-
1048
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1049
-
1050
- agentmemory est **déjà une instance [iii](https://iii.dev) en cours d'exécution**. Fonctions, triggers, état KV, flux, traces OTEL — tout est primitive iii. Vous n'avez pas installé Postgres, Redis, Express, pm2, ni Prometheus, parce qu'iii les remplace.
1051
-
1052
- Cela signifie qu'une commande supplémentaire étend agentmemory d'une toute nouvelle capacité.
1053
-
1054
- ### Étendez agentmemory avec une seule commande
1055
-
1056
- ```bash
1057
- iii worker add iii-pubsub # fan memory writes out to every connected instance
1058
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1059
- iii worker add iii-queue # durable retries for embedding + compression jobs
1060
- iii worker add iii-observability # OTEL traces on every memory op (default on)
1061
- iii worker add iii-sandbox # run recalled code inside an isolated microVM
1062
- iii worker add iii-database # swap in a SQL-backed state adapter
1063
- iii worker add mcp # generic MCP host alongside the agentmemory MCP
1064
- ```
1065
-
1066
- Chaque `iii worker add` enregistre de nouvelles fonctions et triggers dans le même moteur sur lequel agentmemory tourne déjà. Le visualiseur et la console les prennent en compte immédiatement — sans rechargement, sans nouvelle intégration, sans nouveau conteneur.
1067
-
1068
- | `iii worker add` | Ce que vous obtenez en plus d'agentmemory |
1069
- |---|---|
1070
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Mémoire multi-instances : chaque `remember` se diffuse, chaque `search` lit l'union |
1071
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Cycle de vie planifié — consolidation nocturne, snapshots hebdomadaires, décroissance sur horloge fixe |
1072
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Retries durables : les jobs d'embedding + compression en échec survivent au redémarrage, aucune observation perdue |
1073
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Traces, métriques et logs OTEL sur chaque fonction — câblés dans `iii-config.yaml` dès le premier jour |
1074
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Le code issu de `memory_recall` s'exécute dans une VM jetable, pas dans votre shell |
1075
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptateur d'état adossé à SQL lorsque vous dépassez les valeurs par défaut KV en mémoire |
1076
- | [`mcp`](https://workers.iii.dev/workers/mcp) | Déployez des serveurs MCP supplémentaires à côté de celui d'agentmemory, partageant le même moteur |
1077
-
1078
- Registre complet : [workers.iii.dev](https://workers.iii.dev). Chaque worker là-bas se compose via les mêmes primitives qu'utilise agentmemory — et l'agentmemory que vous avez déjà en est un.
1079
-
1080
- ### Ce qu'iii remplace
1081
-
1082
- | Stack traditionnelle | agentmemory utilise |
1083
- |---|---|
1084
- | Express.js / Fastify | iii HTTP Triggers |
1085
- | SQLite / Postgres + pgvector | iii KV State + index vectoriel en mémoire |
1086
- | SSE / Socket.io | iii Streams (WebSocket) |
1087
- | pm2 / systemd | Supervision de workers du moteur iii |
1088
- | Prometheus / Grafana | iii OTEL + moniteur de santé |
1089
- | Systèmes de plugins personnalisés | `iii worker add <name>` |
1090
-
1091
- **118 fichiers sources · ~21 800 LOC · 950+ tests · 123 fonctions · 34 scopes KV** — tout sur trois primitives. Pas de `agentmemory plugin install`. Le système de plugins, c'est iii lui-même.
1092
-
1093
- ---
1094
-
1095
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1096
-
1097
- ### Fournisseurs LLM
1098
-
1099
- agentmemory détecte automatiquement depuis votre environnement. Par défaut, aucun appel LLM n'est effectué tant que vous n'avez pas configuré de fournisseur ou explicitement opté pour le fallback abonnement Claude.
1100
-
1101
- | Fournisseur | Config | Notes |
1102
- |----------|--------|-------|
1103
- | **No-op (par défaut)** | Aucune config nécessaire | Le compress/summarize adossé à un LLM est DÉSACTIVÉ. La compression et le recall BM25 synthétiques fonctionnent toujours. Voir `AGENTMEMORY_ALLOW_AGENT_SDK` ci-dessous si vous comptiez sur le fallback abonnement Claude. |
1104
- | Anthropic API | `ANTHROPIC_API_KEY` | Facturation au token |
1105
- | MiniMax | `MINIMAX_API_KEY` | Compatible Anthropic |
1106
- | Gemini | `GEMINI_API_KEY` | Active aussi les embeddings |
1107
- | OpenRouter | `OPENROUTER_API_KEY` | N'importe quel modèle |
1108
- | Fallback abonnement Claude | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Opt-in seulement. Engendre des sessions `@anthropic-ai/claude-agent-sdk` — provoquait une récursion non bornée du Stop-hook (suite de #149), il n'est plus l'option par défaut. |
1109
-
1110
- ### Sélection de modèle attentive au coût
1111
-
1112
- La compression en arrière-plan tourne sur chaque observation, donc le choix du modèle influence sensiblement la dépense mensuelle. Données de charge capturées : 635 requêtes / 888K tokens / 35 heures d'usage actif, exécutées contre trois modèles OpenRouter au tarif du 2026-05-23.
1113
-
1114
- | Niveau | Modèle | Entrée / 1M | Sortie / 1M | Coût pour les 35h capturées | Notes |
1115
- |------|-------|------------|-------------|---------------------------|-------|
1116
- | Recommandé | `deepseek/deepseek-v4-pro` | 0,435 $ | 0,87 $ | ~0,46 $ | Qualité de compression + résumé solide à un coût ~10× moindre que Sonnet. |
1117
- | Recommandé | `deepseek/deepseek-chat` | 0,27 $ | 1,10 $ | ~0,40 $ | Plus ancien mais toujours satisfaisant pour des charges de compression uniquement. |
1118
- | Recommandé | `qwen/qwen3-coder` | 0,45 $ | 1,80 $ | ~0,55 $ | Solide raisonnement code si vos sessions sont fortement code-shaped. |
1119
- | Premium | `anthropic/claude-sonnet-4.6` | 3,00 $ | 15,00 $ | ~5,02 $ | Haute qualité mais coûteux pour du travail de fond permanent. |
1120
- | Premium | `openai/gpt-4o` | 2,50 $ | 10,00 $ | ~4,20 $ | Niveau similaire à Sonnet. |
1121
- | À éviter | `anthropic/claude-opus-4.6` | 15,00 $ | 75,00 $ | ~25+ $ | Modèle classe raisonnement ; surcoût massif pour de la compression. |
1122
-
1123
- agentmemory imprime un avertissement runtime quand `OPENROUTER_MODEL` correspond à un motif de niveau premium. Définissez `AGENTMEMORY_SUPPRESS_COST_WARNING=1` pour le faire taire une fois votre choix éclairé.
1124
-
1125
- Compromis qualité vs coût pour le travail mémoire : la compression est une tâche de résumé avec des exigences de qualité relativement souples (c'est l'agent qui relit le résumé, pas l'utilisateur). DeepSeek-V4-Pro / Qwen3-Coder se situent à la précision d'arrondi près de Sonnet sur cette tâche tout en coûtant ~10× moins. Réservez les modèles premium aux requêtes que vous lisez directement.
1126
-
1127
- Sources : [tarification OpenRouter pour Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [notes de prix DeepSeek](https://api-docs.deepseek.com/quick_start/pricing/).
1128
-
1129
- ### Mémoire multi-agents (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1130
-
1131
- Dans des configurations multi-agents où plusieurs rôles partagent un même serveur agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` marque chaque écriture avec le rôle qui l'a produite. `AGENTMEMORY_AGENT_SCOPE` contrôle si le recall filtre par ce tag.
1132
-
1133
- ```env
1134
- TEAM_ID=company
1135
- USER_ID=engineering-team
1136
- AGENT_ID=architect
1137
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1138
- ```
1139
-
1140
- Deux modes :
1141
-
1142
- | Mode | Marquer les écritures | Filtrer le recall | Quand l'utiliser |
1143
- |------|------------|---------------|-------------|
1144
- | `shared` (par défaut) | oui | non | Contexte inter-agents avec piste d'audit. L'architect voit ce que le developer a noté, mais chaque ligne enregistre qui l'a dit. |
1145
- | `isolated` | oui | oui | Séparation stricte. L'architect ne voit jamais les observations / mémoires / sessions du developer. |
1146
-
1147
- Ce qui est marqué quand `AGENT_ID` est défini : `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Le rôle circule de `api::session::start` → `mem::observe` → `mem::compress` → KV.
1148
-
1149
- Ce qui est filtré en mode isolé : `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Chaque endpoint accepte `?agentId=<role>` pour surcharger par requête, et `?agentId=*` pour se désinscrire entièrement du scope de l'env. `/memories` accepte aussi `?includeOrphans=true` pour faire remonter les mémoires antérieures à AGENT_ID dont `agentId` est indéfini.
1150
-
1151
- Surcharge par appel au niveau SDK / REST : chaque endpoint mutant (`/session/start`, `/remember`) accepte un champ `agentId` dans le corps de la requête qui gagne sur l'env. Utile pour des runtimes qui routent plusieurs rôles à travers un même processus serveur.
1152
-
1153
- Quand `AGENT_ID` n'est pas défini, la mémoire reste non scopée (comportement legacy, sans tags ni filtres).
1154
-
1155
- ### Ports
1156
-
1157
- agentmemory + iii-engine se lient à quatre ports par défaut. Si un redémarrage échoue avec `port in use`, ce tableau vous indique le processus à chercher.
1158
-
1159
- | Port | Processus | Usage | Surcharge env |
1160
- |------|---------|---------|--------------|
1161
- | `3111` | agentmemory | API REST + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1162
- | `3112` | iii-engine | Worker streams interne (consommé par agentmemory + visualiseur) | `III_STREAMS_PORT` |
1163
- | `3113` | agentmemory | Visualiseur temps réel (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1164
- | `49134` | iii-engine | WebSocket — les workers s'y enregistrent, la télémétrie OTel y circule | `III_ENGINE_URL` (URL complète, défaut `ws://localhost:49134`) |
1165
-
1166
- Nettoyage de processus zombies quand des ports restent occupés après un crash :
1167
-
1168
- ```bash
1169
- # macOS / Linux — find whatever is on each port and kill it
1170
- lsof -i :3111,3112,3113,49134
1171
- pkill -f agentmemory || true
1172
- pkill -f 'iii ' || true
1173
-
1174
- # Windows
1175
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1176
- taskkill /F /PID <pid>
1177
- ```
1178
-
1179
- `agentmemory stop` réclame proprement à la fois le worker et le pidfile du moteur en arrêt gracieux (#640, #474). Le nettoyage manuel ci-dessus n'est nécessaire que pour le cas post-crash où aucun pidfile n'est laissé en place.
1180
-
1181
- ### Fichier de configuration
1182
-
1183
- Mettez la configuration runtime d'agentmemory dans `~/.agentmemory/.env` au lieu d'exporter des variables dans chaque shell. Si le visualiseur affiche un indice de setup comme `export ANTHROPIC_API_KEY=...`, recopiez-le dans ce fichier sous la forme `ANTHROPIC_API_KEY=...` sans le préfixe `export`, puis redémarrez agentmemory.
1184
-
1185
- Les variables d'environnement du processus restent valides et prennent le pas sur les valeurs du fichier.
1186
-
1187
- Sur Windows, le même fichier se trouve dans `%USERPROFILE%\.agentmemory\.env` :
1188
-
1189
- ```powershell
1190
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1191
- notepad $HOME\.agentmemory\.env
1192
- ```
1193
-
1194
- Pour tester avec un abonnement Claude Code Pro/Max au lieu d'une clé d'API, optez-vous explicitement :
1195
-
1196
- ```env
1197
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1198
- AGENTMEMORY_AUTO_COMPRESS=true
1199
- ```
1200
-
1201
- Activez les fonctionnalités de graphe ou de consolidation dans le même fichier si vous les voulez :
1202
-
1203
- ```env
1204
- GRAPH_EXTRACTION_ENABLED=true
1205
- CONSOLIDATION_ENABLED=true
1206
- ```
1207
-
1208
- ### Variables d'environnement
1209
-
1210
- Créez `~/.agentmemory/.env` :
1211
-
1212
- ```env
1213
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1214
- # ANTHROPIC_API_KEY=sk-ant-...
1215
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1216
- # GEMINI_API_KEY=...
1217
- # OPENROUTER_API_KEY=...
1218
- # MINIMAX_API_KEY=...
1219
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1220
- # # OpenAI LLM provider (here) AND the OpenAI
1221
- # # embedding provider (further below). Set
1222
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1223
- # # to embeddings only.
1224
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1225
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1226
- # # Auto-detected from `.openai.azure.com` hostname; uses
1227
- # # api-key header + api-version query param.
1228
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1229
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1230
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1231
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1232
- # # for back-compat with v0.9.17. New configs should
1233
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1234
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1235
- # # Honored only by OpenAI's reasoning models (o1, o3,
1236
- # # gpt-*-reasoning) and providers that mirror that
1237
- # # schema (Ollama Cloud thinking models). Standard
1238
- # # chat models reject this field with 400. Set to
1239
- # # "none" for thinking models that return reasoning
1240
- # # but no content.
1241
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1242
- # # for LLM (useful if you only want OpenAI for embeddings)
1243
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1244
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1245
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1246
-
1247
- # Embedding provider (auto-detected, or override)
1248
- # EMBEDDING_PROVIDER=local
1249
- # VOYAGE_API_KEY=...
1250
- # OPENAI_API_KEY=sk-...
1251
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1252
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1253
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1254
-
1255
- # Outbound LLM / embedding timeout
1256
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1257
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1258
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1259
- # embedding). For the OpenAI LLM path, the
1260
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1261
- # takes precedence when set, for back-compat
1262
- # with v0.9.17.
1263
- # Increase for slow networks or large batch calls;
1264
- # decrease to fail-fast on rate-limit holds.
1265
-
1266
- # Search tuning
1267
- # BM25_WEIGHT=0.4
1268
- # VECTOR_WEIGHT=0.6
1269
- # TOKEN_BUDGET=2000
1270
-
1271
- # Auth
1272
- # AGENTMEMORY_SECRET=your-secret
1273
-
1274
- # Ports (defaults: 3111 API, 3113 viewer)
1275
- # III_REST_PORT=3111
1276
-
1277
- # Features
1278
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1279
- # every PostToolUse hook calls your
1280
- # LLM provider to compress the
1281
- # observation — expect significant
1282
- # token spend on active sessions.
1283
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1284
- # memory slots — persona,
1285
- # user_preferences, tool_guidelines,
1286
- # project_context, guidance,
1287
- # pending_items, session_patterns,
1288
- # self_notes. Size-limited; agent
1289
- # edits via memory_slot_* tools.
1290
- # Pinned slots addressable for
1291
- # SessionStart injection.
1292
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1293
- # Stop hook fires mem::slot-reflect:
1294
- # scans recent observations, auto-
1295
- # appends TODOs to pending_items,
1296
- # counts patterns in
1297
- # session_patterns, records touched
1298
- # files in project_context. Fire-
1299
- # and-forget; does not block.
1300
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1301
- # - SessionStart may inject ~1-2K
1302
- # chars of project context into
1303
- # the first turn of each session
1304
- # (this is what actually reaches
1305
- # the model — Claude Code treats
1306
- # SessionStart stdout as context)
1307
- # - PreToolUse fires /agentmemory/enrich
1308
- # on every file-touching tool call
1309
- # (resource cleanup, not a token
1310
- # fix — PreToolUse stdout is debug
1311
- # log only per Claude Code docs)
1312
- # Observations are still captured via
1313
- # PostToolUse regardless of this flag.
1314
- # GRAPH_EXTRACTION_ENABLED=false
1315
- # CONSOLIDATION_ENABLED=true
1316
- # LESSON_DECAY_ENABLED=true
1317
- # OBSIDIAN_AUTO_EXPORT=false
1318
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1319
- # CLAUDE_MEMORY_BRIDGE=false
1320
- # SNAPSHOT_ENABLED=false
1321
-
1322
- # Team
1323
- # TEAM_ID=
1324
- # USER_ID=
1325
- # TEAM_MODE=private
1326
-
1327
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1328
- # AGENTMEMORY_TOOLS=core
1329
- ```
1330
-
1331
- ---
1332
-
1333
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1334
-
1335
- 124 endpoints sur le port `3111`. L'API REST se lie à `127.0.0.1` par défaut. Les endpoints protégés exigent `Authorization: Bearer <secret>` lorsque `AGENTMEMORY_SECRET` est défini, et les endpoints de mesh sync exigent `AGENTMEMORY_SECRET` sur les deux pairs.
1336
-
1337
- <details>
1338
- <summary>Endpoints clés</summary>
1339
-
1340
- | Méthode | Chemin | Description |
1341
- |--------|------|-------------|
1342
- | `GET` | `/agentmemory/health` | Vérification de santé (toujours publique) |
1343
- | `POST` | `/agentmemory/session/start` | Démarrer une session + obtenir le contexte |
1344
- | `POST` | `/agentmemory/session/end` | Terminer une session |
1345
- | `POST` | `/agentmemory/observe` | Capturer une observation |
1346
- | `POST` | `/agentmemory/smart-search` | Recherche hybride |
1347
- | `POST` | `/agentmemory/context` | Générer du contexte |
1348
- | `POST` | `/agentmemory/remember` | Sauvegarder en mémoire long-terme |
1349
- | `POST` | `/agentmemory/forget` | Supprimer des observations |
1350
- | `POST` | `/agentmemory/enrich` | Contexte de fichier + mémoires + bugs |
1351
- | `GET` | `/agentmemory/profile` | Profil de projet |
1352
- | `GET` | `/agentmemory/export` | Exporter toutes les données |
1353
- | `POST` | `/agentmemory/import` | Importer depuis JSON |
1354
- | `POST` | `/agentmemory/graph/query` | Requête sur le graphe de connaissances |
1355
- | `POST` | `/agentmemory/team/share` | Partager avec l'équipe |
1356
- | `GET` | `/agentmemory/audit` | Piste d'audit |
1357
-
1358
- Liste complète des endpoints : [`src/triggers/api.ts`](../src/triggers/api.ts)
1359
-
1360
- </details>
1361
-
1362
- ---
1363
-
1364
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Développement" height="32" /></picture></h2>
1365
-
1366
- ```bash
1367
- npm run dev # Hot reload
1368
- npm run build # Production build
1369
- npm test # 950+ tests
1370
- npm run test:integration # API tests (requires running services)
1371
- ```
1372
-
1373
- **Prérequis :** Node.js >= 20, [iii-engine](https://iii.dev/docs) ou Docker
1374
-
1375
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licence" height="32" /></picture></h2>
1376
-
1377
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.hi-IN.md DELETED
@@ -1,1380 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — AI कोडिंग एजेंट्स के लिए स्थायी मेमोरी" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- आपका कोडिंग एजेंट सब कुछ याद रखता है। बार-बार समझाने की ज़रूरत नहीं।
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, और किसी भी MCP क्लाइंट के लिए स्थायी मेमोरी।
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- हिन्दी |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>यह gist Karpathy के LLM Wiki पैटर्न को confidence scoring, lifecycle, knowledge graphs और hybrid search के साथ बढ़ाता है: agentmemory इसका implementation है।</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">इंस्टॉल</a> &bull;
73
- <a href="#quick-start">क्विक स्टार्ट</a> &bull;
74
- <a href="#benchmarks">बेंचमार्क्स</a> &bull;
75
- <a href="#vs-competitors">प्रतिस्पर्धियों से तुलना</a> &bull;
76
- <a href="#works-with-every-agent">एजेंट्स</a> &bull;
77
- <a href="#how-it-works">यह कैसे काम करता है</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">व्यूअर</a> &bull;
80
- <a href="#iii-console">iii कंसोल</a> &bull;
81
- <a href="#powered-by-iii">iii द्वारा संचालित</a> &bull;
82
- <a href="#configuration">कॉन्फ़िग</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## इंस्टॉल
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # एक बार — PATH पर `agentmemory` कमांड उपलब्ध
92
- # अगर macOS/Linux सिस्टम Node इंस्टॉल पर EACCES त्रुटि आती है, तो इसके साथ फिर से चलाएँ:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # :3111 पर मेमोरी सर्वर शुरू करें
95
- agentmemory demo # नमूना सेशंस सीड करें + recall साबित करें
96
- agentmemory connect claude-code # अपना एजेंट जोड़ें (अन्य: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- या `npx` के माध्यम से (इंस्टॉल की ज़रूरत नहीं):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- ध्यान दें — npx प्रति-वर्ज़न कैश करता है। अगर बेयर `npx @agentmemory/agentmemory` कोई पुराना रिलीज़ चला रहा है, तो नवीनतम को `npx -y @agentmemory/agentmemory@latest` से ज़बरदस्ती चलाएँ, या एक बार `rm -rf ~/.npm/_npx` से कैश साफ़ करें (macOS/Linux; Windows पर `%LOCALAPPDATA%\npm-cache\_npx` हटाएँ)। v0.9.16+ के बाद पहली npx रन आपको इनलाइन ग्लोबल इंस्टॉल करने का प्रॉम्प्ट देती है ताकि बेयर `agentmemory` कमांड हर जगह काम करे।
106
-
107
- पूर्ण विकल्प नीचे [क्विक स्टार्ट](#quick-start) में हैं। एजेंट-विशिष्ट कॉन्फ़िगरेशन [हर एजेंट के साथ काम करता है](#works-with-every-agent) में।
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
-
113
- agentmemory किसी भी ऐसे एजेंट के साथ काम करता है जो hooks, MCP, या REST API सपोर्ट करता है। सभी एजेंट एक ही मेमोरी सर्वर साझा करते हैं।
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>native plugin + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>native plugin + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>native plugin + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>native plugin + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>native plugin + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>native Memory trait बैकएंड</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP सर्वर</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP सर्वर</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP सर्वर</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP सर्वर</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP सर्वर</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP सर्वर</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP सर्वर</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP सर्वर</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>MCP या HTTP बोलने वाले <strong>किसी भी</strong> एजेंट के साथ काम करता है। एक सर्वर, सभी के बीच साझा मेमोरी।</sub>
204
- </p>
205
-
206
- ---
207
-
208
- आप हर सेशन में वही आर्किटेक्चर समझाते हैं। आप वही bugs बार-बार खोजते हैं। आप वही प्राथमिकताएँ फिर से सिखाते हैं। बिल्ट-इन मेमोरी (CLAUDE.md, .cursorrules) 200 लाइनों पर सीमित है और पुरानी हो जाती है। agentmemory इसे ठीक करता है। यह चुपचाप आपके एजेंट की गतिविधियाँ कैप्चर करता है, उन्हें खोज योग्य मेमोरी में संकुचित करता है, और अगला सेशन शुरू होने पर सही संदर्भ इंजेक्ट करता है। एक कमांड। सभी एजेंट्स के साथ काम करता है।
209
-
210
- **क्या बदलता है:** सेशन 1 में आप JWT auth सेटअप करते हैं। सेशन 2 में आप rate limiting माँगते हैं। एजेंट को पहले से पता है कि आपकी auth `src/middleware/auth.ts` में jose middleware का उपयोग करती है, आपके tests token validation को कवर करते हैं, और आपने Edge compatibility के लिए jsonwebtoken के बजाय jose चुना है। फिर से समझाना नहीं। कॉपी-पेस्ट नहीं। एजेंट बस *जानता है*।
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0 में नया** — लैंडिंग साइट [agent-memory.dev](https://agent-memory.dev), फाइलसिस्टम कनेक्टर (`@agentmemory/fs-watcher`), स्टैंडअलोन MCP अब चल रहे सर्वर को प्रॉक्सी करता है ताकि hooks और व्यूअर सहमत हों, हर delete path में audit policy कोडिफाई की गई, small Node प्रक्रियाओं पर health अब `memory_critical` फ़्लैग नहीं करता। पूरे नोट्स [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) में।
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Retrieval सटीकता
227
-
228
- **coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
229
-
230
- | Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100% top-5 hit rate। समान input पर grep baseline से **2.2×** बेहतर precision। पूरी प्रकार-वार breakdown: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)।
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 प्रश्न)
238
-
239
- | System | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Token बचत
248
-
249
- | दृष्टिकोण | Tokens/yr | Cost/yr |
250
- |---|---|---|
251
- | पूरा context paste करें | 19.5M+ | असंभव (window से अधिक) |
252
- | LLM-summarized | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + local embeddings | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Embedding मॉडल: `all-MiniLM-L6-v2` (local, free, कोई API key नहीं)। पूरी रिपोर्ट्स: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md)। प्रतिस्पर्धी तुलना: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory बनाम mem0, Letta, Khoj, claude-mem, Hippo।
261
-
262
- **स्थानीय रूप से reproduce करें:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s` (public 500-Q) + `coding-agent-life-v1` (in-house 15-session corpus) के लिए adapter-pluggable harness। Grep / vector / agentmemory adapters साथ-साथ scored होते हैं, NDJSON output, प्रकाशित scorecards [`docs/benchmarks/`](../docs/benchmarks/) में जाते हैं।
263
-
264
- **[codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), और [Graphify](https://github.com/safishamsi/graphify) के साथ जोड़ता है।** Code-graph indexing, multi-agent build pipelines, और docs / PDFs / images / videos में व्यापक knowledge graphs। agentmemory काम याद रखता है; ये तीन प्रोजेक्ट्स context layer के बाकी हिस्से को रोशन करते हैं। Recipes + question-routing table: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md)।
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">बिल्ट-इन (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>प्रकार</strong></td>
280
- <td>Memory engine + MCP सर्वर</td>
281
- <td>Memory layer API</td>
282
- <td>पूर्ण agent runtime</td>
283
- <td>Static फाइल</td>
284
- </tr>
285
- <tr>
286
- <td><strong>Retrieval R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>स्वचालित कैप्चर</strong></td>
294
- <td>12 hooks (शून्य मैनुअल प्रयास)</td>
295
- <td>मैनुअल <code>add()</code> कॉल</td>
296
- <td>एजेंट self-edits</td>
297
- <td>मैनुअल editing</td>
298
- </tr>
299
- <tr>
300
- <td><strong>खोज</strong></td>
301
- <td>BM25 + Vector + Graph (RRF fusion)</td>
302
- <td>Vector + Graph</td>
303
- <td>Vector (archival)</td>
304
- <td>सब कुछ context में लोड करता है</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Multi-agent</strong></td>
308
- <td>MCP + REST + leases + signals</td>
309
- <td>API (कोई coordination नहीं)</td>
310
- <td>केवल Letta runtime में</td>
311
- <td>प्रति-एजेंट फाइलें</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Framework lock-in</strong></td>
315
- <td>कोई नहीं (कोई भी MCP क्लाइंट)</td>
316
- <td>कोई नहीं</td>
317
- <td>उच्च (Letta का उपयोग आवश्यक)</td>
318
- <td>प्रति-ए��ेंट format</td>
319
- </tr>
320
- <tr>
321
- <td><strong>बाहरी निर्भरताएँ</strong></td>
322
- <td>कोई नहीं (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + vector DB</td>
325
- <td>कोई नहीं</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Memory lifecycle</strong></td>
329
- <td>4-tier consolidation + decay + auto-forget</td>
330
- <td>Passive extraction</td>
331
- <td>Agent-managed</td>
332
- <td>मैनुअल pruning</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Token दक्षता</strong></td>
336
- <td>~1,900 tokens/session ($10/yr)</td>
337
- <td>integration पर निर्भर</td>
338
- <td>Core memory context में</td>
339
- <td>240 observations पर 22K+ tokens</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Real-time व्यूअर</strong></td>
343
- <td>हाँ (port 3113)</td>
344
- <td>Cloud dashboard</td>
345
- <td>Cloud dashboard</td>
346
- <td>नहीं</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Self-hosted</strong></td>
350
- <td>हाँ (default)</td>
351
- <td>Optional</td>
352
- <td>Optional</td>
353
- <td>हाँ</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
-
361
- संगतता: यह रिलीज़ stable `iii-sdk` `^0.11.0` और iii-engine v0.11.x को टार्गेट करता है।
362
-
363
- ### 30 सेकंड में आज़माएँ
364
-
365
- ```bash
366
- # Terminal 1: सर्वर शुरू करें
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: नमूना डेटा सीड करें और recall को कार्य में देखें
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` 3 यथार्थवादी सेशंस सीड करता है (JWT auth, N+1 query fix, rate limiting) और उन पर semantic searches चलाता है। जब आप "database performance optimization" खोजते हैं तो आप देखेंगे कि यह "N+1 query fix" ढूँढ़ लेता है — keyword matching ऐसा नहीं कर सकती।
374
-
375
- मेमोरी को लाइव बनते हुए देखने के लिए `http://localhost:3113` खोलें।
376
-
377
- ### अनुशंसित: globally इंस्टॉल करें
378
-
379
- `npx` per-version कैश करता है। अगर आपने पिछले हफ्ते `npx @agentmemory/agentmemory@0.9.14` चलाया था, तो एक बेयर `npx @agentmemory/agentmemory` `~/.npm/_npx/` से stale 0.9.14 दे सकता है, न कि नवीनतम रिलीज़। एक बार इंस्टॉल करें और बेयर `agentmemory` कमांड हर जगह काम करता है:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # अगर macOS/Linux सिस्टम Node इंस्टॉल पर EACCES त्रुटि आती है, इसके साथ फिर से चलाएँ:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # सर्वर शुरू करें (npx form के समान)
386
- agentmemory stop # बंद करें
387
- agentmemory remove # हमने जो भी बनाया उसे अनइंस्टॉल करें
388
- agentmemory connect claude-code # एक एजेंट जोड़ें
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- v0.9.16 के बाद से, पहली npx रन आपको inline globally इंस्टॉल करने का प्रॉम्प्ट देती है — एक बार `Y` जवाब दें और तैयार। अगर आप skip करते हैं, तो ताज़ा fetch के लिए इनमें से किसी पर भी fallback करें:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # npm से नवीनतम को force करता है (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # केवल macOS/Linux (POSIX shell)
397
- ```
398
-
399
- Windows / PowerShell पर, समतुल्य cache clear है `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — ऊपर का `npx -y ...@latest` form cross-platform विकल्प है।
400
-
401
- ### Session Replay
402
-
403
- agentmemory द्वारा रिकॉर्ड किया गया हर सेशन replayable है। व्यूअर खोलें, **Replay** टैब चुनें, और timeline scrub करें: prompts, tool calls, tool results, और responses अलग events के रूप में render होते हैं, play/pause, speed control (0.5×–4×), और keyboard shortcuts (space toggle के लिए, arrows step के लिए) के साथ।
404
-
405
- क्या आपके पास पहले से पुर���नी Claude Code JSONL transcripts हैं जिन्हें आप लाना चाहते हैं?
406
-
407
- ```bash
408
- # डिफ़ॉल्ट ~/.claude/projects के तहत सब कुछ import करें
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # या एक अकेली फाइल import करें
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- Imported सेशंस native ones के साथ Replay picker में दिखते हैं। हुड के नीचे प्रत्येक entry `mem::replay::load`, `mem::replay::sessions`, और `mem::replay::import-jsonl` iii functions के माध्यम से रूट होती है — कोई side-channel servers नहीं।
416
-
417
- ### Upgrade / Maintenance
418
-
419
- जब आप जानबूझकर अपने local runtime को update करना चाहते हैं तो maintenance command का उपयोग करें:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- चेतावनी: यह कमांड वर्तमान workspace/runtime को mutate करता है। यह JavaScript निर्भरताएँ update कर सकता है, `cargo install iii-engine --force` चला सकता है, और Docker images खींच सकता है।
426
-
427
- Implementation विवरण `src/cli.ts` में हैं (`src/cli.ts:544-595` क्षेत्र के आसपास `runUpgrade` देखें)।
428
-
429
- ### Claude Code (एक block, paste करें)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Plugin install के बिना Claude Code (MCP-standalone path)
436
-
437
- अगर आप `/plugin install` का उपयोग करने के बजाय `~/.claude.json` के माध्यम से सीधे agentmemory का MCP सर्वर कनेक्ट करते हैं, तो Claude Code कभी भी `${CLAUDE_PLUGIN_ROOT}` resolve नहीं करता और आपको hook scripts को `~/.claude/settings.json` में absolute paths पर point करना पड़ता है। ये paths आमतौर पर agentmemory version को embed करते हैं (जैसे `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), इसलिए अगला upgrade चुपचाप हर hook को तोड़ देता है ([#508](https://github.com/rohitg00/agentmemory/issues/508))।
438
-
439
- Workaround:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- यह वही hook commands को `~/.claude/settings.json` में merge करता है, current installed `@agentmemory/agentmemory` package की bundled `plugin/` directory पर resolve किए गए absolute paths के साथ। agentmemory upgrade करने के बाद paths refresh करने के लिए कमांड फिर से चलाएँ। उसी फाइल में user entries संरक्षित होती हैं; केवल पिछली agentmemory entries replace होती हैं। `/plugin install` path अनुशंसित approach बनी रहती है।
446
- Remote या protected deployments के लिए, Claude Code को `AGENTMEMORY_URL` और `AGENTMEMORY_SECRET` set के साथ launch करें। Plugin दोनों values को इसके bundled MCP सर्वर के माध्यम से pass करता है; जब `AGENTMEMORY_URL` खाली होता है, तो MCP shim `http://localhost:3111` का उपयोग करता है।
447
-
448
- ### Codex CLI (Codex plugin platform)
449
-
450
- ```bash
451
- # 1. एक अलग terminal में memory सर्वर शुरू करें
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. agentmemory marketplace register करें और plugin install करें
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- Codex plugin उसी `plugin/` directory से ship होता है जिससे Claude Code plugin। यह register करता है:
460
-
461
- - `@agentmemory/mcp` MCP सर्वर के रूप में (जब `AGENTMEMORY_URL` चल रहे agentmemory सर्वर पर point करता है, तो सभी 51 tools proxy करता है; कोई पहुँच योग्य सर्वर �� होने पर locally 7 tools पर fallback करता है)
462
- - 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- Codex का hook engine hook subprocesses में `CLAUDE_PLUGIN_ROOT` inject करता है ([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs) के अनुसार), इसलिए वही hook scripts duplication के बिना दोनों hosts में काम करते हैं। Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure events केवल Claude-Code-only हैं और Codex के लिए register नहीं होते।
466
-
467
- #### Codex Desktop: plugin hooks वर्तमान में silent हैं (workaround उपलब्ध)
468
-
469
- `CodexHooks` और `PluginHooks` दोनों [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) में stable + default-enabled हैं, लेकिन Codex Desktop builds वर्तमान में plugin-local `hooks.json` dispatch नहीं करते ([openai/codex#16430](https://github.com/openai/codex/issues/16430))। MCP tools अभी भी काम करते हैं; केवल lifecycle observations छूट जाते हैं।
470
-
471
- जब तक upstream fix land नहीं करता, वही hook commands को global `~/.codex/hooks.json` में mirror करें:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- यह `~/.codex/hooks.json` में एक idempotent block जोड़ता है जो bundled scripts के absolute paths को reference करता है (user-scope पर `${CLAUDE_PLUGIN_ROOT}` expansion की ज़रूरत नहीं)। agentmemory upgrade के बाद paths refresh करने के लिए वही कमांड फिर से चलाएँ। उसी फाइल में user entries संरक्षित रहती हैं; केवल पिछली agentmemory entries replace होती हैं।
478
-
479
- <details>
480
- <summary><b>OpenClaw (यह prompt paste करें)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- पूर्ण गाइड: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (यह prompt paste करें)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- पूर्ण गाइड: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### अन्य एजेंट्स
526
-
527
- मेमोरी सर्वर शुरू करें: `npx @agentmemory/agentmemory`
528
-
529
- agentmemory entry `mcpServers` shape का उपयोग करने वाले हर host में **वही MCP server block** है (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **इस entry को host की config file में मौजूदा `mcpServers` object में merge करें** — file को replace न करें। अगर फाइल में पहले से अन्य servers हैं, तो `mcpServers` के अंदर एक और key के रूप में `agentmemory` को उनके बगल में जोड़ें। अगर `mcpServers` पूरी तरह से missing है, तो block को `{ "mcpServers": { ... } }` के अंदर paste करें। `${VAR}` placeholders MCP-server launch पर shell से `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` inherit करते हैं — unset variables empty strings pass करते हैं और shim `http://localhost:3111` पर fallback होता है। एक wired entry local और remote (k8s / reverse-proxied) दोनों deployments को कवर करती है।
543
-
544
- | एजेंट | Config फाइल | नोट्स |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` में merge करें। Website पर one-click deeplink भी उपलब्ध। |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers` में merge करें। Edit के बाद Claude Desktop restart करें। |
548
- | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | वही `mcpServers` block। |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | वही `mcpServers` block। |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges)। |
551
- | **OpenClaw** | OpenClaw MCP config | वही `mcpServers` block, या गहरे [memory plugin](../integrations/openclaw/) का उपयोग करें। |
552
- | **Codex CLI (केवल MCP)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, या manually `[mcp_servers.agentmemory]` जोड़ें। |
553
- | **Codex CLI (पूर्ण plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` फिर `codex plugin add agentmemory@agentmemory`। MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills register करता है। Codex Desktop पर, [openai/codex#16430](https://github.com/openai/codex/issues/16430) land होने तक `agentmemory connect codex --with-hooks` भी चलाएँ — plugin hooks वर्तमान में वहाँ silent हैं। |
554
- | **OpenCode (केवल MCP)** | `opencode.json` | अलग shape — top-level `mcp` key, command array के रूप में: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`। |
555
- | **OpenCode (पूर्ण plugin)** | `plugin/opencode/` | Session lifecycle, messages, tools, errors को कवर करने वाले 22 auto-capture hooks। दो slash commands (`/recall`, `/remember`)। `plugin/opencode/` को अपने OpenCode workspace में copy करें और plugin entry को `opencode.json` में जोड़ें। पूरी hook table + gap analysis के लिए [`plugin/opencode/README.md`](../plugin/opencode/README.md) देखें। |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) copy करें और pi restart करें। |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | गहरे [memory provider plugin](../integrations/hermes/) का उपयोग `memory.provider: agentmemory` के साथ करें। |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` standard `mcpServers` block लिखता है। Hook payload Claude Code के साथ field-compatible है, इसलिए मौजूदा 12-hook scripts modification के बिना काम करते हैं — उन्हें उसी `settings.json` के `hooks` section के माध्यम से जोड़ें। |
559
- | **Antigravity** (Gemini CLI को replace करता है) | `mcp_config.json` (Antigravity की User dir में) | `agentmemory connect antigravity` standard `mcpServers` block लिखता है। macOS: `~/Library/Application Support/Antigravity/User/`। Linux: `~/.config/Antigravity/User/`। 2026-06-18 Gemini CLI sunset के बाद उपयोग करें। |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` user-level config लिखता है। Workspace overrides आपके code के बगल में `.kiro/settings/mcp.json` में जाते हैं। |
561
- | **Goose** | Goose MCP settings UI | वही `mcpServers` block। |
562
- | **Aider** | n/a | REST API से सीधे बात करें: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`। |
563
- | **कोई भी एजेंट (32+)** | n/a | `npx skillkit install agentmemory` host को auto-detect करता है और merge करता है। |
564
-
565
- **Sandboxed MCP क्लाइंट्स** (Flatpak / Snap / प्रतिबंधात्मक containers) जो host के `localhost` तक नहीं पहुँच सकते: `env` block में `"AGENTMEMORY_FORCE_PROXY": "1"` भी set करें, और `AGENTMEMORY_URL` को एक ऐसे route पर point करें जिस तक sandbox वास्तव में पहुँच सकता है (जैसे आपका LAN IP)। Diagnostic walkthrough के लिए [#234](https://github.com/rohitg00/agentmemory/issues/234) देखें।
566
-
567
- ### Programmatic access (Python / Rust / Node)
568
-
569
- agentmemory अपने core operations को iii functions के रूप में register करता है (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`)। iii SDK वाली कोई भी भाषा उन्हें `ws://localhost:49134` पर सीधे call कर सकती है — प्रति भाषा अलग REST क्लाइंट नहीं।
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- कार्यशील उदाहरण: [`examples/python/`](../examples/python/) (quickstart + observation/recall flow)। iii runtime के बिना hosts के लिए REST `:3111` पर उपलब्ध रहता है।
590
-
591
- ### Source से
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- यह agentmemory को local `iii-engine` के साथ शुरू करता है अगर `iii` पहले से installed है, या Docker उपलब्ध होने पर Docker Compose पर fallback करता है। REST, streams, और व्यूअर default रूप से `127.0.0.1` से bind करते हैं।
599
-
600
- `iii-engine` मैनुअली इंस्टॉल करें। **agentmemory वर्तमान में `iii-engine` को `v0.11.2` पर pin करता है** — `v0.11.6` एक नया sandbox-everything-via-`iii worker add` model introduce करता है जिसके लिए agentmemory को अभी refactor नहीं किया गया है। Refactor land होने के बाद pin हटा दी जाती है। अगर आपने sandbox model पर मैनुअली migrate किया है तो `AGENTMEMORY_III_VERSION=<version>` से override करें।
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** `aarch64-apple-darwin` को `x86_64-apple-darwin` के साथ बदलें
604
- - **Linux x64:** `x86_64-unknown-linux-gnu` के साथ बदलें
605
- - **Linux arm64:** `aarch64-unknown-linux-gnu` के साथ बदलें
606
- - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) से `iii-x86_64-pc-windows-msvc.zip` download करें, `iii.exe` extract करें, PATH में जोड़ें
607
-
608
- या Docker का उपयोग करें (bundled `docker-compose.yml` `iiidev/iii:0.11.2` खींचता है)। पूर्ण docs: [iii.dev/docs](https://iii.dev/docs)।
609
-
610
- ### Windows
611
-
612
- agentmemory Windows 10/11 पर चलता है, लेकिन केवल Node.js package पर्याप्त नहीं है — आपको एक background process के रूप में `iii-engine` runtime (एक अलग native binary) भी चाहिए। आधिकारिक upstream installer एक `sh` script है और आज कोई PowerShell installer या scoop/winget package नहीं है, इसलिए Windows users के पास दो रास्ते हैं:
613
-
614
- **विकल्प A — Prebuilt Windows binary (अनुशंसित):**
615
-
616
- ```powershell
617
- # 1. अपने browser में https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 खोलें
618
- # (हम v0.11.2 पर pin करते हैं जब तक agentmemory नए sandbox
619
- # model के लिए refactor नहीं हो जाता जो engine v0.11.6+ की आवश्यकता है)
620
- # 2. iii-x86_64-pc-windows-msvc.zip download करें
621
- # (या ARM machine पर हैं तो iii-aarch64-pc-windows-msvc.zip)
622
- # 3. PATH पर कहीं iii.exe extract करें, या यहाँ रखें:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory उस location को automatically check करता है)
625
- # 4. Verify करें:
626
- iii --version
627
- # Print होना चाहिए: 0.11.2
628
-
629
- # 5. फिर agentmemory को सामान्य ���ी तरह चलाएँ:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **विकल्प B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Windows के लिए Docker Desktop install करें
637
- # 2. Docker Desktop शुरू करें और सुनिश्चित करें कि engine चल रहा है
638
- # 3. agentmemory चलाएँ — यह bundled compose file को auto-start करेगा:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **विकल्प C — केवल standalone MCP (कोई engine नहीं):** अगर आपको केवल अपने agent के लिए MCP tools चाहिए और REST API, व्यूअर, या cron jobs की ज़रूरत नहीं है, तो engine को पूरी तरह से skip करें:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # या shim package के माध्यम से:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Windows के लिए diagnostics:** अगर `npx @agentmemory/agentmemory` fail करता है, तो वास्तविक engine stderr देखने के लिए `--verbose` के साथ फिर से चलाएँ। सामान्य failure modes:
651
-
652
- | लक्षण | समाधान |
653
- |---|---|
654
- | `iii-engine process started` फिर `did not become ready within 15s` | Engine startup पर crashed — `--verbose` के साथ फिर से चलाएँ, stderr check करें |
655
- | `Could not start iii-engine` | न तो `iii.exe` न ही Docker installed है। ऊपर विकल्प A या B देखें |
656
- | Port conflict | `netstat -ano \| findstr :3111` से देखें कि क्या bind है, फिर उसे kill करें या `--port <N>` का उपयोग करें |
657
- | Docker installed होने पर भी Docker fallback skip हो रहा है | सुनिश्चित करें कि Docker Desktop वास्तव में चल रहा है (system tray icon) |
658
-
659
- > नोट: कोई `cargo install iii-engine` नहीं है — `iii` crates.io पर publish नहीं है। केवल समर्थित install methods ऊपर prebuilt binary, upstream `sh` install script (केवल macOS/Linux), और Docker image हैं।
660
-
661
- ---
662
-
663
- <h2 id="deploy">Deploy</h2>
664
-
665
- Managed hosts के लिए one-click templates। प्रत्येक एक self-contained
666
- Dockerfile ship करता है जो npm से `@agentmemory/agentmemory` खींचता है
667
- और आधिकारिक `iiidev/iii` Docker Hub image से iii engine binary को
668
- copy करता है — pre-built agentmemory image की आवश्यकता नहीं। Persistent
669
- storage `/data` पर mount होती है; first-boot entrypoint npm-bundled
670
- iii config (जो `127.0.0.1` से bind करती है) को एक deploy-tuned config
671
- से overwrite करता है जो `0.0.0.0` से bind करती है और absolute `/data`
672
- paths का उपयोग करती है, HMAC secret generate करती है, फिर agentmemory
673
- CLI को exec करने से पहले `gosu` के माध्यम से privileges को `root` से
674
- `node` पर drop करती है।
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- Render का one-click deploy button repository root पर `render.yaml` की आवश्यकता रखता है,
682
- जिसे हम जानबूझकर साफ़ रखते हैं। In-repo blueprint पर manually point करने के लिए
683
- [`deploy/render/`](../deploy/render/README.md) में documented Render Blueprint flow का उपयोग करें।
684
-
685
- पूर्ण setup विवरण (HMAC capture, viewer SSH tunnel,
686
- rotation, backup, cost floors) [`deploy/`](../deploy/README.md) में रहते हैं:
687
-
688
- - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"` के साथ
689
- single machine; सबसे सस्ता idle।
690
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby plan flat fee,
691
- dashboard में volume।
692
- - [`deploy/render`](../deploy/render/README.md) — Blueprint flow,
693
- paid plans पर automatic disk snapshots।
694
- - [`deploy/coolify`](../deploy/coolify/README.md) — अपने स्वयं के VPS पर
695
- [Coolify](https://coolify.io/self-hosted) के माध��यम से self-hosted; वही Docker
696
- Compose stack, आप host और data के मालिक हैं।
697
-
698
- केवल port `3111` publish किया जाता है। `3113` पर viewer container के अंदर
699
- loopback से bound रहता है — हर template का README उस तक पहुँचने के लिए
700
- SSH-tunnel pattern को document करता है।
701
-
702
- ---
703
-
704
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
705
-
706
- हर coding agent सेशन समाप्त होने पर सब कुछ भूल जाता है। आप हर सेशन के पहले 5 मिनट अपने stack को फिर से समझाने में बर्बाद करते हैं। agentmemory पृष्ठभूमि में चलता है और इसे पूरी तरह से समाप्त कर देता है।
707
-
708
- ```text
709
- Session 1: "Add auth to the API"
710
- Agent writes code, runs tests, fixes bugs
711
- agentmemory silently captures every tool use
712
- Session ends -> observations compressed into structured memory
713
-
714
- Session 2: "Now add rate limiting"
715
- Agent already knows:
716
- - Auth uses JWT middleware in src/middleware/auth.ts
717
- - Tests in test/auth.test.ts cover token validation
718
- - You chose jose over jsonwebtoken for Edge compatibility
719
- Zero re-explaining. Starts working immediately.
720
- ```
721
-
722
- ### बिल्ट-इन agent memory से तुलना
723
-
724
- हर AI coding agent बिल्ट-इन memory के साथ ship होता है — Claude Code में `MEMORY.md` है, Cursor में notepads हैं, Cline में memory bank है। ये sticky notes की तरह काम करते हैं। agentmemory उन sticky notes के पीछे का searchable database है।
725
-
726
- | | बिल्ट-इन (CLAUDE.md) | agentmemory |
727
- |---|---|---|
728
- | Scale | 200-line cap | असीमित |
729
- | खोज | सब कुछ context में load करता है | BM25 + vector + graph (केवल top-K) |
730
- | Token cost | 240 observations पर 22K+ | ~1,900 tokens (92% कम) |
731
- | Cross-agent | प्रति-agent फाइलें | MCP + REST (कोई भी agent) |
732
- | Coordination | कोई नहीं | Leases, signals, actions, routines |
733
- | Observability | फाइलें मैनुअल पढ़ें | :3113 पर real-time viewer |
734
-
735
- ---
736
-
737
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
738
-
739
- ### Memory Pipeline
740
-
741
- ```text
742
- PostToolUse hook fires
743
- -> SHA-256 dedup (5min window)
744
- -> Privacy filter (strip secrets, API keys)
745
- -> Store raw observation
746
- -> LLM compress -> structured facts + concepts + narrative
747
- -> Vector embedding (6 providers + local)
748
- -> Index in BM25 + vector
749
-
750
- Stop / SessionEnd hook fires
751
- -> Summarize session
752
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
753
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
754
-
755
- SessionStart hook fires
756
- -> Load project profile (top concepts, files, patterns)
757
- -> Hybrid search (BM25 + vector + graph)
758
- -> Token budget (default: 2000 tokens)
759
- -> Inject into conversation
760
- ```
761
-
762
- ### 4-Tier Memory Consolidation
763
-
764
- मानव मस्तिष्क memory को कैसे process करता है उससे प्रेरित — sleep consolidation से बहुत अलग नहीं।
765
-
766
- | Tier | क्या | Analogy |
767
- |------|------|---------|
768
- | **Working** | Tool use से raw observations | Short-term memory |
769
- | **Episodic** | संकुचित session summaries | "क्या हुआ" |
770
- | **Semantic** | निकाले गए facts और patterns | "मैं क्या जानता हूँ" |
771
- | **Procedural** | Workflows और decision patterns | "कैसे करें" |
772
-
773
- Memories समय के साथ decay होती हैं (Ebbinghaus curve)। बार-बार access की जाने वाली memories मज़बूत होती हैं। पुरानी memories auto-evict होती हैं। Contradictions detect और resolve होती हैं।
774
-
775
- ### क्या Capture होता है
776
-
777
- | Hook | Captures |
778
- |------|----------|
779
- | `SessionStart` | Project path, session ID |
780
- | `UserPromptSubmit` | User prompts (privacy-filtered) |
781
- | `PreToolUse` | File access patterns + enriched context |
782
- | `PostToolUse` | Tool name, input, output |
783
- | `PostToolUseFailure` | Error context |
784
- | `PreCompact` | Compaction से पहले memory को re-inject करता है |
785
- | `SubagentStart/Stop` | Sub-agent lifecycle |
786
- | `Stop` | End-of-session summary |
787
- | `SessionEnd` | Session complete marker |
788
-
789
- ### मुख्य क्षमताएँ
790
-
791
- | क्षमता | विवरण |
792
- |---|---|
793
- | **Automatic capture** | हर tool use hooks के माध्यम से record होता है — शून्य manual effort |
794
- | **Semantic search** | RRF fusion के साथ BM25 + vector + knowledge graph |
795
- | **Memory evolution** | Versioning, supersession, relationship graphs |
796
- | **Auto-forgetting** | TTL expiry, contradiction detection, importance eviction |
797
- | **Privacy first** | API keys, secrets, `<private>` tags storage से पहले strip होते हैं |
798
- | **Self-healing** | Circuit breaker, provider fallback chain, health monitoring |
799
- | **Claude bridge** | MEMORY.md के साथ bi-directional sync |
800
- | **Knowledge graph** | Entity extraction + BFS traversal |
801
- | **Team memory** | Team members के बीच namespaced shared + private |
802
- | **Citation provenance** | किसी भी memory को source observations तक trace करें |
803
- | **Git snapshots** | Memory state को version, rollback, और diff करें |
804
-
805
- ---
806
-
807
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
808
-
809
- तीन signals को combine करने वाला triple-stream retrieval:
810
-
811
- | Stream | यह क्या करता है | कब |
812
- |---|---|---|
813
- | **BM25** | Synonym expansion के साथ stemmed keyword matching | हमेशा on |
814
- | **Vector** | Dense embeddings पर cosine similarity | Embedding provider configured |
815
- | **Graph** | Entity matching के माध्यम से knowledge graph traversal | Query में entities detected |
816
-
817
- Reciprocal Rank Fusion (RRF, k=60) के साथ fuse होता है और session-diversified होता है (प्रति session max 3 results)।
818
-
819
- BM25 box से बाहर ही Greek, Cyrillic, Hebrew, Arabic, और accented Latin को tokenize करता है। Chinese / Japanese / Korean memories के लिए, CJK runs को word-level tokens में split करने के लिए optional segmenters install करें (`npm install @node-rs/jieba tiny-segmenter`); उनके बिना, agentmemory soft-fall back होकर whole-run tokenization पर जाता है और stderr पर एक-बार hint print करता है।
820
-
821
- ### Embedding providers
822
-
823
- agentmemory आपके provider को auto-detect करता है। सर्वोत्तम परिणामों के लिए, local embeddings install करें (free):
824
-
825
- ```bash
826
- npm install @xenova/transformers
827
- ```
828
-
829
- | Provider | Model | Cost | नोट्स |
830
- |---|---|---|---|
831
- | **Local (अनुशंसित)** | `all-MiniLM-L6-v2` | Free | Offline, BM25-only पर +8pp recall |
832
- | Gemini | `gemini-embedding-001` | Free tier | 100+ भाषाएँ, 768/1536/3072 dims (MRL), 2048-token input। `text-embedding-004` को replace करता है ([deprecated, 14 जनवरी 2026 को shutdown](https://ai.google.dev/gemini-api/docs/deprecations)) |
833
- | OpenAI | `text-embedding-3-small` | $0.02/1M | उच्चतम quality |
834
- | Voyage AI | `voyage-code-3` | Paid | Code के लिए optimized |
835
- | Cohere | `embed-english-v3.0` | Free trial | General purpose |
836
- | OpenRouter | कोई भी model | भिन्न | Multi-model proxy |
837
-
838
- ---
839
-
840
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
841
-
842
- 53 tools, 6 resources, 3 prompts, और 4 skills — किसी भी agent के लिए सबसे व्यापक MCP memory toolkit।
843
-
844
- > **MCP shim बनाम full server:** published `@agentmemory/mcp` package एक thin shim है। यह full 51-tool surface को **केवल तभी expose करता है जब यह `AGENTMEMORY_URL` के माध्यम से चल रहे agentmemory server तक पहुँच सके** (proxy mode)। कोई पहुँच योग्य server न होने पर, shim 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`) पर fallback करता है। `AGENTMEMORY_TOOLS=core|all` env var एक *server-side* flag है — shim के `env` block में set करने का कोई असर नहीं। अगर आप Cursor / OpenCode / Gemini CLI में केवल 7 tools देखते हैं, तो `npx @agentmemory/agentmemory` (या Docker stack) शुरू करें और `AGENTMEMORY_URL=http://localhost:3111` set करें।
845
-
846
- ### 51 Tools
847
-
848
- <details>
849
- <summary>Core tools (हमेशा उपलब्ध)</summary>
850
-
851
- | Tool | विवरण |
852
- |------|-------------|
853
- | `memory_recall` | पिछले observations खोजें |
854
- | `memory_compress_file` | Structure preserve करते हुए markdown files compress करें |
855
- | `memory_save` | एक insight, decision, या pattern save करें |
856
- | `memory_patterns` | Recurring patterns detect करें |
857
- | `memory_smart_search` | Hybrid semantic + keyword search |
858
- | `memory_file_history` | विशिष्ट files के बारे में पिछले observations |
859
- | `memory_sessions` | Recent sessions list करें |
860
- | `memory_timeline` | Chronological observations |
861
- | `memory_profile` | Project profile (concepts, files, patterns) |
862
- | `memory_export` | सभी memory data export करें |
863
- | `memory_relations` | Relationship graph query करें |
864
-
865
- </details>
866
-
867
- <details>
868
- <summary>Extended tools (कुल 51 — AGENTMEMORY_TOOLS=all set करें)</summary>
869
-
870
- | Tool | विवरण |
871
- |------|-------------|
872
- | `memory_patterns` | Recurring patterns detect करें |
873
- | `memory_timeline` | Chronological observations |
874
- | `memory_relations` | Relationship graph query करें |
875
- | `memory_graph_query` | Knowledge graph traversal |
876
- | `memory_consolidate` | 4-tier consolidation चलाएँ |
877
- | `memory_claude_bridge_sync` | MEMORY.md के साथ sync करें |
878
- | `memory_team_share` | Team members के साथ share करें |
879
- | `memory_team_feed` | हाल ही में shared items |
880
- | `memory_audit` | Operations का audit trail |
881
- | `memory_governance_delete` | Audit trail के साथ delete करें |
882
- | `memory_snapshot_create` | Git-versioned snapshot |
883
- | `memory_action_create` | Dependencies के साथ work items create करें |
884
- | `memory_action_update` | Action status update करें |
885
- | `memory_frontier` | Priority द्वारा ranked unblocked actions |
886
- | `memory_next` | Single most important next action |
887
- | `memory_lease` | Exclusive action leases (multi-agent) |
888
- | `memory_routine_run` | Workflow routines instantiate करें |
889
- | `memory_signal_send` | Inter-agent messaging |
890
- | `memory_signal_read` | Receipts के साथ messages पढ़ें |
891
- | `memory_checkpoint` | External condition gates |
892
- | `memory_mesh_sync` | Instances के बीच P2P sync |
893
- | `memory_sentinel_create` | Event-driven watchers |
894
- | `memory_sentinel_trigger` | Sentinels externally fire करें |
895
- | `memory_sketch_create` | Ephemeral action graphs |
896
- | `memory_sketch_promote` | Permanent पर promote करें |
897
- | `memory_crystallize` | Action chains compact करें |
898
- | `memory_diagnose` | Health checks |
899
- | `memory_heal` | Stuck state को auto-fix करें |
900
- | `memory_facet_tag` | Dimension:value tags |
901
- | `memory_facet_query` | Facet tags द्वारा query करें |
902
- | `memory_verify` | Provenance trace करें |
903
-
904
- </details>
905
-
906
- ### 6 Resources · 3 Prompts · 4 Skills
907
-
908
- | प्रकार | नाम | विवरण |
909
- |------|------|-------------|
910
- | Resource | `agentmemory://status` | Health, session count, memory count |
911
- | Resource | `agentmemory://project/{name}/profile` | Per-project intelligence |
912
- | Resource | `agentmemory://memories/latest` | नवीनतम 10 active memories |
913
- | Resource | `agentmemory://graph/stats` | Knowledge graph statistics |
914
- | Prompt | `recall_context` | Search + context messages return करें |
915
- | Prompt | `session_handoff` | Agents के बीच handoff data |
916
- | Prompt | `detect_patterns` | Recurring patterns analyze करें |
917
- | Skill | `/recall` | Memory खोजें |
918
- | Skill | `/remember` | Long-term memory में save करें |
919
- | Skill | `/session-history` | हाल के session summaries |
920
- | Skill | `/forget` | Observations/sessions delete करें |
921
-
922
- ### Standalone MCP
923
-
924
- Full server के बिना चलाएँ — किसी भी MCP client के लिए। इनमें से कोई भी काम करता है:
925
-
926
- ```bash
927
- npx -y @agentmemory/agentmemory mcp # canonical (हमेशा उपलब्ध)
928
- npx -y @agentmemory/mcp # shim package alias
929
- ```
930
-
931
- या अपने agent की MCP config में जोड़ें:
932
-
933
- अधिकांश agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
934
- ```json
935
- {
936
- "mcpServers": {
937
- "agentmemory": {
938
- "command": "npx",
939
- "args": ["-y", "@agentmemory/mcp"],
940
- "env": {
941
- "AGENTMEMORY_URL": "http://localhost:3111"
942
- }
943
- }
944
- }
945
- }
946
- ```
947
-
948
- `agentmemory` entry को file को replace करने के बजाय अपने host के मौजूदा `mcpServers` object में merge करें। होस्ट के `localhost` तक नहीं पहुँच सकने वाले sandboxed clients के लिए, env block में `"AGENTMEMORY_FORCE_PROXY": "1"` जोड़ें और `AGENTMEMORY_URL` को एक ऐसे route पर set करें जिस तक sandbox पहुँच सकता है।
949
-
950
- OpenCode (`opencode.json`):
951
- ```json
952
- {
953
- "mcp": {
954
- "agentmemory": {
955
- "type": "local",
956
- "command": ["npx", "-y", "@agentmemory/mcp"],
957
- "enabled": true
958
- }
959
- },
960
- "plugin": ["./plugins/agentmemory-capture.ts"]
961
- }
962
- ```
963
-
964
- Plugin file को repo से copy करें:
965
- ```bash
966
- mkdir -p ~/.config/opencode/plugins
967
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
968
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
969
- ```
970
-
971
- ---
972
-
973
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
974
-
975
- Port `3113` पर auto-start होता है। Live observation stream, session explorer, memory browser, knowledge graph visualization, और health dashboard।
976
-
977
- ```bash
978
- open http://localhost:3113
979
- ```
980
-
981
- व्यूअर server default रूप से `127.0.0.1` से bind होता है। REST-served `/agentmemory/viewer` endpoint सामान्य `AGENTMEMORY_SECRET` bearer-token नियमों का पालन करता है। CSP headers per-response script nonce का उपयोग करते हैं और inline handler attributes को disable करते हैं (`script-src-attr 'none'`)।
982
-
983
- ---
984
-
985
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
986
-
987
- `:3113` पर viewer दिखाता है कि आपके agent ने क्या **याद रखा**। [iii console](https://iii.dev/docs/console) दिखाता है कि आपके agent ने क्या **किया** — हर memory op एक OpenTelemetry trace के रूप में, हर KV entry editable, हर function invocable, हर stream tappable। एक ही memory पर दो windows: एक product-shaped, एक engine-shaped।
988
-
989
- `memory_smart_search` को fire होते देखें और BM25 scan → embedding lookup → RRF fusion → reranker को waterfall के रूप में देखें। KV browser में stuck consolidation timer को edit करें। `PostToolUse` hook को tweaked payload के साथ replay करें। WebSocket stream को pin करें और observations को live land होते देखें।
990
-
991
- agentmemory इसे free में ship करता है क्योंकि हर function, trigger, state scope, और stream एक iii primitive है — कुछ भी custom नहीं, instrument करने के लिए कुछ नहीं।
992
-
993
- <p align="center">
994
- <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
995
- <br/>
996
- <em>Workers page: हर connected worker — agentmemory स्वयं सहित — PID, function count, runtime, और last-seen के साथ।</em>
997
- </p>
998
-
999
- **पहले से installed।** Console `iii` के साथ ship होता है — कोई अलग installer नहीं।
1000
-
1001
- **agentmemory के साथ launch करें:**
1002
-
1003
- ```bash
1004
- # agentmemory viewer port 3113 रखता है, तो console को 3114 पर चलाएँ।
1005
- # Engine REST (3111), WebSocket (3112), और bridge (49134) defaults agentmemory से match करते हैं।
1006
- iii console --port 3114
1007
- ```
1008
-
1009
- फिर `http://localhost:3114` खोलें। Experimental architecture-graph page के लिए `--enable-flow` जोड़ें।
1010
-
1011
- केवल तभी engine endpoints override करें जब आपने उन्हें move किया हो:
1012
-
1013
- ```bash
1014
- iii console --port 3114 \
1015
- --engine-port 3111 \
1016
- --ws-port 3112 \
1017
- --bridge-port 49134
1018
- ```
1019
-
1020
- **Console से आप क्या कर सकते हैं:**
1021
-
1022
- | Page | इसके लिए उपयोग करें |
1023
- |------|-----------|
1024
- | **Workers** | हर connected worker और उसके live metrics देखें — agentmemory worker सहित। |
1025
- | **Functions** | agentmemory के किसी भी function को सीधे JSON payload के साथ invoke करें — client जोड़े बिना `memory.recall`, `memory.consolidate`, `graph.query` test करने के लिए उपयोगी। |
1026
- | **Triggers** | HTTP, cron, event, और state triggers replay करें — consolidation cron को manually fire करें, HTTP route retry करें, एक state change emit करें। |
1027
- | **States** | Full CRUD के साथ KV browser — sessions, memory slots, lifecycle timers, embeddings index — values को in place edit करें। |
1028
- | **Streams** | Memory writes, hook events, और observation updates के लिए live WebSocket monitor क्योंकि वे iii streams से बहते हैं। |
1029
- | **Queues** | Durable queue topics + dead-letter management। Failed embedding / compression jobs को replay या drop करें। |
1030
- | **Traces** | OpenTelemetry waterfall / flame / service-breakdown views। `trace_id` से filter करें ताकि देख सकें कि एक `memory.search` ने वास्तव में कौन से functions, DB calls, और embedding requests produce किए। |
1031
- | **Logs** | Trace/span IDs से correlated और filtered structured OTEL logs। |
1032
- | **Config** | Runtime configuration — देखें कि आपका engine किन workers, providers, और ports के साथ चल रहा है। |
1033
- | **Flow** | (Optional, `--enable-flow`) हर worker, trigger, और stream का interactive architecture graph। |
1034
-
1035
- <p align="center">
1036
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1037
- <br/>
1038
- <em>Traces: हर memory operation के लिए waterfall / flame / service breakdown।</em>
1039
- </p>
1040
-
1041
- **Traces पहले से on हैं:**
1042
-
1043
- `iii-config.yaml` `iii-observability` worker enabled (`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs) के साथ ship होता है। कोई extra config की ज़रूरत नहीं — जैसे ही agentmemory शुरू होता है, हर memory operation एक trace span और एक structured log emit करता है जिसे console पढ़ सकता है।
1044
-
1045
- अगर आप इसके बजाय Jaeger/Honeycomb/Grafana Tempo पर export करना चाहते हैं, तो `exporter: memory` को `exporter: otlp` में बदलें और iii के observability docs के अनुसार collector endpoint set करें।
1046
-
1047
- > **ध्यान दें:** console पर कोई auth enforce नहीं है — इसे `127.0.0.1` (default) से bound रखें और इसे कभी publicly expose न करें।
1048
-
1049
- ---
1050
-
1051
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1052
-
1053
- agentmemory **पहले से एक चल रहा [iii](https://iii.dev) instance है**। Functions, triggers, KV state, streams, OTEL traces — यह सब iii primitives हैं। आपने Postgres, Redis, Express, pm2, या Prometheus install नहीं किया, क्योंकि iii उन्हें replace करता है।
1054
-
1055
- इसका मतलब है कि एक और कमांड agentmemory को एक पूरी नई capability के साथ extend करती है।
1056
-
1057
- ### एक command के साथ agentmemory को extend करें
1058
-
1059
- ```bash
1060
- iii worker add iii-pubsub # memory writes को हर connected instance पर fan out करें
1061
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1062
- iii worker add iii-queue # embedding + compression jobs के लिए durable retries
1063
- iii worker add iii-observability # हर memory op पर OTEL traces (default on)
1064
- iii worker add iii-sandbox # recalled code को isolated microVM के अंदर चलाएँ
1065
- iii worker add iii-database # एक SQL-backed state adapter में swap करें
1066
- iii worker add mcp # agentmemory MCP के साथ-साथ generic MCP host
1067
- ```
1068
-
1069
- प्रत्येक `iii worker add` उसी engine में नए functions और triggers register करता है जिस पर agentmemory पहले से चल रहा है। Viewer और console उन्हें तुरंत pick करते हैं — कोई reload नहीं, कोई नया integration नहीं, कोई नया container नहीं।
1070
-
1071
- | `iii worker add` | agentmemory के ऊपर आपको क्या मिलता है |
1072
- |---|---|
1073
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-instance memory: हर `remember` fan out होती है, हर `search` union पढ़ता है |
1074
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Scheduled lifecycle — रात की consolidation, साप्ताहिक snapshots, fixed clock पर decay |
1075
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable retries: failed embedding + compression jobs restart से बचते हैं, कोई lost observations नहीं |
1076
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | हर function पर OTEL traces, metrics, logs — दिन एक से `iii-config.yaml` में wired |
1077
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` से निकला code throwaway VM के अंदर चलता है, आपके shell में नहीं |
1078
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | जब आप in-memory KV defaults से बाहर निकलते हैं तो SQL-backed state adapter |
1079
- | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory के साथ-साथ extra MCP servers खड़े करें, वही engine share करें |
1080
-
1081
- Full registry: [workers.iii.dev](https://workers.iii.dev)। वहाँ हर worker उन्हीं primitives के माध्यम से compose करता है जिनका agentmemory उपयोग करता है — और आपके पास पहले से जो agentmemory है, वह उनमें से एक है।
1082
-
1083
- ### iii क्या replace करता है
1084
-
1085
- | Traditional stack | agentmemory उपयोग करता है |
1086
- |---|---|
1087
- | Express.js / Fastify | iii HTTP Triggers |
1088
- | SQLite / Postgres + pgvector | iii KV State + in-memory vector index |
1089
- | SSE / Socket.io | iii Streams (WebSocket) |
1090
- | pm2 / systemd | iii engine worker supervision |
1091
- | Prometheus / Grafana | iii OTEL + health monitor |
1092
- | Custom plugin systems | `iii worker add <name>` |
1093
-
1094
- **118 source files · ~21,800 LOC · 950+ tests · 123 functions · 34 KV scopes** — सब कुछ तीन primitives पर। कोई `agentmemory plugin install` नहीं। Plugin system iii स्वयं है।
1095
-
1096
- ---
1097
-
1098
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1099
-
1100
- ### LLM Providers
1101
-
1102
- agentmemory आपके environment से auto-detect करता है। Default रूप से, जब तक आप एक provider configure नहीं करते या Claude subscription fallback में explicitly opt in नहीं करते, कोई LLM calls नहीं की जातीं।
1103
-
1104
- | Provider | Config | नोट्स |
1105
- |----------|--------|-------|
1106
- | **No-op (default)** | कोई config की ज़रूरत नहीं | LLM-backed compress/summarize DISABLED है। Synthetic BM25 compression + recall अभी भी काम करते हैं। अगर आप पहले Claude-subscription fallback पर निर्भर थे तो नीचे `AGENTMEMORY_ALLOW_AGENT_SDK` देखें। |
1107
- | Anthropic API | `ANTHROPIC_API_KEY` | Per-token billing |
1108
- | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
1109
- | Gemini | `GEMINI_API_KEY` | Embeddings भी enable करता है |
1110
- | OpenRouter | `OPENROUTER_API_KEY` | कोई भी model |
1111
- | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | केवल opt-in। `@anthropic-ai/claude-agent-sdk` sessions spawn करता है — पहले unbounded Stop-hook recursion का कारण था (#149 follow-up) तो यह अब default नहीं है। |
1112
-
1113
- ### Cost-aware model selection
1114
-
1115
- Background compression हर observation पर चलता है, इसलिए model choice monthly spend को meaningfully बदलता है। Captured workload data: 635 requests / 888K tokens / 35 hours of active use, 2026-05-23 pricing पर तीन OpenRouter models पर चलाया गया।
1116
-
1117
- | Tier | Model | Input / 1M | Output / 1M | Captured 35h के लिए cost | नोट्स |
1118
- |------|-------|------------|-------------|---------------------------|-------|
1119
- | अनुशंसित | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Sonnet से ~10× कम cost पर solid compression + summarization quality। |
1120
- | अनुशंसित | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | पुराना लेकिन केवल-compression workloads के लिए अभी भी ठीक। |
1121
- | अनुशंसित | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | अगर आपके sessions भारी रूप से code-shaped हैं तो strong code reasoning। |
1122
- | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality लेकिन always-on background work के लिए महंगा। |
1123
- | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet के समान tier। |
1124
- | बचें | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; compression के लिए massive overspend। |
1125
-
1126
- जब `OPENROUTER_MODEL` premium-tier pattern से match करता है तो agentmemory एक runtime warning print करता है। जब आप informed choice कर लें तो silence करने के लिए `AGENTMEMORY_SUPPRESS_COST_WARNING=1` set करें।
1127
-
1128
- Memory work के लिए quality बनाम cost tradeoff: compression एक summarization task है जिसमें अपेक्षाकृत loose quality bars हैं (agent summary को re-read करता है, user नहीं)। DeepSeek-V4-Pro / Qwen3-Coder इस task पर Sonnet से rounding error के भीतर land होते हैं जबकि ~10× कम cost में। Premium-tier models को उन queries के लिए save करें जिन्हें आप सीधे पढ़ते हैं।
1129
-
1130
- Sources: [Sonnet 4.6 के लिए OpenRouter pricing](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing नोट्स](https://api-docs.deepseek.com/quick_start/pricing/)।
1131
-
1132
- ### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1133
-
1134
- Multi-agent setups में जहाँ कई roles एक agentmemory server share करते हैं (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` हर write को उस role से tag करता है जिसने इसे किया। `AGENTMEMORY_AGENT_SCOPE` यह control करता है कि recall उस tag के द्वारा filter करता है या नहीं।
1135
-
1136
- ```env
1137
- TEAM_ID=company
1138
- USER_ID=engineering-team
1139
- AGENT_ID=architect
1140
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1141
- ```
1142
-
1143
- दो modes:
1144
-
1145
- | Mode | Writes को tag करें | Recall filter करें | कब उपयोग करें |
1146
- |------|------------|---------------|-------------|
1147
- | `shared` (default) | हाँ | नहीं | Audit trail के साथ cross-agent context। Architect देख सकता है कि developer ने क्या note किया, लेकिन हर row record करती है कि किसने कहा। |
1148
- | `isolated` | हाँ | हाँ | सख्त separation। Architect कभी developer के observations / memories / sessions नहीं देखता। |
1149
-
1150
- जब `AGENT_ID` set होता है तो क्या tagged होता है: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`। Role `api::session::start` → `mem::observe` → `mem::compress` → KV से flow करता है।
1151
-
1152
- Isolated mode में क्या filter होता है: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`। प्रत्येक endpoint per-request override के लिए `?agentId=<role>` और env scope से पूरी तरह से opt out करने के लिए `?agentId=*` accept करता है। `/memories` AGENT_ID से पहले के memories को surface करने के लिए `?includeOrphans=true` भी accept करता है जिनकी `agentId` undefined है।
1153
-
1154
- SDK / REST layer पर per-call override: हर mutating endpoint (`/session/start`, `/remember`) request body में एक `agentId` field accept करता है जो env से जीतता है। एक server process के माध्यम से कई roles को route करने वाले runtimes के लिए उपयोगी।
1155
-
1156
- जब `AGENT_ID` unset होता है, तो memory unscoped रहती है (legacy behavior, कोई tags नहीं, कोई filters नहीं)।
1157
-
1158
- ### Ports
1159
-
1160
- agentmemory + iii-engine default रूप से चार ports पर bind होते हैं। अगर एक restart `port in use` के साथ fail होता है, तो यह table बताती है कि किस process को देखना है।
1161
-
1162
- | Port | Process | उद्देश्य | Env override |
1163
- |------|---------|---------|--------------|
1164
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1165
- | `3112` | iii-engine | Internal streams worker (agentmemory + viewer द्वारा consumed) | `III_STREAMS_PORT` |
1166
- | `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1167
- | `49134` | iii-engine | WebSocket — workers यहाँ register होते हैं, OTel telemetry यहाँ से flow होती है | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
1168
-
1169
- Crashed run के बाद ports bound रहने पर stale-process cleanup:
1170
-
1171
- ```bash
1172
- # macOS / Linux — हर port पर जो भी है उसे ढूँढ़ें और kill करें
1173
- lsof -i :3111,3112,3113,49134
1174
- pkill -f agentmemory || true
1175
- pkill -f 'iii ' || true
1176
-
1177
- # Windows
1178
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1179
- taskkill /F /PID <pid>
1180
- ```
1181
-
1182
- `agentmemory stop` graceful shutdown पर worker और engine pidfile दोनों को साफ़ रूप से reap करता है (#640, #474)। ऊपर का manual cleanup केवल post-crash case के लिए है जहाँ कोई भी pidfile पीछे नहीं छोड़ी गई।
1183
-
1184
- ### Config File
1185
-
1186
- हर shell में variables export करने के बजाय agentmemory runtime configuration को `~/.agentmemory/.env` में रखें। अगर viewer `export ANTHROPIC_API_KEY=...` जैसा setup hint दिखाता है, तो इसे `export` prefix के बिना इस file में `ANTHROPIC_API_KEY=...` के रूप में copy करें, फिर agentmemory restart करें।
1187
-
1188
- Process environment variables अभी भी काम करते हैं और file में values पर precedence लेते हैं।
1189
-
1190
- Windows पर, वही file `%USERPROFILE%\.agentmemory\.env` पर रहती है:
1191
-
1192
- ```powershell
1193
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1194
- notepad $HOME\.agentmemory\.env
1195
- ```
1196
-
1197
- API key के बजाय Claude Code Pro/Max subscription के साथ test करने के लिए, explicitly opt in करें:
1198
-
1199
- ```env
1200
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1201
- AGENTMEMORY_AUTO_COMPRESS=true
1202
- ```
1203
-
1204
- अगर आप graph या consolidation features चाहते हैं तो उसी file में उन्हें on करें:
1205
-
1206
- ```env
1207
- GRAPH_EXTRACTION_ENABLED=true
1208
- CONSOLIDATION_ENABLED=true
1209
- ```
1210
-
1211
- ### Environment Variables
1212
-
1213
- `~/.agentmemory/.env` बनाएँ:
1214
-
1215
- ```env
1216
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1217
- # ANTHROPIC_API_KEY=sk-ant-...
1218
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1219
- # GEMINI_API_KEY=...
1220
- # OPENROUTER_API_KEY=...
1221
- # MINIMAX_API_KEY=...
1222
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1223
- # # OpenAI LLM provider (here) AND the OpenAI
1224
- # # embedding provider (further below). Set
1225
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1226
- # # to embeddings only.
1227
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1228
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1229
- # # Auto-detected from `.openai.azure.com` hostname; uses
1230
- # # api-key header + api-version query param.
1231
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1232
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1233
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1234
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1235
- # # for back-compat with v0.9.17. New configs should
1236
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1237
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1238
- # # Honored only by OpenAI's reasoning models (o1, o3,
1239
- # # gpt-*-reasoning) and providers that mirror that
1240
- # # schema (Ollama Cloud thinking models). Standard
1241
- # # chat models reject this field with 400. Set to
1242
- # # "none" for thinking models that return reasoning
1243
- # # but no content.
1244
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1245
- # # for LLM (useful if you only want OpenAI for embeddings)
1246
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1247
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1248
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1249
-
1250
- # Embedding provider (auto-detected, or override)
1251
- # EMBEDDING_PROVIDER=local
1252
- # VOYAGE_API_KEY=...
1253
- # OPENAI_API_KEY=sk-...
1254
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1255
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1256
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1257
-
1258
- # Outbound LLM / embedding timeout
1259
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1260
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1261
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1262
- # embedding). For the OpenAI LLM path, the
1263
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1264
- # takes precedence when set, for back-compat
1265
- # with v0.9.17.
1266
- # Increase for slow networks or large batch calls;
1267
- # decrease to fail-fast on rate-limit holds.
1268
-
1269
- # Search tuning
1270
- # BM25_WEIGHT=0.4
1271
- # VECTOR_WEIGHT=0.6
1272
- # TOKEN_BUDGET=2000
1273
-
1274
- # Auth
1275
- # AGENTMEMORY_SECRET=your-secret
1276
-
1277
- # Ports (defaults: 3111 API, 3113 viewer)
1278
- # III_REST_PORT=3111
1279
-
1280
- # Features
1281
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1282
- # every PostToolUse hook calls your
1283
- # LLM provider to compress the
1284
- # observation — expect significant
1285
- # token spend on active sessions.
1286
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1287
- # memory slots — persona,
1288
- # user_preferences, tool_guidelines,
1289
- # project_context, guidance,
1290
- # pending_items, session_patterns,
1291
- # self_notes. Size-limited; agent
1292
- # edits via memory_slot_* tools.
1293
- # Pinned slots addressable for
1294
- # SessionStart injection.
1295
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1296
- # Stop hook fires mem::slot-reflect:
1297
- # scans recent observations, auto-
1298
- # appends TODOs to pending_items,
1299
- # counts patterns in
1300
- # session_patterns, records touched
1301
- # files in project_context. Fire-
1302
- # and-forget; does not block.
1303
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1304
- # - SessionStart may inject ~1-2K
1305
- # chars of project context into
1306
- # the first turn of each session
1307
- # (this is what actually reaches
1308
- # the model — Claude Code treats
1309
- # SessionStart stdout as context)
1310
- # - PreToolUse fires /agentmemory/enrich
1311
- # on every file-touching tool call
1312
- # (resource cleanup, not a token
1313
- # fix — PreToolUse stdout is debug
1314
- # log only per Claude Code docs)
1315
- # Observations are still captured via
1316
- # PostToolUse regardless of this flag.
1317
- # GRAPH_EXTRACTION_ENABLED=false
1318
- # CONSOLIDATION_ENABLED=true
1319
- # LESSON_DECAY_ENABLED=true
1320
- # OBSIDIAN_AUTO_EXPORT=false
1321
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1322
- # CLAUDE_MEMORY_BRIDGE=false
1323
- # SNAPSHOT_ENABLED=false
1324
-
1325
- # Team
1326
- # TEAM_ID=
1327
- # USER_ID=
1328
- # TEAM_MODE=private
1329
-
1330
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1331
- # AGENTMEMORY_TOOLS=core
1332
- ```
1333
-
1334
- ---
1335
-
1336
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1337
-
1338
- Port `3111` पर 124 endpoints। REST API default रूप से `127.0.0.1` से bind होता है। `AGENTMEMORY_SECRET` set होने पर protected endpoints `Authorization: Bearer <secret>` की आवश्यकता रखते हैं, और mesh sync endpoints दोनों peers पर `AGENTMEMORY_SECRET` की आवश्यकता रखते हैं।
1339
-
1340
- <details>
1341
- <summary>मुख्य endpoints</summary>
1342
-
1343
- | Method | Path | विवरण |
1344
- |--------|------|-------------|
1345
- | `GET` | `/agentmemory/health` | Health check (हमेशा public) |
1346
- | `POST` | `/agentmemory/session/start` | Session शुरू करें + context प्राप्त करें |
1347
- | `POST` | `/agentmemory/session/end` | Session समाप्त करें |
1348
- | `POST` | `/agentmemory/observe` | Observation capture करें |
1349
- | `POST` | `/agentmemory/smart-search` | Hybrid search |
1350
- | `POST` | `/agentmemory/context` | Context generate करें |
1351
- | `POST` | `/agentmemory/remember` | Long-term memory में save करें |
1352
- | `POST` | `/agentmemory/forget` | Observations delete करें |
1353
- | `POST` | `/agentmemory/enrich` | File context + memories + bugs |
1354
- | `GET` | `/agentmemory/profile` | Project profile |
1355
- | `GET` | `/agentmemory/export` | सभी data export करें |
1356
- | `POST` | `/agentmemory/import` | JSON से import करें |
1357
- | `POST` | `/agentmemory/graph/query` | Knowledge graph query |
1358
- | `POST` | `/agentmemory/team/share` | Team के साथ share करें |
1359
- | `GET` | `/agentmemory/audit` | Audit trail |
1360
-
1361
- Full endpoint list: [`src/triggers/api.ts`](../src/triggers/api.ts)
1362
-
1363
- </details>
1364
-
1365
- ---
1366
-
1367
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1368
-
1369
- ```bash
1370
- npm run dev # Hot reload
1371
- npm run build # Production build
1372
- npm test # 950+ tests
1373
- npm run test:integration # API tests (running services की आवश्यकता है)
1374
- ```
1375
-
1376
- **आवश्यकताएँ:** Node.js >= 20, [iii-engine](https://iii.dev/docs) या Docker
1377
-
1378
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1379
-
1380
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.ja-JP.md DELETED
@@ -1,1380 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — AI コーディングエージェントのための永続メモリ" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- コーディングエージェントがすべてを記憶します。もう説明し直す必要はありません。
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode、そしてあらゆる MCP クライアントのための永続メモリ。
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- 日本語 |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>この gist は Karpathy の LLM Wiki パターンを信頼度スコア、ライフサイクル管理、ナレッジグラフ、ハイブリッド検索で拡張します。agentmemory はその実装です。</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">インストール</a> &bull;
73
- <a href="#quick-start">クイックスタート</a> &bull;
74
- <a href="#benchmarks">ベンチマーク</a> &bull;
75
- <a href="#vs-competitors">競合比較</a> &bull;
76
- <a href="#works-with-every-agent">エージェント</a> &bull;
77
- <a href="#how-it-works">仕組み</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">ビューワー</a> &bull;
80
- <a href="#iii-console">iii コンソール</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">設定</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## インストール
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # 一度のインストール — PATH 上に `agentmemory` が使えるようになる
92
- # macOS/Linux のシステム Node で EACCES が出る場合は次を試してください:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # :3111 でメモリサーバーを起動
95
- agentmemory demo # サンプルセッションを投入してリコールを実証
96
- agentmemory connect claude-code # エージェントを接続 (他にも codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- または `npx` で(インストール不要):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- 注意 — npx はバージョン単位でキャッシュします。素の `npx @agentmemory/agentmemory` が古いリリースを返す場合は、`npx -y @agentmemory/agentmemory@latest` で最新を強制するか、`rm -rf ~/.npm/_npx`(macOS/Linux。Windows では `%LOCALAPPDATA%\npm-cache\_npx` を削除)で一度キャッシュをクリアしてください。v0.9.16+ では初回 npx 実行時にインラインでグローバルインストールを促されるので、それ以降は素の `agentmemory` コマンドがどこでも動きます。
106
-
107
- すべてのオプションは下の[クイックスタート](#quick-start)を参照。各エージェント固有の接続は[すべてのエージェントで動作](#works-with-every-agent)を参照。
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
-
113
- agentmemory は hooks、MCP、REST API をサポートするあらゆるエージェントで動作します。すべてのエージェントが同じメモリサーバーを共有します。
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>ネイティブプラグイン + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>ネイティブプラグイン + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>ネイティブプラグイン + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>ネイティブプラグイン + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>ネイティブプラグイン + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>ネイティブ Memory trait バックエンド</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP サーバー</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP サーバー</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + プラグイン</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP サーバー</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP サーバー</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP サーバー</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP サーバー</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP サーバー</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP サーバー</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>MCP または HTTP を話す<strong>あらゆる</strong>エージェントで動作。サーバー 1 つで、すべてのエージェントがメモリを共有。</sub>
204
- </p>
205
-
206
- ---
207
-
208
- あなたは毎セッション、同じアーキテクチャを説明し直している。同じバグを何度も発見する。同じ好みを繰り返し教える。組み込みのメモリ(CLAUDE.md、.cursorrules)は 200 行で打ち止め、しかも古びていく。agentmemory がこれを解決します。バックグラウンドで静かにエージェントの動きを捕捉し、検索可能なメモリに圧縮し、次のセッションが始まるときに適切なコンテキストを注入します。コマンド 1 つ。エージェント間で動作します。
209
-
210
- **何が変わるか:** セッション 1 で JWT 認証をセットアップ。セッション 2 でレート制限を依頼する。エージェントは既に、あなたの認証が `src/middleware/auth.ts` の jose ミドルウェアを使い、テストがトークン検証をカバーし、Edge 互換性のために jsonwebtoken ではなく jose を選んだことを知っています。説明のし直し不要。コピペ不要。エージェントはただ*知っている*。
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0 新機能** — ランディングサイト [agent-memory.dev](https://agent-memory.dev) 公開、ファイルシステムコネクタ(`@agentmemory/fs-watcher`)、スタンドアロン MCP は実行中のサーバーへプロキシすることで hooks とビューワーが整合、削除パス全体で監査ポリシーをコード化、健康チェックは小さな Node プロセスで `memory_critical` を誤検知しなくなりました。詳細は [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) を参照。
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### 検索精度
227
-
228
- **coding-agent-life-v1**(社内コーパス、サンドボックスで再現可能)
229
-
230
- | アダプタ | P@5 | R@5 | Top-5 ヒット率 | p50 レイテンシ |
231
- |---|---|---|---|---|
232
- | **agentmemory ハイブリッド** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep ベースライン | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100% Top-5 ヒット率。同じ入力で grep ベースラインより **2.2×** 高い精度。タイプ別の詳細は [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
-
237
- **LongMemEval-S**(ICLR 2025、500 問)
238
-
239
- | システム | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25 のみのフォールバック | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### トークン削減
248
-
249
- | 方式 | トークン/年 | コスト/年 |
250
- |---|---|---|
251
- | フルコンテキスト貼付 | 19.5M+ | 不可能(コンテキストウィンドウ超過) |
252
- | LLM 要約 | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + ローカル埋め込み | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > 埋め込みモデル:`all-MiniLM-L6-v2`(ローカル、無料、API キー不要)。詳細レポート:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。競合比較:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0、Letta、Khoj、claude-mem、Hippo。
261
-
262
- **ローカルで再現:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s`(公開 500 問)+ `coding-agent-life-v1`(社内 15 セッションコーパス)向けのアダプタプラガブルハーネス。Grep / vector / agentmemory アダプタを並べてスコアリングし、NDJSON 出力、公開スコアカードは [`docs/benchmarks/`](../docs/benchmarks/) に掲載。
263
-
264
- **[codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything)、[Graphify](https://github.com/safishamsi/graphify) と組み合わせて使えます。** コードグラフのインデックス、マルチエージェントビルドパイプライン、ドキュメント / PDF / 画像 / 動画にまたがる広範なナレッジグラフ。agentmemory が作業を覚え、これら 3 つのプロジェクトがコンテキストレイヤーの残りを照らします。レシピと質問ルーティング表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">組み込み (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>種別</strong></td>
280
- <td>メモリエンジン + MCP サーバー</td>
281
- <td>メモリレイヤー API</td>
282
- <td>フルエージェントランタイム</td>
283
- <td>静的ファイル</td>
284
- </tr>
285
- <tr>
286
- <td><strong>検索 R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>自動キャプチャ</strong></td>
294
- <td>12 hooks(手動作業ゼロ)</td>
295
- <td>手動の <code>add()</code> 呼び出し</td>
296
- <td>エージェントが自分で編集</td>
297
- <td>手動編集</td>
298
- </tr>
299
- <tr>
300
- <td><strong>検索</strong></td>
301
- <td>BM25 + ベクトル + グラフ(RRF 融合)</td>
302
- <td>ベクトル + グラフ</td>
303
- <td>ベクトル(アーカイブ)</td>
304
- <td>すべてをコンテキストにロード</td>
305
- </tr>
306
- <tr>
307
- <td><strong>マルチエージェント</strong></td>
308
- <td>MCP + REST + リース + シグナル</td>
309
- <td>API(調整なし)</td>
310
- <td>Letta ランタイム内のみ</td>
311
- <td>エージェントごとにファイル</td>
312
- </tr>
313
- <tr>
314
- <td><strong>フレームワークロックイン</strong></td>
315
- <td>なし(任意の MCP クライアント)</td>
316
- <td>なし</td>
317
- <td>高(Letta 必須)</td>
318
- <td>エージェントごとのフォーマット</td>
319
- </tr>
320
- <tr>
321
- <td><strong>外部依存</strong></td>
322
- <td>なし(SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + ベクトル DB</td>
325
- <td>なし</td>
326
- </tr>
327
- <tr>
328
- <td><strong>メモリライフサイクル</strong></td>
329
- <td>4 層統合 + 減衰 + 自動忘却</td>
330
- <td>受動的抽出</td>
331
- <td>エージェント管理</td>
332
- <td>手動プルーニング</td>
333
- </tr>
334
- <tr>
335
- <td><strong>トークン効率</strong></td>
336
- <td>~1,900 tokens/セッション ($10/年)</td>
337
- <td>統合方法による</td>
338
- <td>コアメモリがコンテキスト内</td>
339
- <td>240 観測で 22K+ tokens</td>
340
- </tr>
341
- <tr>
342
- <td><strong>リアルタイムビューワー</strong></td>
343
- <td>あり(ポート 3113)</td>
344
- <td>クラウドダッシュボード</td>
345
- <td>クラウドダッシュボード</td>
346
- <td>なし</td>
347
- </tr>
348
- <tr>
349
- <td><strong>セルフホスト</strong></td>
350
- <td>あり(デフォルト)</td>
351
- <td>オプション</td>
352
- <td>オプション</td>
353
- <td>あり</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
-
361
- 互換性:このリリースは安定版の `iii-sdk` `^0.11.0` と iii-engine v0.11.x を対象とします。
362
-
363
- ### 30 秒で試す
364
-
365
- ```bash
366
- # ターミナル 1: サーバーを起動
367
- npx @agentmemory/agentmemory
368
-
369
- # ターミナル 2: サンプルデータを投入してリコールを確認
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` は 3 つの現実的なセッション(JWT 認証、N+1 クエリ修正、レート制限)を投入し、セマンティック検索を実行します。「database performance optimization」で検索すると「N+1 query fix」が見つかります — キーワード一致ではできない芸当です。
374
-
375
- `http://localhost:3113` を開けばメモリがリアルタイムに構築される様子が見られます。
376
-
377
- ### 推奨:グローバルインストール
378
-
379
- `npx` はバージョン単位でキャッシュ���ます。先週 `npx @agentmemory/agentmemory@0.9.14` を実行していた場合、素の `npx @agentmemory/agentmemory` は最新ではなく `~/.npm/_npx/` から古い 0.9.14 を提供することがあります。一度インストールすれば、素の `agentmemory` コマンドがどこでも動きます:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # macOS/Linux のシステム Node で EACCES が出る場合は次を試してください:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # サーバー起動(npx 形式と同じ)
386
- agentmemory stop # 停止
387
- agentmemory remove # 作成したものをすべてアンインストール
388
- agentmemory connect claude-code # エージェントを 1 つ接続
389
- agentmemory doctor # 対話型診断 + 修正プロンプト
390
- ```
391
-
392
- v0.9.16 以降、初回 npx 実行時にインラインでグローバルインストールを促されます — 一度 `Y` と答えれば完了です。スキップした場合、以下のいずれかで最新を取得できます:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # npm から最新を強制(クロスプラットフォーム)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux のみ (POSIX shell)
397
- ```
398
-
399
- Windows / PowerShell では、同等のキャッシュクリアは `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` です — 上記の `npx -y ...@latest` 形式がクロスプラットフォームの選択肢になります。
400
-
401
- ### セッションリプレイ
402
-
403
- agentmemory が記録するすべてのセッションは再生可能です。ビューワーを開き、**Replay** タブを選択し、タイムラインをスクラブしてください: プロンプト、ツール呼び出し、ツール結果、応答が個別のイベントとして表示され、再生/一時停止、速度コントロール(0.5×–4×)、キーボードショートカット(スペースで切り替え、矢印でステップ)が使えます。
404
-
405
- 古い Claude Code の JSONL トランスクリプトを取り込みたい?
406
-
407
- ```bash
408
- # デフォルトの ~/.claude/projects 配下を一括インポート
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # あるいは単一ファイルをインポート
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- インポートしたセッションはネイティブのセッションと並んで Replay ピッカーに表示されます。内部では各エントリが `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` の iii functions を経由します — サイドチャネルサーバーはありません。
416
-
417
- ### アップグレード / メンテナンス
418
-
419
- 意図的にローカルランタイムを更新したいときは、メンテナンスコマンドを使ってください:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- 警告: このコマンドは現在のワークスペース/ランタイムを変更します。JavaScript 依存を更新したり、`cargo install iii-engine --force` を実行したり、Docker イメージを pull したりすることがあります。
426
-
427
- 実装の詳細は `src/cli.ts` を参照(`src/cli.ts:544-595` 付近の `runUpgrade`)。
428
-
429
- ### Claude Code(1 ブロックそのまま貼り付け)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### プラグインをインストールしない Claude Code(MCP スタンドアロン)
436
-
437
- `/plugin install` ではなく `~/.claude.json` から直接 agentmemory の MCP サーバーを配線する場合、Claude Code は `${CLAUDE_PLUGIN_ROOT}` を解決しないため、hook スクリプトを `~/.claude/settings.json` の絶対パスに向ける必要があります。これらのパスには通常 agentmemory のバージョン(例: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`)が埋め込まれるため、次のアップグレードで全 hook が静かに壊れます([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
-
439
- 回避策:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- 同じ hook コマンドを `~/.claude/settings.json` にマージし、現在インストールされている `@agentmemory/agentmemory` パッケージの `plugin/` ディレクトリに解決された絶対パスを書き込みます。agentmemory をアップグレードしたら、このコマンドを再実行してパスを更新してください。��じファイル内のユーザーエントリは保持され、以前の agentmemory エントリだけが置き換えられます。`/plugin install` の経路が推奨アプローチであることに変わりはありません。
446
-
447
- リモートや保護されたデプロイでは、`AGENTMEMORY_URL` と `AGENTMEMORY_SECRET` を設定して Claude Code を起動します。プラグインはこの両方の値を同梱の MCP サーバーに渡します。`AGENTMEMORY_URL` が空の場合、MCP shim は `http://localhost:3111` にフォールバックします。
448
-
449
- ### Codex CLI(Codex プラグインプラットフォーム)
450
-
451
- ```bash
452
- # 1. 別ターミナルでメモリサーバーを起動
453
- npx @agentmemory/agentmemory
454
-
455
- # 2. agentmemory マーケットプレイスを登録してプラグインをインストール
456
- codex plugin marketplace add rohitg00/agentmemory
457
- codex plugin add agentmemory@agentmemory
458
- ```
459
-
460
- Codex プラグインは Claude Code プラグインと同じ `plugin/` ディレクトリから出荷されます。以下を登録します:
461
-
462
- - `@agentmemory/mcp` を MCP サーバーとして(`AGENTMEMORY_URL` が動作中の agentmemory サーバーを指す場合は 51 ツールすべてをプロキシ、サーバーに到達できない場合はローカルで 7 ツールにフォールバック)
463
- - 6 つのライフサイクル hooks: `SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
- - 4 つの skills: `/recall`、`/remember`、`/session-history`、`/forget`
465
-
466
- Codex の hook エンジンは hook サブプロセスに `CLAUDE_PLUGIN_ROOT` を注入する([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs))ので、同じ hook スクリプトが両ホストで重複なく動きます。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure イベントは Claude Code 専用で、Codex には登録されません。
467
-
468
- #### Codex Desktop: プラグイン hooks は現在無音(回避策あり)
469
-
470
- `CodexHooks` と `PluginHooks` はどちらも [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) で安定版・デフォルト有効ですが、Codex Desktop ビルドは現在プラグインローカルの `hooks.json` をディスパッチしません([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP ツールは引き続き動きますが、ライフサイクル観測だけが欠落します。
471
-
472
- 上流が修正を出すまでは、同じ hook コマンドをグローバルな `~/.codex/hooks.json` にミラーしてください:
473
-
474
- ```bash
475
- agentmemory connect codex --with-hooks
476
- ```
477
-
478
- これは同梱スクリプトへの絶対パスを参照する冪等なブロックを `~/.codex/hooks.json` に追加します(ユーザースコープでは `${CLAUDE_PLUGIN_ROOT}` の展開は不要)。agentmemory をアップグレードしたら同じコマンドを再実行してパスを更新してください。同じファイル内のユーザーエントリは保持され、以前の agentmemory エントリだけが置き換えられます。
479
-
480
- <details>
481
- <summary><b>OpenClaw(このプロンプトを貼り付け)</b></summary>
482
-
483
- ```text
484
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
-
486
- {
487
- "mcpServers": {
488
- "agentmemory": {
489
- "command": "npx",
490
- "args": ["-y", "@agentmemory/mcp"],
491
- "env": {
492
- "AGENTMEMORY_URL": "http://localhost:3111"
493
- }
494
- }
495
- }
496
- }
497
-
498
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
- ```
500
-
501
- 詳細ガイド:[`integrations/openclaw/`](../integrations/openclaw/)
502
-
503
- </details>
504
-
505
- <details>
506
- <summary><b>Hermes Agent(このプロンプトを貼り付け)</b></summary>
507
-
508
- ```text
509
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
-
511
- mcp_servers:
512
- agentmemory:
513
- command: npx
514
- args: ["-y", "@agentmemory/mcp"]
515
-
516
- memory:
517
- provider: agentmemory
518
-
519
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
- ```
521
-
522
- 詳細ガイド:[`integrations/hermes/`](../integrations/hermes/)
523
-
524
- </details>
525
-
526
- ### その他のエージェント
527
-
528
- メ��リサーバーを起動:`npx @agentmemory/agentmemory`
529
-
530
- `mcpServers` シェイプを使うホスト(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)では、agentmemory エントリは**同じ MCP サーバーブロック**です:
531
-
532
- ```json
533
- "agentmemory": {
534
- "command": "npx",
535
- "args": ["-y", "@agentmemory/mcp"],
536
- "env": {
537
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
- }
540
- }
541
- ```
542
-
543
- **このエントリをホストの設定ファイルにある既存の `mcpServers` オブジェクトにマージしてください** — ファイル全体を置き換えないでください。ファイルに既に他のサーバーがある場合は、`agentmemory` をその隣にもう 1 つのキーとして追加します。`mcpServers` が完全に欠落している場合は、ブロックを `{ "mcpServers": { ... } }` の中に貼り付けてください。`${VAR}` プレースホルダーは MCP サーバー起動時にシェルから `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` を継承します — 未設定の変数は空文字列を渡し、shim は `http://localhost:3111` にフォールバックします。1 つの接続済みエントリでローカルとリモート(k8s / リバースプロキシ)両方のデプロイに対応します。
544
-
545
- | エージェント | 設定ファイル | 備考 |
546
- |---|---|---|
547
- | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` にマージ。ウェブサイトでワンクリックディープリンクも利用可能。 |
548
- | **Claude Desktop** | `claude_desktop_config.json`(Application Support) | `mcpServers` にマージ。編集後 Claude Desktop を再起動。 |
549
- | **Cline / Roo Code / Kilo Code** | Cline MCP 設定(設定 UI → MCP Servers → Edit) | 同じ `mcpServers` ブロック。 |
550
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同じ `mcpServers` ブロック。 |
551
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自動マージ)。 |
552
- | **OpenClaw** | OpenClaw MCP 設定 | 同じ `mcpServers` ブロック、または[より深いメモリプラグイン](../integrations/openclaw/)を使用。 |
553
- | **Codex CLI(MCP のみ)** | `.codex/config.toml` | TOML シェイプ: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`、または `[mcp_servers.agentmemory]` を手動で追加。 |
554
- | **Codex CLI(フルプラグイン)** | Codex プラグインマーケットプレイス | `codex plugin marketplace add rohitg00/agentmemory` のあと `codex plugin add agentmemory@agentmemory`。MCP + 6 つのライフサイクル hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 つの skills を登録。Codex Desktop では、[openai/codex#16430](https://github.com/openai/codex/issues/16430) が解決するまで `agentmemory connect codex --with-hooks` も実行 — そちらではプラグイン hooks が現在無音。 |
555
- | **OpenCode(MCP のみ)** | `opencode.json` | 異なるシェイプ — トップレベルの `mcp` キー、command は配列: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
- | **OpenCode(フルプラグイン)** | `plugin/opencode/` | 22 個の自動キャプチャ hooks がセッションライフサイクル、メッセージ、ツール、エラーをカバー。2 つのスラッシュコマンド(`/recall`、`/remember`)。`plugin/opencode/` を OpenCode ワークスペースにコピーし、プラグインエントリを `opencode.json` に追加。完全な hook 表とギャップ分析は [`plugin/opencode/README.md`](../plugin/opencode/README.md) を参照。 |
557
- | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) をコピーして pi を再起動。 |
558
- | **Hermes Agent** | `~/.hermes/config.yaml` | より深い[メモリプロバイダープラグイン](../integrations/hermes/)を使い、`memory.provider: agentmemory` を設定。 |
559
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` が標準の `mcpServers` ブロックを書き込みます。Hook ペイロードは Claude Code とフィールド互換なので、既存の 12 hook スクリプトはそのまま動作 — 同じ `settings.json` の `hooks` セクションで配線してください。 |
560
- | **Antigravity**(Gemini CLI の後継) | `mcp_config.json`(Antigravity の User ディレクトリ内) | `agentmemory connect antigravity` が標準の `mcpServers` ブロックを書き込みます。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。2026-06-18 の Gemini CLI 終了後に使用。 |
561
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` がユーザーレベル設定を書き込みます。ワークスペースのオーバーライドはコードの横にある `.kiro/settings/mcp.json` に。 |
562
- | **Goose** | Goose MCP 設定 UI | 同じ `mcpServers` ブロック。 |
563
- | **Aider** | n/a | REST API に直接話しかける: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
- | **任意のエージェント(32+)** | n/a | `npx skillkit install agentmemory` がホストを自動検出してマージ。 |
565
-
566
- **サンドボックス化された MCP クライアント**(Flatpak / Snap / 制限的なコンテナ)はホストの `localhost` に到達できません: `env` ブロックに `"AGENTMEMORY_FORCE_PROXY": "1"` も設定し、`AGENTMEMORY_URL` をサンドボックスが実際に到達できる経路(例: LAN IP)に向けてください。診断手順は [#234](https://github.com/rohitg00/agentmemory/issues/234) を参照。
567
-
568
- ### プログラマティックアクセス(Python / Rust / Node)
569
-
570
- agentmemory はコア操作を iii functions(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)として登録します。iii SDK を持つあらゆる言語が `ws://localhost:49134` で直接呼び出せます — 言語ごとに REST クライアントを用意する必要はありません。
571
-
572
- ```bash
573
- pip install iii-sdk # Python
574
- cargo add iii-sdk # Rust
575
- npm install iii-sdk # Node
576
- ```
577
-
578
- ```python
579
- from iii import register_worker
580
-
581
- iii = register_worker("ws://localhost:49134")
582
- iii.connect()
583
-
584
- iii.trigger({
585
- "function_id": "mem::smart-search",
586
- "payload": {"project": "demo", "query": "how do tokens refresh"},
587
- })
588
- ```
589
-
590
- 実例:[`examples/python/`](../examples/python/)(クイックスタート + 観測/リコールフロー)。iii ランタイムがないホスト向けに `:3111` の REST も引き続き利用可能。
591
-
592
- ### ソースから
593
-
594
- ```bash
595
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
- npm install && npm run build && npm start
597
- ```
598
-
599
- `iii` が既にインストールされていれば、これでローカルの `iii-engine` で agentmemory が起動します。Docker が使える場合は Docker Compose にフォールバックします。REST、ストリーム、ビューワーはデフォルトで `127.0.0.1` にバインドします。
600
-
601
- `iii-engine` を手動でインストールしてください。**agentmemory は現在 `iii-engine` を `v0.11.2` にピン留めしています** — `v0.11.6` では `iii worker add` で何でもサンドボックス化する新モデルが導入されましたが、agentmemory はまだそれ向けにリファクタリングされていません。リファクタが完了次第ピンは解除されます。サンドボックスモデルへ手動移行済みなら `AGENTMEMORY_III_VERSION=<version>` でオーバーライドできます。
602
-
603
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
- - **macOS x64:** `aarch64-apple-darwin` を `x86_64-apple-darwin` に置換
605
- - **Linux x64:** `x86_64-unknown-linux-gnu` に置換
606
- - **Linux arm64:** `aarch64-unknown-linux-gnu` に置換
607
- - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) から `iii-x86_64-pc-windows-msvc.zip` をダウンロード、`iii.exe` を展開し PATH に追加
608
-
609
- または Docker を使用(同梱の `docker-compose.yml` が `iiidev/iii:0.11.2` を pull します)。詳細ドキュメント:[iii.dev/docs](https://iii.dev/docs)。
610
-
611
- ### Windows
612
-
613
- agentmemory は Windows 10/11 で動作しますが、Node.js パッケージだけでは不十分で、`iii-engine` ランタイム(別のネイティブバイナリ)もバックグラウンドプロセスとして必要です。公式の上流インストーラは `sh` スクリプトで、今のところ PowerShell インストーラや scoop/winget パッケージは存在しないため、Windows ユーザーには 2 つの経路があります:
614
-
615
- **選択肢 A — ビルド済み Windows バイナリ(推奨):**
616
-
617
- ```powershell
618
- # 1. ブラウザで https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 を開く
619
- # (engine v0.11.6+ が要求する新しいサンドボックスモデルへ
620
- # agentmemory がリファクタリングされるまで v0.11.2 にピン留め)
621
- # 2. iii-x86_64-pc-windows-msvc.zip をダウンロード
622
- # (ARM マシンの場合は iii-aarch64-pc-windows-msvc.zip)
623
- # 3. iii.exe を PATH 上のどこかに展開、または以下に配置:
624
- # %USERPROFILE%\.local\bin\iii.exe
625
- # (agentmemory はこの場所を自動でチェックします)
626
- # 4. 確認:
627
- iii --version
628
- # 出力: 0.11.2
629
-
630
- # 5. その後 agentmemory を通常通り起動:
631
- npx -y @agentmemory/agentmemory
632
- ```
633
-
634
- **選択肢 B — Docker Desktop:**
635
-
636
- ```powershell
637
- # 1. Docker Desktop for Windows をインストール
638
- # 2. Docker Desktop を起動し、エンジンが動作中であることを確認
639
- # 3. agentmemory を実行 — 同梱の compose ファイルが自動起動します:
640
- npx -y @agentmemory/agentmemory
641
- ```
642
-
643
- **選択肢 C — スタンドアロン MCP のみ(エンジンなし):** ���ージェント用に MCP ツールだけが必要で、REST API、ビューワー、cron ジョブが不要なら、エンジンを完全にスキップ:
644
-
645
- ```powershell
646
- npx -y @agentmemory/agentmemory mcp
647
- # あるいは shim パッケージ経由:
648
- npx -y @agentmemory/mcp
649
- ```
650
-
651
- **Windows の診断:** `npx @agentmemory/agentmemory` が失敗する場合、`--verbose` 付きで再実行して実際のエンジン stderr を確認してください。よくある失敗パターン:
652
-
653
- | 症状 | 修正 |
654
- |---|---|
655
- | `iii-engine process started` のあとに `did not become ready within 15s` | エンジンが起動時にクラッシュ — `--verbose` で再実行し stderr を確認 |
656
- | `Could not start iii-engine` | `iii.exe` も Docker もインストールされていない。上記の選択肢 A または B を参照 |
657
- | ポート競合 | `netstat -ano \| findstr :3111` でバインドを確認、kill するか `--port <N>` を使用 |
658
- | Docker をインストール済みなのにフォールバックがスキップされる | Docker Desktop が実際に動作している(システムトレイアイコン)ことを確認 |
659
-
660
- > 注意: `cargo install iii-engine` は存在しません — `iii` は crates.io に公開されていません。サポートされるインストール方法は、上記のビルド済みバイナリ、上流の `sh` インストールスクリプト(macOS/Linux のみ)、Docker イメージのみです。
661
-
662
- ---
663
-
664
- <h2 id="deploy">デプロイ</h2>
665
-
666
- マネージドホスト向けのワンクリックテンプレート。それぞれが
667
- 自己完結した Dockerfile を提供し、npm から
668
- `@agentmemory/agentmemory` を pull して公式の `iiidev/iii`
669
- Docker Hub イメージから iii engine バイナリをコピーします — 事前に
670
- ビルドした agentmemory イメージは不要です。永続ストレージは
671
- `/data` にマウントされます。初回起動の entrypoint は npm 同梱の
672
- iii 設定(`127.0.0.1` をバインド)をデプロイ向けに調整した
673
- 設定(`0.0.0.0` をバインドし絶対 `/data` パスを使用)で上書きし、
674
- HMAC シークレットを生成、そして `gosu` で `root` から `node`
675
- に権限を落としてから agentmemory CLI を exec します。
676
-
677
- <p>
678
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
679
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
680
- </p>
681
-
682
- Render のワンクリックデプロイボタンはリポジトリルートに `render.yaml` を要求しますが、ルートをあえて綺麗に保っています。[`deploy/render/`](../deploy/render/README.md) にドキュメント化された Render Blueprint フローを使い、リポジトリ内のブループリントを手動で指してください。
683
-
684
- 完全なセットアップ詳細(HMAC キャプチャ、ビューワーの SSH トンネル、
685
- ローテーション、バックアップ、コスト下限)は
686
- [`deploy/`](../deploy/README.md) を参照:
687
-
688
- - [`deploy/fly`](../deploy/fly/README.md) — 単一マシンで
689
- `auto_stop_machines = "stop"`、アイドル時最安。
690
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby プラン定額、
691
- ボリュームはダッシュボードで。
692
- - [`deploy/render`](../deploy/render/README.md) — Blueprint フロー、
693
- 有料プランで自動ディスクスナップショット。
694
- - [`deploy/coolify`](../deploy/coolify/README.md) — [Coolify](https://coolify.io/self-hosted)
695
- 経由で自前 VPS にセルフホスト。同じ Docker Compose
696
- スタックで、ホストとデータは自分の手元に。
697
-
698
- 公開されるのはポート `3111` のみです。`3113` のビューワーは
699
- コンテナ内でループバックにバインドされ続けます — 各テンプレートの
700
- README にそこへ到達する SSH トンネルパターンが記載されています。
701
-
702
- ---
703
-
704
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
705
-
706
- すべてのコーディングエージェントはセッションが終わるとすべてを忘れます。毎セッションの最初の 5 分をスタックの再説明に浪費しています。agentmemory はバックグラウンドで動作し、それを完全になくします。
707
-
708
- ```text
709
- Session 1: "Add auth to the API"
710
- Agent writes code, runs tests, fixes bugs
711
- agentmemory silently captures every tool use
712
- Session ends -> observations compressed into structured memory
713
-
714
- Session 2: "Now add rate limiting"
715
- Agent already knows:
716
- - Auth uses JWT middleware in src/middleware/auth.ts
717
- - Tests in test/auth.test.ts cover token validation
718
- - You chose jose over jsonwebtoken for Edge compatibility
719
- Zero re-explaining. Starts working immediately.
720
- ```
721
-
722
- ### 組み込みエージェントメモリとの比較
723
-
724
- すべての AI コーディングエージェントには組み込みのメモリが付属します — Claude Code には `MEMORY.md`、Cursor には notepad、Cline には memory bank。これらは付箋のようなものです。agentmemory はその付箋の背後にある検索可能なデータベースです。
725
-
726
- | | 組み込み (CLAUDE.md) | agentmemory |
727
- |---|---|---|
728
- | スケール | 200 行上限 | 無制限 |
729
- | 検索 | すべてをコンテキストにロード | BM25 + ベクトル + グラフ(top-K のみ) |
730
- | トークンコスト | 240 観測で 22K+ | ~1,900 tokens(92% 削減) |
731
- | クロスエージェント | エージェントごとのファイル | MCP + REST(任意のエージェント) |
732
- | 調整 | なし | リース、シグナル、アクション、ルーチン |
733
- | 可観測性 | 手動でファイルを読む | ポート 3113 のリアルタイムビューワー |
734
-
735
- ---
736
-
737
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
738
-
739
- ### メモリパイプライン
740
-
741
- ```text
742
- PostToolUse hook fires
743
- -> SHA-256 dedup (5min window)
744
- -> Privacy filter (strip secrets, API keys)
745
- -> Store raw observation
746
- -> LLM compress -> structured facts + concepts + narrative
747
- -> Vector embedding (6 providers + local)
748
- -> Index in BM25 + vector
749
-
750
- Stop / SessionEnd hook fires
751
- -> Summarize session
752
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
753
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
754
-
755
- SessionStart hook fires
756
- -> Load project profile (top concepts, files, patterns)
757
- -> Hybrid search (BM25 + vector + graph)
758
- -> Token budget (default: 2000 tokens)
759
- -> Inject into conversation
760
- ```
761
-
762
- ### 4 層メモリ統合
763
-
764
- 人間の脳が記憶を処理する方法に着想を得ています — 睡眠時の記憶統合と通じるものがあります。
765
-
766
- | 層 | 内容 | 例え |
767
- |------|------|---------|
768
- | **Working(作業記憶)** | ツール使用からの生観測 | 短期記憶 |
769
- | **Episodic(エピソード記憶)** | 圧縮されたセッション要約 | 「何が起きたか」 |
770
- | **Semantic(意味記憶)** | 抽出された事実とパターン | 「何を知っているか」 |
771
- | **Procedural(手続き記憶)** | ワークフローと意思決定パターン | 「どうやるか」 |
772
-
773
- 記憶は時間とともに減衰(エビングハウス曲線)。頻繁にアクセスされる記憶は強化されます。古い記憶は自動退避。矛盾は検出され解決されます。
774
-
775
- ### 何をキャプチャするか
776
-
777
- | Hook | キャプチャ内容 |
778
- |------|----------|
779
- | `SessionStart` | プロジェクトパス、セッション ID |
780
- | `UserPromptSubmit` | ユーザープロンプト(プライバシーフィルタ済み) |
781
- | `PreToolUse` | ファイルアクセスパターン + コンテキスト富化 |
782
- | `PostToolUse` | ツール名、入力、出力 |
783
- | `PostToolUseFailure` | エラーコンテキスト |
784
- | `PreCompact` | コンパクション前にメモリを再注入 |
785
- | `SubagentStart/Stop` | サブエージェントのライフサイクル |
786
- | `Stop` | セッション終了時の要約 |
787
- | `SessionEnd` | セッション完了マーカー |
788
-
789
- ### 主な機能
790
-
791
- | 機能 | 説明 |
792
- |---|---|
793
- | **自動キャプチャ** | hooks で毎ツール使用を記録 — 手動作業ゼロ |
794
- | **セマンティック検索** | BM25 + ベクトル + ナレッジグラフ、RRF 融合 |
795
- | **メモリ進化** | バージョン管理、上書き、関係グラフ |
796
- | **自動忘却** | TTL 期限切れ、矛盾検出、重要度退避 |
797
- | **プライバシー優先** | API キー、シークレット、`<private>` タグは保存前に除去 |
798
- | **自己修復** | サーキットブレーカー、プロバイダーフォールバックチェーン、ヘルスモニタ |
799
- | **Claude ブリッジ** | MEMORY.md と双方向同期 |
800
- | **ナレッジグラフ** | エンティティ抽出 + BFS 探索 |
801
- | **チームメモリ** | チームメンバー間で名前空間化された共有 + プライベート |
802
- | **引用の出所追跡** | あらゆるメモリを元の観測まで遡れる |
803
- | **Git スナップショット** | メモリ状態のバージョン、ロールバック、diff |
804
-
805
- ---
806
-
807
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
808
-
809
- 3 つのシグナルを組み合わせるトリプルストリーム検索:
810
-
811
- | ストリーム | 役割 | 起動条件 |
812
- |---|---|---|
813
- | **BM25** | ステミング付きキーワード一���と類義語拡張 | 常時有効 |
814
- | **Vector(ベクトル)** | 密埋め込みのコサイン類似度 | 埋め込みプロバイダー設定時 |
815
- | **Graph(グラフ)** | エンティティ一致によるナレッジグラフ探索 | クエリにエンティティ検出時 |
816
-
817
- Reciprocal Rank Fusion (RRF, k=60) で融合し、セッションで多様化(セッションあたり最大 3 件)。
818
-
819
- BM25 は箱から出してすぐにギリシャ文字、キリル文字、ヘブライ文字、アラビア文字、アクセント付きラテン文字をトークン化できます。中国語 / 日本語 / 韓国語のメモリには、オプションのセグメンタ(`npm install @node-rs/jieba tiny-segmenter`)をインストールして CJK 連続を単語レベルのトークンに分割してください。インストールしない場合、agentmemory は連続全体をそのままトークン化するソフトフォールバックに切り替わり、stderr に一度だけヒントを出します。
820
-
821
- ### 埋め込みプロバイダー
822
-
823
- agentmemory はプロバイダーを自動検出します。最良の結果を得るには、ローカル埋め込み(無料)をインストール:
824
-
825
- ```bash
826
- npm install @xenova/transformers
827
- ```
828
-
829
- | プロバイダー | モデル | コスト | 備考 |
830
- |---|---|---|---|
831
- | **ローカル(推奨)** | `all-MiniLM-L6-v2` | 無料 | オフライン、BM25 単独より召集率 +8pp |
832
- | Gemini | `gemini-embedding-001` | 無料枠 | 100+ 言語、768/1536/3072 次元 (MRL)、2048 トークン入力。`text-embedding-004` の後継([非推奨、2026 年 1 月 14 日に停止](https://ai.google.dev/gemini-api/docs/deprecations)) |
833
- | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高品質 |
834
- | Voyage AI | `voyage-code-3` | 有料 | コード向け最適化 |
835
- | Cohere | `embed-english-v3.0` | 無料試用 | 汎用 |
836
- | OpenRouter | 任意のモデル | 場合による | マルチモデルプロキシ |
837
-
838
- ---
839
-
840
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
841
-
842
- 53 ツール、6 リソース、3 プロンプト、4 skills — あらゆるエージェント向けで最も充実した MCP メモリツールキット。
843
-
844
- > **MCP shim とフルサーバー:** 公開されている `@agentmemory/mcp` パッケージは薄い shim です。**`AGENTMEMORY_URL` 経由で動作中の agentmemory サーバーに到達できる場合に限り**、完全な 51 ツール群を公開します(プロキシモード)。サーバーに到達できない場合、shim は 7 ツールのローカルセット(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)にフォールバックします。`AGENTMEMORY_TOOLS=core|all` 環境変数は*サーバー側*のフラグです — shim の `env` ブロックで設定しても効果はありません。Cursor / OpenCode / Gemini CLI で 7 ツールしか見えない場合は、`npx @agentmemory/agentmemory`(または Docker スタック)を起動し、`AGENTMEMORY_URL=http://localhost:3111` を設定してください。
845
-
846
- ### 51 ツール
847
-
848
- <details>
849
- <summary>コアツール(常時利用可能)</summary>
850
-
851
- | ツール | 説明 |
852
- |------|-------------|
853
- | `memory_recall` | 過去の観測を検索 |
854
- | `memory_compress_file` | 構造を保持したまま markdown ファイルを圧縮 |
855
- | `memory_save` | 洞察、決定、パターンを保存 |
856
- | `memory_patterns` | 繰り返し現れるパターンを検出 |
857
- | `memory_smart_search` | ハイブリッドなセマンティック + キーワード検索 |
858
- | `memory_file_history` | 特定ファイルに関する過去の観測 |
859
- | `memory_sessions` | 最近のセッション一覧 |
860
- | `memory_timeline` | 時系列の観測 |
861
- | `memory_profile` | プロジェクトプロファイル(概念、ファイル、パターン) |
862
- | `memory_export` | すべてのメモリデータをエクスポート |
863
- | `memory_relations` | 関係グラフを照会 |
864
-
865
- </details>
866
-
867
- <details>
868
- <summary>拡張ツール(全 51 — AGENTMEMORY_TOOLS=all を設定)</summary>
869
-
870
- | ツール | 説明 |
871
- |------|-------------|
872
- | `memory_patterns` | 繰り返し現れるパターンを検出 |
873
- | `memory_timeline` | 時系列の観測 |
874
- | `memory_relations` | 関係グラフを照会 |
875
- | `memory_graph_query` | ナレッジグラフ探索 |
876
- | `memory_consolidate` | 4 層統合を実行 |
877
- | `memory_claude_bridge_sync` | MEMORY.md と同期 |
878
- | `memory_team_share` | チームメンバーと共有 |
879
- | `memory_team_feed` | 最近の共有アイテム |
880
- | `memory_audit` | 操作の監査証跡 |
881
- | `memory_governance_delete` | 監査証跡付き削除 |
882
- | `memory_snapshot_create` | Git バージョンスナップショット |
883
- | `memory_action_create` | 依存関係付き作業項目を作成 |
884
- | `memory_action_update` | アクションのステータス更新 |
885
- | `memory_frontier` | 優先度順のブロック解除済みアクション |
886
- | `memory_next` | 次に最も重要なアクション 1 つ |
887
- | `memory_lease` | 排他的アクションリース(マルチエージェント) |
888
- | `memory_routine_run` | ワークフロー ルーチンをインスタンス化 |
889
- | `memory_signal_send` | エージェント間メッセージング |
890
- | `memory_signal_read` | 受領確認付きでメッセージを読む |
891
- | `memory_checkpoint` | 外部条件ゲート |
892
- | `memory_mesh_sync` | インスタンス間 P2P 同期 |
893
- | `memory_sentinel_create` | イベント駆動ウォッチャー |
894
- | `memory_sentinel_trigger` | 外部からセンチネルを発火 |
895
- | `memory_sketch_create` | 一時的なアクショングラフ |
896
- | `memory_sketch_promote` | 永続化に昇格 |
897
- | `memory_crystallize` | アクションチェーンをコンパクト化 |
898
- | `memory_diagnose` | ヘルスチェック |
899
- | `memory_heal` | 詰まった状態を自動修復 |
900
- | `memory_facet_tag` | 次元:値タグ |
901
- | `memory_facet_query` | facet タグで照会 |
902
- | `memory_verify` | 出所を追跡 |
903
-
904
- </details>
905
-
906
- ### 6 リソース · 3 プロンプト · 4 Skills
907
-
908
- | 種類 | 名前 | 説明 |
909
- |------|------|-------------|
910
- | Resource | `agentmemory://status` | ヘルス、セッション数、メモリ数 |
911
- | Resource | `agentmemory://project/{name}/profile` | プロジェクト別インテリジェンス |
912
- | Resource | `agentmemory://memories/latest` | 直近 10 件のアクティブメモリ |
913
- | Resource | `agentmemory://graph/stats` | ナレッジグラフ統計 |
914
- | Prompt | `recall_context` | 検索してコンテキストメッセージを返す |
915
- | Prompt | `session_handoff` | エージェント間でのハンドオフデータ |
916
- | Prompt | `detect_patterns` | 繰り返し現れるパターンを分析 |
917
- | Skill | `/recall` | メモリを検索 |
918
- | Skill | `/remember` | 長期メモリに保存 |
919
- | Skill | `/session-history` | 最近のセッション要約 |
920
- | Skill | `/forget` | 観測/セッションを削除 |
921
-
922
- ### スタンドアロン MCP
923
-
924
- フルサーバーなしで実行 — 任意の MCP クライアント向け。以下のどちらも動きます:
925
-
926
- ```bash
927
- npx -y @agentmemory/agentmemory mcp # 正規(常時利用可能)
928
- npx -y @agentmemory/mcp # shim パッケージのエイリアス
929
- ```
930
-
931
- またはエージェントの MCP 設定に追加:
932
-
933
- ほとんどのエージェント(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
934
- ```json
935
- {
936
- "mcpServers": {
937
- "agentmemory": {
938
- "command": "npx",
939
- "args": ["-y", "@agentmemory/mcp"],
940
- "env": {
941
- "AGENTMEMORY_URL": "http://localhost:3111"
942
- }
943
- }
944
- }
945
- }
946
- ```
947
-
948
- `agentmemory` エントリはホストの既存 `mcpServers` オブジェクトにマージし、ファイル全体を置き換えないでください。ホストの `localhost` に到達できないサンドボックスクライアントには、env ブロックに `"AGENTMEMORY_FORCE_PROXY": "1"` を追加し、`AGENTMEMORY_URL` をサンドボックスが到達できる経路に設定してください。
949
-
950
- OpenCode (`opencode.json`):
951
- ```json
952
- {
953
- "mcp": {
954
- "agentmemory": {
955
- "type": "local",
956
- "command": ["npx", "-y", "@agentmemory/mcp"],
957
- "enabled": true
958
- }
959
- },
960
- "plugin": ["./plugins/agentmemory-capture.ts"]
961
- }
962
- ```
963
-
964
- リポジトリからプラグインファイルをコピー:
965
- ```bash
966
- mkdir -p ~/.config/opencode/plugins
967
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
968
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
969
- ```
970
-
971
- ---
972
-
973
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
974
-
975
- ポート `3113` で自動起動。ライブ観測ストリーム、セッションエクスプローラ、メモリブラウザ、ナレッジグラフの可視化、ヘルスダッシュボード。
976
-
977
- ```bash
978
- open http://localhost:3113
979
- ```
980
-
981
- ビューワーサーバーはデフォルトで `127.0.0.1` にバインドします。REST 経由の `/agentmemory/viewer` エンドポイントは通常の `AGENTMEMORY_SECRET` ベアラートークン規則に従います。CSP ヘッダーはレスポンスごとのスクリプト nonce を使い、インラインハンドラ属性は無効化(`script-src-attr 'none'`)。
982
-
983
- ---
984
-
985
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
986
-
987
- `:3113` のビューワーはエージェントが**覚えた**ことを見せます。[iii コンソール](https://iii.dev/docs/console)はエージェントが**やった**ことを見せます — 各メモリ操作は OpenTelemetry トレース、各 KV エントリは編集可能、各 function は呼び出し可能、各ストリームは tap 可能。同じメモリへの 2 つの窓: 一方はプロダクト形、もう一方はエンジン形。
988
-
989
- `memory_smart_search` の発火を眺め、BM25 スキャン → 埋め込み参照 → RRF 融合 → リランカーをウォーターフォールで見ます。KV ブラウザで詰まった統合タイマーを編集します。調整したペイロードで `PostToolUse` hook を再生します。WebSocket ストリームをピンして観測がライブで着地するのを眺めます。
990
-
991
- agentmemory はこれを無料で提供します。すべての function、トリガー、ステートスコープ、ストリームが iii プリミティブだからです — カスタム実装も計装も必要ありません。
992
-
993
- <p align="center">
994
- <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
995
- <br/>
996
- <em>Workers ページ: agentmemory 自身を含む、接続中のすべての worker と PID、function 数、ランタイム、最終応答時刻。</em>
997
- </p>
998
-
999
- **インストール済みです。** コンソールは `iii` に同梱 — 別途インストーラはありません。
1000
-
1001
- **agentmemory と並行して起動:**
1002
-
1003
- ```bash
1004
- # agentmemory ビューワーがポート 3113 を握っているので、コンソールは 3114 で実行します。
1005
- # エンジン REST (3111)、WebSocket (3112)、bridge (49134) のデフォルトは agentmemory と一致します。
1006
- iii console --port 3114
1007
- ```
1008
-
1009
- その後 `http://localhost:3114` を開きます。`--enable-flow` で実験的なアーキテクチャグラフページを有効化します。
1010
-
1011
- エンジンエンドポイントを移動した場合のみ上書き:
1012
-
1013
- ```bash
1014
- iii console --port 3114 \
1015
- --engine-port 3111 \
1016
- --ws-port 3112 \
1017
- --bridge-port 49134
1018
- ```
1019
-
1020
- **コンソールでできること:**
1021
-
1022
- | ページ | 用途 |
1023
- |------|-----------|
1024
- | **Workers** | agentmemory worker 自身を含む、接続中の各 worker とライブメトリクスを表示。 |
1025
- | **Functions** | JSON ペイロードを与えて agentmemory の任意の function を直接呼び出し — クライアントを配線せずに `memory.recall`、`memory.consolidate`、`graph.query` をテストできて便利。 |
1026
- | **Triggers** | HTTP、cron、イベント、ステートのトリガーを再生 — 統合 cron を手動で発火、HTTP ルートを再試行、ステート変更を発行。 |
1027
- | **States** | フル CRUD の KV ブラウザ — セッション、メモリスロット、ライフサイクルタイマー、埋め込みインデックス — その場で値を編集。 |
1028
- | **Streams** | メモリ書き込み、hook イベント、観測更新が iii ストリームを流れる様子をライブで監視する WebSocket モニタ。 |
1029
- | **Queues** | 永続キューのトピック + デッドレター管理。失敗した埋め込み / 圧縮ジョブを再生または破棄。 |
1030
- | **Traces** | OpenTelemetry のウォーターフォール / フレーム / サービスブレークダウン。`trace_id` でフィルタすれば、単一の `memory.search` がどの function、DB 呼び出し、埋め込みリクエストを生んだか正確にわかります。 |
1031
- | **Logs** | 構造化 OTEL ログをフィルタし、trace/span ID と相関付け。 |
1032
- | **Config** | ランタイム設定 — エンジンがどの worker、プロバイダー、ポートで動いているか確認。 |
1033
- | **Flow** | (オプション、`--enable-flow`)各 worker、トリガー、ストリームの対話型アーキテクチャグラフ。 |
1034
-
1035
- <p align="center">
1036
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1037
- <br/>
1038
- <em>Traces: すべてのメモリ操作についてウォーターフォール / フレーム / サービスブレークダウン。</em>
1039
- </p>
1040
-
1041
- **Traces は既にオン:**
1042
-
1043
- `iii-config.yaml` は出荷時から `iii-observability` worker を有効化(`exporter: memory`、`sampling_ratio: 1.0`、メトリクス + ログ)。追加設定不要 — agentmemory が起動した瞬間に、すべてのメモリ操作がトレーススパンとコンソールが読み取れる構造化ログを出します。
1044
-
1045
- 代わりに Jaeger / Honeycomb / Grafana Tempo へエクスポートしたい場合は、`exporter: memory` を `exporter: otlp` に変更し、iii の可観測性ドキュメントに従ってコレクタエンドポイントを設定してください。
1046
-
1047
- > **注意:** コンソール自身に認証は強制されていません — デフォルトの `127.0.0.1` バインドのままにし、決して公開しないでください。
1048
-
1049
- ---
1050
-
1051
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1052
-
1053
- agentmemory は**それ自体が稼働中の [iii](https://iii.dev) インスタンス**です。function、トリガー、KV ステート、ストリーム、OTEL トレース — すべてが iii プリミティブです。Postgres、Redis、Express、pm2、Prometheus をインストールしなかったのは、iii がそれらを置き換えるからです。
1054
-
1055
- つまり、もう 1 つのコマンドで agentmemory にまったく新しい機能を拡張できます。
1056
-
1057
- ### 1 つのコマンドで agentmemory を拡張
1058
-
1059
- ```bash
1060
- iii worker add iii-pubsub # メモリ書き込みを接続中のすべてのインスタンスに fan-out
1061
- iii worker add iii-cron # スケジュール統合、減衰スイープ、スナップショットローテーション
1062
- iii worker add iii-queue # 埋め込み + 圧縮ジョブの永続リトライ
1063
- iii worker add iii-observability # すべてのメモリ操作に OTEL トレース(デフォルト オン)
1064
- iii worker add iii-sandbox # リコールしたコードを隔離 microVM 内で実行
1065
- iii worker add iii-database # SQL バックエンドのステートアダプタに切り替え
1066
- iii worker add mcp # agentmemory MCP の横に汎用 MCP ホストを立てる
1067
- ```
1068
-
1069
- 各 `iii worker add` は新しい function とトリガーを、agentmemory が既に動いているのと同じエンジンに登録します。ビューワーとコンソールがすぐに拾い上げます — リロード不要、新しい統合不要、新しいコンテナ不要。
1070
-
1071
- | `iii worker add` | agentmemory の上に得られるもの |
1072
- |---|---|
1073
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | マルチインスタンスメモリ: すべての `remember` が fan-out、すべての `search` が和集合を読む |
1074
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | スケジュールされたライフサイクル — 夜間統合、週次スナップショット、固定クロックでの減衰 |
1075
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 永続リトライ: 失敗した埋め込み + 圧縮ジョブが再起動を生き延び、観測は失われない |
1076
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | すべての function に OTEL トレース、メトリクス、ログ — 初日から `iii-config.yaml` に配線済み |
1077
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` から出てきたコードはあなたのシェルではなく使い捨て VM 内で実行 |
1078
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | デフォルトのインメモリ KV では足りないときの SQL バックエンドのステートアダプタ |
1079
- | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory の隣に追加の MCP サーバーを立て、同じエンジンを共有 |
1080
-
1081
- 完全なレジストリ:[workers.iii.dev](https://workers.iii.dev)。そこにあるすべての worker は agentmemory が使っているのと同じプリミティブで組み立てられています — そして既に手元にある agentmemory もその 1 つです。
1082
-
1083
- ### iii が置き換えるもの
1084
-
1085
- | 従来のスタック | agentmemory が使うもの |
1086
- |---|---|
1087
- | Express.js / Fastify | iii HTTP Triggers |
1088
- | SQLite / Postgres + pgvector | iii KV State + インメモリベクトルインデックス |
1089
- | SSE / Socket.io | iii Streams (WebSocket) |
1090
- | pm2 / systemd | iii engine worker 監視 |
1091
- | Prometheus / Grafana | iii OTEL + ヘルスモニタ |
1092
- | カスタムプラグインシステム | `iii worker add <name>` |
1093
-
1094
- **118 ソースファイル · ~21,800 LOC · 950+ テスト · 123 functions · 34 KV スコープ** — すべて 3 つのプリミティブの上に。`agentmemory plugin install` はありません。プラグインシステムは iii そのものです。
1095
-
1096
- ---
1097
-
1098
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1099
-
1100
- ### LLM プロバイダー
1101
-
1102
- agentmemory は環境から自動検出します。デフォルトでは、プロバイダーを設定するか Claude 購読フォールバックに明示的にオプトインしない限り、LLM 呼び出しは行いません。
1103
-
1104
- | プロバイダー | 設定 | 備考 |
1105
- |----------|--------|-------|
1106
- | **No-op(デフォルト)** | 設定不要 | LLM 駆動の compress/summarize は無効。合成 BM25 圧縮 + リコールは引き続き動作。以前 Claude 購読フォールバックに依存していた場合は、下記の `AGENTMEMORY_ALLOW_AGENT_SDK` を参照。 |
1107
- | Anthropic API | `ANTHROPIC_API_KEY` | トークン単位課金 |
1108
- | MiniMax | `MINIMAX_API_KEY` | Anthropic 互換 |
1109
- | Gemini | `GEMINI_API_KEY` | 埋め込みも有効化 |
1110
- | OpenRouter | `OPENROUTER_API_KEY` | 任意のモデル |
1111
- | Claude 購読フォールバック | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | オプトインのみ。`@anthropic-ai/claude-agent-sdk` セッションを生成 — 過去に無限の Stop-hook 再帰(#149 のフォローアップ)を引き起こしたため、もはやデフォルトではありません。 |
1112
-
1113
- ### コストを意識したモデル選択
1114
-
1115
- バックグラウンド圧縮は観測のたびに走るため、モデル選択は月額支出に大きく効きます。記録されたワークロード: 635 リクエスト / 888K トークン / 35 時間のアクティブ使用、2026-05-23 時点の OpenRouter 価格で 3 モデルを比較。
1116
-
1117
- | 階層 | モデル | 入力 / 1M | 出力 / 1M | 35 時間のワークロードでのコスト | 備考 |
1118
- |------|-------|------------|-------------|---------------------------|-------|
1119
- | 推奨 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 圧縮 + 要約品質が手堅く、Sonnet の約 10 分の 1 のコスト。 |
1120
- | 推奨 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | やや古めだが圧縮のみのワークロードには十分。 |
1121
- | 推奨 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | セッションがコード中心ならコード推論が強い。 |
1122
- | プレミアム | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 品質は高いが常時稼働のバックグラウンドには高価。 |
1123
- | プレミアム | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet と同階層。 |
1124
- | 回避 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推論クラスのモデル。圧縮には大幅な過剰支出。 |
1125
-
1126
- agentmemory は `OPENROUTER_MODEL` がプレミアム階層パターンと一致するときランタイム警告を表示します。納得して選んだあとは `AGENTMEMORY_SUPPRESS_COST_WARNING=1` で消音できます。
1127
-
1128
- メモリ作業における品質対コストのトレードオフ: 圧縮は品質のハードルが比較的緩い要約タスクです(要約を読み返すのはエージェントであってユーザーではありません)。DeepSeek-V4-Pro / Qwen3-Coder はこのタスクで Sonnet と誤差範囲に収まる一方、コストは約 10 分の 1 です。プレミアム階層のモデルは、あなたが直接読むクエリに取っておきましょう。
1129
-
1130
- 出典:[OpenRouter の Sonnet 4.6 価格](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek の価格に関する注](https://api-docs.deepseek.com/quick_start/pricing/)。
1131
-
1132
- ### マルチエージェントメモリ(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1133
-
1134
- 複数のロール(architect / developer / reviewer / researcher / support-agent)が 1 つの agentmemory サーバーを共有するマルチエージェント構成では、`AGENT_ID` がすべての書き込みに発信したロールのタグを付けます。`AGENTMEMORY_AGENT_SCOPE` はリコールがそのタグでフィルタするかどうかを制御します。
1135
-
1136
- ```env
1137
- TEAM_ID=company
1138
- USER_ID=engineering-team
1139
- AGENT_ID=architect
1140
- AGENTMEMORY_AGENT_SCOPE=isolated # 任意、デフォルトは "shared"
1141
- ```
1142
-
1143
- 2 つのモード:
1144
-
1145
- | モード | 書き込みにタグ | リコールでフィルタ | 使いどころ |
1146
- |------|------------|---------------|-------------|
1147
- | `shared`(デフォルト) | はい | いいえ | 監査証跡付きのクロスエージェントコンテキスト。Architect は developer のメモを見られるが、各行に発言者が記録されます。 |
1148
- | `isolated` | はい | はい | 厳格分離。Architect は developer の観測 / メモリ / セッションを決して見られません。 |
1149
-
1150
- `AGENT_ID` が設定されたときにタグ付けされるもの:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。ロールは `api::session::start` → `mem::observe` → `mem::compress` → KV を流れます。
1151
-
1152
- isolated モードでフィルタされるもの:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。各エンドポイントはリクエスト単位でオーバーライドする `?agentId=<role>` を受け付け、`?agentId=*` で環境スコープから完全にオプトアウトできます。`/memories` はさらに `?includeOrphans=true` を受け付け、`agentId` が undefined の AGENT_ID 導入前のメモリを浮上させます。
1153
-
1154
- SDK / REST 層での呼び出し単位オーバーライド: すべての変更系エンドポイント(`/session/start`、`/remember`)はリクエストボディに `agentId` フィールドを受け付け、環境変数より優先されます。1 つのサーバープロセス経由で多数のロールをルーティングするランタイムに便利です。
1155
-
1156
- `AGENT_ID` が未設定の場合、メモリはスコープなしのまま(従来の挙動、タグなし・フィルタなし)。
1157
-
1158
- ### ポート
1159
-
1160
- agentmemory + iii-engine はデフォルトで 4 つのポートをバインドします。再起動が `port in use` で失敗する場合、この表でどのプロセスを探せばよいか分かります。
1161
-
1162
- | ポート | プロセス | 用途 | 環境変数で上書き |
1163
- |------|---------|---------|--------------|
1164
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1165
- | `3112` | iii-engine | 内部ストリーム worker(agentmemory + ビューワーが消費) | `III_STREAMS_PORT` |
1166
- | `3113` | agentmemory | リアルタイムビューワー(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1167
- | `49134` | iii-engine | WebSocket — worker はここに登録、OTel テレメトリもここを流れる | `III_ENGINE_URL`(完全 URL、デフォルト `ws://localhost:49134`) |
1168
-
1169
- クラッシュ後にポートが解放されないときの古いプロセス整理:
1170
-
1171
- ```bash
1172
- # macOS / Linux — 各ポートで動いているものを探して kill
1173
- lsof -i :3111,3112,3113,49134
1174
- pkill -f agentmemory || true
1175
- pkill -f 'iii ' || true
1176
-
1177
- # Windows
1178
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1179
- taskkill /F /PID <pid>
1180
- ```
1181
-
1182
- `agentmemory stop` は正常終了時に worker と engine の pidfile を綺麗に回収します(#640、#474)。上の手動クリーンアップは、どちらの pidfile も残っていないクラッシュ後の状態を対象とします。
1183
-
1184
- ### 設定ファイル
1185
-
1186
- agentmemory のランタイム設定は、各シェルで変数を export するのではなく `~/.agentmemory/.env` に置いてください。ビューワーが `export ANTHROPIC_API_KEY=...` のようなセットアップヒントを表示したら、これをこのファイルに `ANTHROPIC_API_KEY=...` として(`export` プレフィックスなしで)コピーしてから agentmemory を再起動してください。
1187
-
1188
- プロセスの環境変数も引き続き有効で、ファイルの値より優先されます。
1189
-
1190
- Windows では同じファイルが `%USERPROFILE%\.agentmemory\.env` にあります:
1191
-
1192
- ```powershell
1193
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1194
- notepad $HOME\.agentmemory\.env
1195
- ```
1196
-
1197
- API キーの代わりに Claude Code Pro/Max 購読でテストするには、明示的にオプトイン:
1198
-
1199
- ```env
1200
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1201
- AGENTMEMORY_AUTO_COMPRESS=true
1202
- ```
1203
-
1204
- グラフや統合の機能を使いたい場合は同じファイルでオン:
1205
-
1206
- ```env
1207
- GRAPH_EXTRACTION_ENABLED=true
1208
- CONSOLIDATION_ENABLED=true
1209
- ```
1210
-
1211
- ### 環境変数
1212
-
1213
- `~/.agentmemory/.env` を作成:
1214
-
1215
- ```env
1216
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1217
- # ANTHROPIC_API_KEY=sk-ant-...
1218
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1219
- # GEMINI_API_KEY=...
1220
- # OPENROUTER_API_KEY=...
1221
- # MINIMAX_API_KEY=...
1222
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1223
- # # OpenAI LLM provider (here) AND the OpenAI
1224
- # # embedding provider (further below). Set
1225
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1226
- # # to embeddings only.
1227
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1228
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1229
- # # Auto-detected from `.openai.azure.com` hostname; uses
1230
- # # api-key header + api-version query param.
1231
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1232
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1233
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1234
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1235
- # # for back-compat with v0.9.17. New configs should
1236
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1237
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1238
- # # Honored only by OpenAI's reasoning models (o1, o3,
1239
- # # gpt-*-reasoning) and providers that mirror that
1240
- # # schema (Ollama Cloud thinking models). Standard
1241
- # # chat models reject this field with 400. Set to
1242
- # # "none" for thinking models that return reasoning
1243
- # # but no content.
1244
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1245
- # # for LLM (useful if you only want OpenAI for embeddings)
1246
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1247
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1248
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1249
-
1250
- # Embedding provider (auto-detected, or override)
1251
- # EMBEDDING_PROVIDER=local
1252
- # VOYAGE_API_KEY=...
1253
- # OPENAI_API_KEY=sk-...
1254
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1255
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1256
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1257
-
1258
- # Outbound LLM / embedding timeout
1259
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1260
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1261
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1262
- # embedding). For the OpenAI LLM path, the
1263
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1264
- # takes precedence when set, for back-compat
1265
- # with v0.9.17.
1266
- # Increase for slow networks or large batch calls;
1267
- # decrease to fail-fast on rate-limit holds.
1268
-
1269
- # Search tuning
1270
- # BM25_WEIGHT=0.4
1271
- # VECTOR_WEIGHT=0.6
1272
- # TOKEN_BUDGET=2000
1273
-
1274
- # Auth
1275
- # AGENTMEMORY_SECRET=your-secret
1276
-
1277
- # Ports (defaults: 3111 API, 3113 viewer)
1278
- # III_REST_PORT=3111
1279
-
1280
- # Features
1281
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1282
- # every PostToolUse hook calls your
1283
- # LLM provider to compress the
1284
- # observation — expect significant
1285
- # token spend on active sessions.
1286
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1287
- # memory slots — persona,
1288
- # user_preferences, tool_guidelines,
1289
- # project_context, guidance,
1290
- # pending_items, session_patterns,
1291
- # self_notes. Size-limited; agent
1292
- # edits via memory_slot_* tools.
1293
- # Pinned slots addressable for
1294
- # SessionStart injection.
1295
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1296
- # Stop hook fires mem::slot-reflect:
1297
- # scans recent observations, auto-
1298
- # appends TODOs to pending_items,
1299
- # counts patterns in
1300
- # session_patterns, records touched
1301
- # files in project_context. Fire-
1302
- # and-forget; does not block.
1303
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1304
- # - SessionStart may inject ~1-2K
1305
- # chars of project context into
1306
- # the first turn of each session
1307
- # (this is what actually reaches
1308
- # the model — Claude Code treats
1309
- # SessionStart stdout as context)
1310
- # - PreToolUse fires /agentmemory/enrich
1311
- # on every file-touching tool call
1312
- # (resource cleanup, not a token
1313
- # fix — PreToolUse stdout is debug
1314
- # log only per Claude Code docs)
1315
- # Observations are still captured via
1316
- # PostToolUse regardless of this flag.
1317
- # GRAPH_EXTRACTION_ENABLED=false
1318
- # CONSOLIDATION_ENABLED=true
1319
- # LESSON_DECAY_ENABLED=true
1320
- # OBSIDIAN_AUTO_EXPORT=false
1321
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1322
- # CLAUDE_MEMORY_BRIDGE=false
1323
- # SNAPSHOT_ENABLED=false
1324
-
1325
- # Team
1326
- # TEAM_ID=
1327
- # USER_ID=
1328
- # TEAM_MODE=private
1329
-
1330
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1331
- # AGENTMEMORY_TOOLS=core
1332
- ```
1333
-
1334
- ---
1335
-
1336
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1337
-
1338
- ポート `3111` 上の 124 エンドポイント。REST API はデフォルトで `127.0.0.1` にバインドします。`AGENTMEMORY_SECRET` が設定されている場合、保護されたエンドポイントは `Authorization: Bearer <secret>` を要求し、mesh sync エンドポイントは両ピアで `AGENTMEMORY_SECRET` を要求します。
1339
-
1340
- <details>
1341
- <summary>主要エンドポイント</summary>
1342
-
1343
- | メソッド | パス | 説明 |
1344
- |--------|------|-------------|
1345
- | `GET` | `/agentmemory/health` | ヘルスチェック(常に公開) |
1346
- | `POST` | `/agentmemory/session/start` | セッシ���ン開始 + コンテキスト取得 |
1347
- | `POST` | `/agentmemory/session/end` | セッション終了 |
1348
- | `POST` | `/agentmemory/observe` | 観測キャプチャ |
1349
- | `POST` | `/agentmemory/smart-search` | ハイブリッド検索 |
1350
- | `POST` | `/agentmemory/context` | コンテキスト生成 |
1351
- | `POST` | `/agentmemory/remember` | 長期メモリに保存 |
1352
- | `POST` | `/agentmemory/forget` | 観測の削除 |
1353
- | `POST` | `/agentmemory/enrich` | ファイルコンテキスト + メモリ + bug |
1354
- | `GET` | `/agentmemory/profile` | プロジェクトプロファイル |
1355
- | `GET` | `/agentmemory/export` | 全データをエクスポート |
1356
- | `POST` | `/agentmemory/import` | JSON からインポート |
1357
- | `POST` | `/agentmemory/graph/query` | ナレッジグラフ照会 |
1358
- | `POST` | `/agentmemory/team/share` | チームと共有 |
1359
- | `GET` | `/agentmemory/audit` | 監査証跡 |
1360
-
1361
- 完全なエンドポイント一覧:[`src/triggers/api.ts`](../src/triggers/api.ts)
1362
-
1363
- </details>
1364
-
1365
- ---
1366
-
1367
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1368
-
1369
- ```bash
1370
- npm run dev # ホットリロード
1371
- npm run build # 本番ビルド
1372
- npm test # 950+ テスト
1373
- npm run test:integration # API テスト(サービス起動が必要)
1374
- ```
1375
-
1376
- **前提:** Node.js >= 20、[iii-engine](https://iii.dev/docs) または Docker
1377
-
1378
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1379
-
1380
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.ko-KR.md DELETED
@@ -1,1361 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — AI 코딩 에이전트를 위한 영구 메모리" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- 코딩 에이전트가 모든 것을 기억합니다. 더 이상 다시 설명할 필요가 없습니다.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode 및 모든 MCP 클라이언트를 위한 영구 메모리입니다.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- 한국어 |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="설계 문서: gist 기준 1200 stars / 172 forks" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>이 gist는 Karpathy의 LLM Wiki 패턴을 신뢰도 점수, 라이프사이클, 지식 그래프, 하이브리드 검색으로 확장한 것입니다. agentmemory는 그 구현체입니다.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory 데모" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">설치</a> &bull;
73
- <a href="#quick-start">빠른 시작</a> &bull;
74
- <a href="#benchmarks">벤치마크</a> &bull;
75
- <a href="#vs-competitors">경쟁 제품 비교</a> &bull;
76
- <a href="#works-with-every-agent">에이전트</a> &bull;
77
- <a href="#how-it-works">동작 방식</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">뷰어</a> &bull;
80
- <a href="#iii-console">iii Console</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">설정</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Install
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # start the memory server on :3111
95
- agentmemory demo # seed sample sessions + prove recall
96
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- 또는 `npx`로 설치 없이 실행:
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- 참고 — npx는 버전별로 캐싱합니다. 단순한 `npx @agentmemory/agentmemory`가 이전 릴리스를 제공한다면, `npx -y @agentmemory/agentmemory@latest`로 최신 버전을 강제로 가져오거나 `rm -rf ~/.npm/_npx`로 캐시를 한 번 비우십시오(macOS/Linux. Windows에서는 `%LOCALAPPDATA%\npm-cache\_npx`를 삭제). v0.9.16부터의 첫 npx 실행은 전역 설치 여부를 인라인으로 묻기 때문에, 이후에는 어디서나 단순한 `agentmemory` 명령이 동작합니다.
106
-
107
- 전체 옵션은 아래 [빠른 시작](#quick-start)을 참고하십시오. 에이전트별 연결 방법은 [모든 에이전트와 호환](#works-with-every-agent) 섹션에서 확인할 수 있습니다.
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="모든 에이전트와 호환" height="32" /></picture></h2>
112
-
113
- agentmemory는 hooks, MCP, REST API를 지원하는 모든 에이전트와 호환됩니다. 모든 에이전트는 동일한 메모리 서버를 공유합니다.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>native plugin + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>native plugin + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>native plugin + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>native plugin + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>native plugin + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>native Memory trait backend</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP server</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP server</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP server</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP server</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP server</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP server</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP server</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP server</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>MCP 또는 HTTP를 지원하는 <strong>모든</strong> 에이전트와 호환됩니다. 서버 하나, 모든 에이전트가 메모리를 공유합니다.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- 세션마다 같은 아키텍처를 설명하고, 같은 버그를 다시 찾고, 같은 선호 사항을 다시 가르치게 됩니다. 내장 메모리(CLAUDE.md, .cursorrules)는 200줄 한도에서 멈추고 금세 낡습니다. agentmemory가 이 문제를 해결합니다. 에이전트의 동작을 조용히 캡처하여 검색 가능한 메모리로 압축하고, 다음 세션이 시작될 때 적절한 컨텍스트를 주입합니다. 명령 하나면 됩니다. 모든 에이전트에서 동작합니다.
209
-
210
- **무엇이 바뀌는가:** 세션 1에서 JWT 인증을 설정합니다. 세션 2에서 rate limiting을 요청합니다. 에이전트는 이미 인증이 `src/middleware/auth.ts`의 jose 미들웨어로 처리된다는 것, 테스트가 토큰 검증을 다룬다는 것, 그리고 Edge 호환성 때문에 jsonwebtoken 대신 jose를 선택했다는 것을 알고 있습니다. 다시 설명할 필요도, 복사·붙여넣기도 필요 없습니다. 에이전트가 그냥 *알고* 있습니다.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0의 새로운 기능** — [agent-memory.dev](https://agent-memory.dev)의 랜딩 사이트, 파일시스템 커넥터(`@agentmemory/fs-watcher`), 독립형 MCP가 이제 실행 중인 서버로 프록시되어 hooks와 뷰어가 일치합니다. 모든 삭제 경로에 감사 정책이 코드로 명문화되었고, 작은 Node 프로세스에서 health가 `memory_critical`로 잘못 표시되지 않습니다. 전체 노트는 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)에서 확인할 수 있습니다.
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="벤치마크" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### 검색 정확도
227
-
228
- **coding-agent-life-v1** (자체 코퍼스, 샌드박스 재현 가능)
229
-
230
- | 어댑터 | P@5 | R@5 | Top-5 적중률 | p50 지연 |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- Top-5 적중률 100%. 동일한 입력에서 grep 기준선 대비 정밀도가 **2.2배** 더 높습니다. 유형별 전체 분석은 다음에서 확인할 수 있습니다: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500개 질문)
238
-
239
- | 시스템 | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### 토큰 절감
248
-
249
- | 방식 | 연간 토큰 | 연간 비용 |
250
- |---|---|---|
251
- | 전체 컨텍스트를 매번 붙여넣기 | 19.5M+ | 불가능(컨텍스트 윈도우 초과) |
252
- | LLM 요약 | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + 로컬 임베딩 | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > 임베딩 모델: `all-MiniLM-L6-v2` (로컬, 무료, API 키 불필요). 전체 보고서: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). 경쟁 제품 비교: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 대 mem0, Letta, Khoj, claude-mem, Hippo.
261
-
262
- **로컬 재현 방법:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s`(공개 500-Q)와 `coding-agent-life-v1`(자체 15-세션 코퍼스)을 위한 어댑터 플러그형 하니스. grep / vector / agentmemory 어댑터를 나란히 평가하고, NDJSON으로 출력하며, 게시된 스코어카드는 [`docs/benchmarks/`](../docs/benchmarks/)에 보관됩니다.
263
-
264
- **다음과 함께 사용하기 좋습니다: [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), [Graphify](https://github.com/safishamsi/graphify).** 코드 그래프 인덱싱, 멀티 에이전트 빌드 파이프라인, 그리고 docs/PDF/이미지/비디오에 걸친 더 넓은 지식 그래프. agentmemory는 작업을 기억하고, 이 세 프로젝트는 나머지 컨텍스트 레이어를 밝혀줍니다. 레시피와 질문 라우팅 표: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="경쟁 제품 비교" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">내장 메모리 (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>유형</strong></td>
280
- <td>메모리 엔진 + MCP 서버</td>
281
- <td>메모리 레이어 API</td>
282
- <td>완전한 에이전트 런타임</td>
283
- <td>정적 파일</td>
284
- </tr>
285
- <tr>
286
- <td><strong>검색 R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>해당 없음 (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>자동 캡처</strong></td>
294
- <td>12 hooks (수동 작업 없음)</td>
295
- <td>수동 <code>add()</code> 호출</td>
296
- <td>에이전트 자체 편집</td>
297
- <td>수동 편집</td>
298
- </tr>
299
- <tr>
300
- <td><strong>검색</strong></td>
301
- <td>BM25 + Vector + Graph (RRF 융합)</td>
302
- <td>Vector + Graph</td>
303
- <td>Vector (archival)</td>
304
- <td>모든 것을 컨텍스트에 로드</td>
305
- </tr>
306
- <tr>
307
- <td><strong>멀티 에이전트</strong></td>
308
- <td>MCP + REST + leases + signals</td>
309
- <td>API (조정 없음)</td>
310
- <td>Letta 런타임 내에서만</td>
311
- <td>에이전트별 파일</td>
312
- </tr>
313
- <tr>
314
- <td><strong>프레임워크 종속성</strong></td>
315
- <td>없음 (모든 MCP 클라이언트)</td>
316
- <td>없음</td>
317
- <td>높음 (Letta 사용 필수)</td>
318
- <td>에이전트별 포맷</td>
319
- </tr>
320
- <tr>
321
- <td><strong>외부 의존성</strong></td>
322
- <td>없음 (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + 벡터 DB</td>
325
- <td>없음</td>
326
- </tr>
327
- <tr>
328
- <td><strong>메모리 라이프사이클</strong></td>
329
- <td>4-tier 통합 + 감쇠 + 자동 망각</td>
330
- <td>수동적 추출</td>
331
- <td>에이전트 관리</td>
332
- <td>수동 정리</td>
333
- </tr>
334
- <tr>
335
- <td><strong>토큰 효율</strong></td>
336
- <td>세션당 ~1,900 토큰 ($10/년)</td>
337
- <td>통합 방식에 따라 다름</td>
338
- <td>핵심 메모리는 컨텍스트에 상주</td>
339
- <td>관측 240개 기준 22K+ 토큰</td>
340
- </tr>
341
- <tr>
342
- <td><strong>실시간 뷰어</strong></td>
343
- <td>있음 (port 3113)</td>
344
- <td>클라우드 대시보드</td>
345
- <td>클라우드 대시보드</td>
346
- <td>없음</td>
347
- </tr>
348
- <tr>
349
- <td><strong>셀프 호스팅</strong></td>
350
- <td>예 (기본)</td>
351
- <td>선택 사항</td>
352
- <td>선택 사항</td>
353
- <td>예</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="빠른 시작" height="32" /></picture></h2>
360
-
361
- 호환성: 이 릴리스는 안정 버전 `iii-sdk` `^0.11.0`과 iii-engine v0.11.x를 대상으로 합니다.
362
-
363
- ### 30초 만에 사용해 보기
364
-
365
- ```bash
366
- # Terminal 1: start the server
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: seed sample data and see recall in action
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo`는 현실적인 세션 3개(JWT 인증, N+1 쿼리 수정, rate limiting)를 시드하고, 그 위에서 시맨틱 검색을 실행합니다. "database performance optimization"으로 검색하면 "N+1 query fix"를 찾는 것을 확인할 수 있는데, 키워드 매칭으로는 불가능한 결과입니다.
374
-
375
- `http://localhost:3113`을 열어서 메모리가 실시간으로 쌓이는 것을 지켜보십시오.
376
-
377
- ### 권장: 전역 설치
378
-
379
- `npx`는 버전별로 캐싱합니다. 지난주에 `npx @agentmemory/agentmemory@0.9.14`를 실행했다면, 단순한 `npx @agentmemory/agentmemory`는 최신 릴리스가 아니라 `~/.npm/_npx/`에 캐시된 0.9.14를 제공할 수 있습니다. 한 번 설치하면 단순한 `agentmemory` 명령이 어디서나 동작합니다:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # start the server (same as the npx form)
386
- agentmemory stop # tear it down
387
- agentmemory remove # uninstall everything we created
388
- agentmemory connect claude-code # wire one agent
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- v0.9.16 이후부터 첫 npx 실행은 인라인으로 전역 설치 여부를 묻습니다 — `Y`로 한 ���만 답하면 설정이 끝납니다. 만약 건너뛰었다면, 새로 가져오기 위해 다음 중 하나를 사용하십시오:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
- ```
398
-
399
- Windows / PowerShell에서 동일한 캐시 비우기는 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"`입니다 — 위의 `npx -y ...@latest`가 크로스 플랫폼 옵션입니다.
400
-
401
- ### 세션 리플레이
402
-
403
- agentmemory가 기록한 모든 세션은 재생 가능합니다. 뷰어를 열어 **Replay** 탭을 선택하고 타임라인을 스크럽하면 프롬프트, 도구 호출, 도구 결과, 응답이 별개의 이벤트로 렌더링됩니다. 재생/일시정지, 속도 제어(0.5×–4×), 키보드 단축키(space로 토글, 화살표로 단계 이동)를 모두 지원합니다.
404
-
405
- 가져오고 싶은 기존 Claude Code JSONL 트랜스크립트가 있습니까?
406
-
407
- ```bash
408
- # Import everything under the default ~/.claude/projects
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Or import a single file
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- 가져온 세션은 네이티브 세션과 함께 Replay 선택기에 표시됩니다. 내부적으로 각 항목은 `mem::replay::load`, `mem::replay::sessions`, `mem::replay::import-jsonl` iii 함수로 라우팅됩니다 — 별도의 사이드 채널 서버 없이.
416
-
417
- ### 업그레이드 / 유지보수
418
-
419
- 로컬 런타임을 의도적으로 업데이트할 때는 maintenance 명령을 사용하십시오:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- 경고: 이 명령은 현재 workspace/런타임을 변경합니다. JavaScript 의존성을 업데이트할 수 있으며, `cargo install iii-engine --force`를 실행할 수도 있고, Docker 이미지를 pull할 수도 있습니다.
426
-
427
- 구현 세부 사항은 `src/cli.ts`에 있습니다 (`runUpgrade`는 `src/cli.ts:544-595` 부근 참고).
428
-
429
- ### Claude Code (블록 한 번, 붙여넣기)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### 플러그인 설치 없이 Claude Code 사용 (MCP-독립형 경로)
436
-
437
- `/plugin install` 대신 `~/.claude.json`을 통해 agentmemory의 MCP 서버를 직접 연결한 경우, Claude Code는 `${CLAUDE_PLUGIN_ROOT}`를 해석하지 못하므로 `~/.claude/settings.json`의 hook 스크립트를 절대 경로로 지정해야 합니다. 이 경로들은 일반적으로 agentmemory 버전을 포함하기 때문에 (예: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), 다음 업그레이드에서 모든 hook이 조용히 깨질 수 있습니다 ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- 해결책:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- 이 명령은 현재 설치된 `@agentmemory/agentmemory` 패키지의 번들된 `plugin/` 디렉터리로 해석된 절대 경로로 동일한 hook 명령을 `~/.claude/settings.json`에 병합합니다. agentmemory를 업그레이드한 후 동일한 명령을 다시 실행하여 경로를 갱신하십시오. 동일한 파일의 사용자 항목은 보존되며, 이전 agentmemory 항목만 교체됩니다. `/plugin install` 경로를 사용하는 것이 여전히 권장 방식입니다.
446
- 원격 또는 보호된 배포의 경우, `AGENTMEMORY_URL`과 `AGENTMEMORY_SECRET`을 설정한 채로 Claude Code를 실행하십시오. 플러그인은 두 값을 모두 번들된 MCP 서버로 전달합니다. `AGENTMEMORY_URL`이 비어 있을 때는 MCP shim이 `http://localhost:3111`을 사용합니다.
447
-
448
- ### Codex CLI (Codex 플러그인 플랫폼)
449
-
450
- ```bash
451
- # 1. start the memory server in a separate terminal
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. register the agentmemory marketplace and install the plugin
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- Codex 플러그인은 Claude Code 플러그인과 동일한 `plugin/` 디렉터리에서 제공됩니다. 다음을 등록합니다:
460
-
461
- - `@agentmemory/mcp`를 MCP 서버로 등록 (`AGENTMEMORY_URL`이 실행 중인 agentmemory 서버를 가리킬 때 51개 도구 모두 프록시. 도달 가능한 서버가 없으면 로컬에서 7개 도구로 폴백)
462
- - 6개 라이프사이클 hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4개 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- Codex��� hook 엔진은 hook 서브프로세스에 `CLAUDE_PLUGIN_ROOT`를 주입하므로 ([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs) 참고), 동일한 hook 스크립트가 중복 없이 두 호스트에서 모두 동작합니다. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 이벤트는 Claude Code 전용이며 Codex에는 등록되지 않습니다.
466
-
467
- #### Codex Desktop: 플러그인 hooks가 현재 동작하지 않음 (해결책 있음)
468
-
469
- `CodexHooks`와 `PluginHooks`는 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs)에서 모두 안정 + 기본 활성화 상태이지만, 현재 Codex Desktop 빌드는 플러그인-로컬 `hooks.json`을 디스패치하지 않습니다 ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP 도구는 여전히 동작합니다. 라이프사이클 관측만 누락됩니다.
470
-
471
- 업스트림 수정이 적용될 때까지 동일한 hook 명령을 전역 `~/.codex/hooks.json`에 미러링하십시오:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- 이 명령은 번들된 스크립트의 절대 경로를 참조하는 idempotent 블록을 `~/.codex/hooks.json`에 추가합니다(사용자 스코프에서 `${CLAUDE_PLUGIN_ROOT}` 확장이 필요 없음). agentmemory를 업그레이드한 후 동일한 명령을 다시 실행하여 경로를 갱신하십시오. 동일한 파일의 사용자 항목은 보존되며, 이전 agentmemory 항목만 교체됩니다.
478
-
479
- <details>
480
- <summary><b>OpenClaw (이 프롬프트를 붙여넣으세요)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- 전체 가이드: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (이 프롬프트를 붙여넣으세요)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- 전체 가이드: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### 다른 에이전트
526
-
527
- 메모리 서버 시작: `npx @agentmemory/agentmemory`
528
-
529
- agentmemory 항목은 `mcpServers` 형태를 사용하는 모든 호스트(Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw)에서 **동일한 MCP 서버 블록**입니다:
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **호스트 설정 파일의 기존 `mcpServers` 객체에 이 항목을 병합하십시오** — 파일 전체를 교체하지 마십시오. 파일에 이미 다른 서버가 있다면, `agentmemory`를 `mcpServers` 안의 또 다른 키로 옆에 추가하십시오. `mcpServers` 자체가 없다면 `{ "mcpServers": { ... } }` 안에 블록을 붙여넣으십시오. `${VAR}` 자리표시자는 MCP 서버 실행 시 셸에서 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET`을 상속합니다 — 설정되지 않은 변수는 빈 문자열로 전달되며 shim은 `http://localhost:3111`로 폴백합니다. 한 번 연결한 항목으로 로컬과 원격(k8s / 리버스 프록시) 배포를 모두 커버합니다.
543
-
544
- | 에이전트 | 설정 파일 | 비고 |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | `mcpServers`에 병합. 웹사이트에서 원클릭 deeplink도 사용 가능. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers`에 병합. 편집 후 Claude Desktop 재시작. |
548
- | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | 동일한 `mcpServers` ��록. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 동일한 `mcpServers` 블록. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (자동 병합). |
551
- | **OpenClaw** | OpenClaw MCP config | 동일한 `mcpServers` 블록을 사용하거나, 더 깊은 [memory plugin](../integrations/openclaw/)을 사용. |
552
- | **Codex CLI (MCP only)** | `.codex/config.toml` | TOML 형식: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, 또는 `[mcp_servers.agentmemory]`를 수동으로 추가. |
553
- | **Codex CLI (full plugin)** | Codex 플러그인 마켓플레이스 | `codex plugin marketplace add rohitg00/agentmemory` 후 `codex plugin add agentmemory@agentmemory`. MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills 등록. Codex Desktop에서는 [openai/codex#16430](https://github.com/openai/codex/issues/16430)이 머지될 때까지 `agentmemory connect codex --with-hooks`도 실행해야 합니다 — 현재 그곳에서는 플러그인 hooks가 동작하지 않습니다. |
554
- | **OpenCode (MCP only)** | `opencode.json` | 다른 형식 — 최상위 `mcp` 키, 명령은 배열로: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (full plugin)** | `plugin/opencode/` | 세션 라이프사이클, 메시지, 도구, 오류를 다루는 22개의 자동 캡처 hooks. 두 개의 슬래시 명령(`/recall`, `/remember`). `plugin/opencode/`를 OpenCode workspace에 복사한 후 `opencode.json`에 플러그인 항목을 추가하십시오. 전체 hook 표 + gap 분석은 [`plugin/opencode/README.md`](../plugin/opencode/README.md) 참고. |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/)를 복사하고 pi를 재시작. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | `memory.provider: agentmemory`로 더 깊은 [memory provider plugin](../integrations/hermes/) 사용. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen`이 표준 `mcpServers` 블록을 기록. Hook 페이로드는 Claude Code와 필드 호환이므로, 기존 12-hook 스크립트가 수정 없이 동작합니다 — 동일한 `settings.json`의 `hooks` 섹션에서 연결. |
559
- | **Antigravity** (Gemini CLI 대체) | `mcp_config.json` (Antigravity의 User 디렉터리 내) | `agentmemory connect antigravity`가 표준 `mcpServers` 블록을 기록. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. 2026-06-18 Gemini CLI sunset 이후 사용. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro`가 사용자 레벨 설정을 기록. 워크스페이스 오버라이드는 코드 옆 `.kiro/settings/mcp.json`에. |
561
- | **Goose** | Goose MCP settings UI | 동일한 `mcpServers` 블록. |
562
- | **Aider** | n/a | REST API와 직접 통신: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **모든 에이전트 (32+)** | n/a | `npx skillkit install agentmemory`가 호스트를 자동 감지하고 병합. |
564
-
565
- **샌드박스된 MCP 클라이언트**(Flatpak / Snap / 제한적인 컨테이너 등)가 호스트의 `localhost`에 도달할 수 없는 경우: `env` 블록에 `"AGENTMEMORY_FORCE_PROXY": "1"`도 설정하고, `AGENTMEMORY_URL`을 샌드박스가 실제로 도달 가능한 경로(예: LAN IP)로 지정하십시오. 진단 가이드는 [#234](https://github.com/rohitg00/agentmemory/issues/234)를 참고하십시오.
566
-
567
- ### 프로그래매틱 액세스 (Python / Rust / Node)
568
-
569
- agentmemory는 핵심 작업을 iii 함수(`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`)로 등록합니다. iii SDK가 있는 모든 언어에서 `ws://localhost:49134`로 직접 호출할 수 있습니다 — 언어별 별도의 REST 클라이언트가 필요하지 않습니다.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- 작동 예제: [`examples/python/`](../examples/python/) (퀵스타트 + 관측/리콜 흐름). iii 런타임이 없는 호스트를 위해 `:3111`의 REST는 그대로 사용 가능합니다.
590
-
591
- ### 소스에서 빌드
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- `iii`가 이미 설치되어 있으면 로컬 `iii-engine`으로 agentmemory를 시작하고, Docker가 사용 가능하면 Docker Compose로 폴백합니다. REST, 스트림, 뷰어는 기본적으로 `127.0.0.1`에 바인딩됩니다.
599
-
600
- `iii-engine`을 수동으로 설치하십시오. **agentmemory는 현재 `iii-engine`을 `v0.11.2`로 고정합니다** — `v0.11.6`은 모든 것을 `iii worker add`를 통해 샌드박스화하는 새 모델을 도입했는데 agentmemory는 아직 이를 위해 리팩터링되지 않았기 때문입니다. 리팩터링이 완료되면 고정이 풀립니다. 수동으로 sandbox 모델로 마이그레이션했다면 `AGENTMEMORY_III_VERSION=<version>`으로 덮어쓰십시오.
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** `aarch64-apple-darwin`을 `x86_64-apple-darwin`으로 교체
604
- - **Linux x64:** `x86_64-unknown-linux-gnu`로 교체
605
- - **Linux arm64:** `aarch64-unknown-linux-gnu`로 교체
606
- - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2)에서 `iii-x86_64-pc-windows-msvc.zip`을 다운로드하고 `iii.exe`를 추출한 후 PATH에 추가
607
-
608
- 또는 Docker 사용 (번들된 `docker-compose.yml`이 `iiidev/iii:0.11.2`를 pull). 전체 문서: [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory는 Windows 10/11에서 실행되지만, Node.js 패키지만으로는 충분하지 않습니다 — 별도의 네이티브 바이너리인 `iii-engine` 런타임이 백그라운드 프로세스로 필요합니다. 공식 업스트림 인스톨러는 `sh` 스크립트이고 PowerShell 인스톨러나 scoop/winget 패키지는 현재 없으므로, Windows 사용자에게는 두 가지 경로가 있습니다:
613
-
614
- **옵션 A — 사전 빌드된 Windows 바이너리 (권장):**
615
-
616
- ```powershell
617
- # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
- # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
- # model that engine v0.11.6+ requires)
620
- # 2. Download iii-x86_64-pc-windows-msvc.zip
621
- # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
- # 3. Extract iii.exe somewhere on PATH, or place it at:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory checks that location automatically)
625
- # 4. Verify:
626
- iii --version
627
- # Should print: 0.11.2
628
-
629
- # 5. Then run agentmemory as usual:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **옵션 B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Install Docker Desktop for Windows
637
- # 2. Start Docker Desktop and make sure the engine is running
638
- # 3. Run agentmemory — it will auto-start the bundled compose file:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **옵션 C — 독립형 MCP만 사용 (엔진 없음):** 에이전트용 MCP 도구만 필요하고 REST API, 뷰어, cron 작업이 필요하지 않다면 엔진을 완전히 건너뛸 수 있습니다:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # or via the shim package:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Windows 진단:** `npx @agentmemory/agentmemory`가 실패하면 `--verbose`로 다시 실행하여 실제 엔진 stderr를 확인하십시오. 일반적인 실패 모드:
651
-
652
- | 증상 | 해결 방법 |
653
- |---|---|
654
- | `iii-engine process started`가 표시된 후 `did not become ready within 15s` | 엔진이 시작 시 충돌함 — `--verbose`로 다시 실행하여 stderr 확인 |
655
- | `Could not start iii-engine` | `iii.exe`도 Docker도 설치되어 있지 않음. 위의 옵션 A 또는 B 참고 |
656
- | 포트 충돌 | `netstat -ano \| findstr :3111`로 무엇이 바인딩되어 있는지 확인하고 종료하거나 `--port <N>` 사용 |
657
- | Docker가 설치되어 있어도 Docker 폴백을 건너뜀 | Docker Desktop이 실제로 실행 중인지 확인 (시스템 트레이 아이콘) |
658
-
659
- > 참고: `cargo install iii-engine`는 없습니다 — `iii`는 crates.io에 게시되지 않았습니다. 지원되는 설치 방법은 위의 사전 빌드된 바이너리, 업스트림 `sh` 설치 스크립트(macOS/Linux 전용), Docker 이미지뿐입니다.
660
-
661
- ---
662
-
663
- <h2 id="deploy">배포</h2>
664
-
665
- 매니지드 호스트용 원클릭 템플릿입니다. 각각은 npm에서 `@agentmemory/agentmemory`를 가져오고 공식 `iiidev/iii` Docker Hub 이미지에서 iii 엔진 바이너리를 복사하는 자체 완결형 Dockerfile을 제공합니다 — 사전 빌드된 agentmemory 이미지가 필요 없습니다. 영구 스토리지는 `/data`에 마운트되며, 첫 부팅 진입점은 npm 번들 iii 설정(`127.0.0.1`에 바인딩)을 `0.0.0.0`에 바인딩하고 절대 `/data` 경로를 사용하는 배포 튜닝 설정으로 덮어쓰고, HMAC 시크릿을 생성한 후, `gosu`를 통해 `root`에서 `node`로 권한을 낮춘 다음 agentmemory CLI를 exec합니다.
666
-
667
- <p>
668
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
669
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
670
- </p>
671
-
672
- Render의 원클릭 배포 버튼은 저장소 루트에 `render.yaml`이 필요한데, 우리는 의도적으로 이를 깨끗하게 유지합니다. [`deploy/render/`](../deploy/render/README.md)에 문서화된 Render Blueprint 플로우를 사용하여 in-repo blueprint를 수동으로 가리키도록 하십시오.
673
-
674
- 전체 설정 세부 사항(HMAC 캡처, 뷰어 SSH 터널, 로테이션, 백업, 비용 하한)은 [`deploy/`](../deploy/README.md)에 있습니다:
675
-
676
- - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"`으로 단일 머신; 유휴 비용이 가장 저렴.
677
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby 플랜 정액제, 볼륨은 대시보드에서.
678
- - [`deploy/render`](../deploy/render/README.md) — Blueprint 플로우, 유료 플랜에서 자동 디스크 스냅샷.
679
- - [`deploy/coolify`](../deploy/coolify/README.md) — [Coolify](https://coolify.io/self-hosted)를 통해 자체 VPS에 셀프 호스팅; 동일한 Docker Compose 스택, 호스트와 데이터를 직접 소유.
680
-
681
- `3111` 포트만 게시됩니다. `3113`의 뷰어는 컨테이너 내부에서 loopback에 바인딩된 채로 유지됩니다 — 각 템플릿의 README는 그곳에 도달하기 위한 SSH 터널 패턴을 문서화합니다.
682
-
683
- ---
684
-
685
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="왜 agentmemory인가" height="32" /></picture></h2>
686
-
687
- 모든 코딩 에이전트는 세션이 끝나면 모든 것을 잊습니다. 매 세션의 첫 5분을 스택을 다시 설명하는 데 낭비합니다. agentmemory는 백그라운드에서 실행되어 이를 완전히 제거합니다.
688
-
689
- ```text
690
- Session 1: "Add auth to the API"
691
- Agent writes code, runs tests, fixes bugs
692
- agentmemory silently captures every tool use
693
- Session ends -> observations compressed into structured memory
694
-
695
- Session 2: "Now add rate limiting"
696
- Agent already knows:
697
- - Auth uses JWT middleware in src/middleware/auth.ts
698
- - Tests in test/auth.test.ts cover token validation
699
- - You chose jose over jsonwebtoken for Edge compatibility
700
- Zero re-explaining. Starts working immediately.
701
- ```
702
-
703
- ### 내장 에이전트 메모리와의 비교
704
-
705
- 모든 AI 코딩 에이전트는 내장 메모리와 함께 제공됩니다 — Claude Code에는 `MEMORY.md`가 있고, Cursor에는 notepad가, Cline에는 memory bank가 있습니다. 이들은 포스트잇처럼 동작합니다. agentmemory는 포스트잇 뒤에 있는 검색 가능한 데이터베이스입니다.
706
-
707
- | | 내장 (CLAUDE.md) | agentmemory |
708
- |---|---|---|
709
- | 규모 | 200줄 한도 | 무제한 |
710
- | 검색 | 모든 것을 컨텍스트에 로드 | BM25 + vector + graph (top-K만) |
711
- | 토큰 비용 | 관측 240개 기준 22K+ | ~1,900 토큰 (92% 적음) |
712
- | 크로스 에이전트 | 에이전트별 파일 | MCP + REST (모든 에이전트) |
713
- | 조정 | 없음 | leases, signals, actions, routines |
714
- | 가시성 | 파일 수동 읽기 | :3113의 실시간 뷰어 |
715
-
716
- ---
717
-
718
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="동작 방식" height="32" /></picture></h2>
719
-
720
- ### 메모리 파이프라인
721
-
722
- ```text
723
- PostToolUse hook fires
724
- -> SHA-256 dedup (5min window)
725
- -> Privacy filter (strip secrets, API keys)
726
- -> Store raw observation
727
- -> LLM compress -> structured facts + concepts + narrative
728
- -> Vector embedding (6 providers + local)
729
- -> Index in BM25 + vector
730
-
731
- Stop / SessionEnd hook fires
732
- -> Summarize session
733
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
734
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
735
-
736
- SessionStart hook fires
737
- -> Load project profile (top concepts, files, patterns)
738
- -> Hybrid search (BM25 + vector + graph)
739
- -> Token budget (default: 2000 tokens)
740
- -> Inject into conversation
741
- ```
742
-
743
- ### 4-Tier 메모리 통합
744
-
745
- 인간 뇌가 메모리를 처리하는 방식 — 수면 통합과 크게 다르지 않은 방식 — 에서 영감을 받았습니다.
746
-
747
- | Tier | 무엇 | 비유 |
748
- |------|------|---------|
749
- | **Working** | 도구 사용에서 나온 원시 관측 | 단기 기억 |
750
- | **Episodic** | 압축된 세션 요약 | "무슨 일이 있었는가" |
751
- | **Semantic** | 추출된 사실과 패턴 | "내가 아는 것" |
752
- | **Procedural** | 워크플로우와 의사 결정 패턴 | "그것을 하는 방법" |
753
-
754
- 메모리는 시간이 지나면서 감쇠합니다(Ebbinghaus 곡선). 자주 액세스하는 메모리는 강화됩니다. 오래된 메모리는 자동으로 축출됩니다. 모순은 감지되고 해결됩니다.
755
-
756
- ### 무엇이 캡처되는가
757
-
758
- | Hook | 캡처 내용 |
759
- |------|----------|
760
- | `SessionStart` | 프로젝트 경로, 세션 ID |
761
- | `UserPromptSubmit` | 사용자 프롬프트 (개인정보 필터링됨) |
762
- | `PreToolUse` | 파일 접근 패턴 + 풍부한 컨텍스트 |
763
- | `PostToolUse` | 도구 이름, 입력, 출력 |
764
- | `PostToolUseFailure` | 오류 컨텍스트 |
765
- | `PreCompact` | 컴팩션 전에 메모리 재주입 |
766
- | `SubagentStart/Stop` | 서브 에이전트 라이프사이클 |
767
- | `Stop` | 세션 종료 요약 |
768
- | `SessionEnd` | 세션 완료 마커 |
769
-
770
- ### 핵심 기능
771
-
772
- | 기능 | 설명 |
773
- |---|---|
774
- | **자동 캡처** | 모든 도구 사용을 hooks로 기록 — 수동 작업 없음 |
775
- | **시맨틱 검색** | BM25 + vector + 지식 그래프, RRF 융합 |
776
- | **메모리 진화** | 버저닝, supersession, 관계 그래프 |
777
- | **자동 망각** | TTL 만료, 모순 감지, 중요도 기반 축출 |
778
- | **개인정보 우선** | API 키, 시크릿, `<private>` 태그를 저장 전에 제거 |
779
- | **자가 치유** | 서킷 브레이커, 프로바이더 폴백 체인, 헬스 모니터링 |
780
- | **Claude 브리지** | MEMORY.md와의 양방향 동기화 |
781
- | **지식 그래프** | 엔티티 추출 + BFS 순회 |
782
- | **팀 메모리** | 팀원 간 namespaced 공유 + 비공개 |
783
- | **인용 출처 추적** | 모든 메모리를 원본 관측으로 추적 |
784
- | **Git 스냅샷** | 메모리 상태의 버전 관리, 롤백, 차이 비교 |
785
-
786
- ---
787
-
788
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="검색" height="32" /></picture></h2>
789
-
790
- 세 가지 신호를 결합한 트리플 스트림 검색:
791
-
792
- | 스트림 | 무엇을 하는가 | 언제 |
793
- |---|---|---|
794
- | **BM25** | 형태소 추출 키워드 매칭 + 동의어 확장 | 항상 활성 |
795
- | **Vector** | 밀집 임베딩 위의 코사인 유사도 | 임베딩 프로바이더 구성 시 |
796
- | **Graph** | 엔티티 매칭을 통한 지식 그래프 순회 | 쿼리에서 엔티티 감지 시 |
797
-
798
- Reciprocal Rank Fusion(RRF, k=60)으로 융합하고, 세션 다양화(세션당 최대 3개 결과)합니다.
799
-
800
- BM25는 기본적으로 그리스어, 키릴 문자, 히브리어, 아랍어, 강세 부호가 있는 라틴 문자를 토크나이즈합니다. 중국어 / 일본어 / 한국어 메모리의 경우 선택적 세그멘터(`npm install @node-rs/jieba tiny-segmenter`)를 설치하여 CJK 런을 단어 수준 토큰으로 분할하십시오. 설치하지 않으면 agentmemory는 전체 런 토크나이제이션으로 soft fallback하고 stderr에 일회성 힌트를 출력합니다.
801
-
802
- ### 임베딩 프로바이더
803
-
804
- agentmemory는 프로바이더를 자동 감지합니다. 최상의 결과를 위해 로컬 임베딩을 설치하십시오 (무료):
805
-
806
- ```bash
807
- npm install @xenova/transformers
808
- ```
809
-
810
- | 프로바이더 | 모델 | 비용 | 비고 |
811
- |---|---|---|---|
812
- | **Local (권장)** | `all-MiniLM-L6-v2` | 무료 | 오프라인, BM25-only 대비 +8pp recall |
813
- | Gemini | `gemini-embedding-001` | 무료 티어 | 100+ 언어, 768/1536/3072 dims (MRL), 2048-token 입력. `text-embedding-004`를 대체 ([deprecated, 2026년 1월 14일 종료](https://ai.google.dev/gemini-api/docs/deprecations)) |
814
- | OpenAI | `text-embedding-3-small` | $0.02/1M | 최고 품질 |
815
- | Voyage AI | `voyage-code-3` | 유료 | 코드 최적화 |
816
- | Cohere | `embed-english-v3.0` | 무료 평가판 | 범용 |
817
- | OpenRouter | 모든 모델 | 다양 | 멀티 모델 프록시 |
818
-
819
- ---
820
-
821
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP 서버" height="32" /></picture></h2>
822
-
823
- 53개 도구, 6개 리소스, 3개 프롬프트, 4개 skills — 모든 에이전트를 위한 가장 포괄적인 MCP 메모리 툴킷.
824
-
825
- > **MCP shim 대 전체 서버:** 게시된 `@agentmemory/mcp` 패키지는 얇은 shim입니다. `AGENTMEMORY_URL`을 통해 실행 중인 agentmemory 서버에 도달할 수 있을 때 **만** 전체 51-도구 표면을 노출합니다(프록시 모드). 도달 가능한 서버가 없으면 shim은 7-도구 로컬 세트(`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`)로 폴백합니다. `AGENTMEMORY_TOOLS=core|all` 환경 변수는 *서버 측* 플래그입니다 — shim의 `env` 블록에 설정해도 효과가 없습니다. Cursor / OpenCode / Gemini CLI에서 도구가 7개만 보인다면 `npx @agentmemory/agentmemory`(또는 Docker 스택)를 시작하고 `AGENTMEMORY_URL=http://localhost:3111`을 설정하십시오.
826
-
827
- ### 51개 도구
828
-
829
- <details>
830
- <summary>핵심 도구 (항상 사용 가능)</summary>
831
-
832
- | 도구 | 설명 |
833
- |------|-------------|
834
- | `memory_recall` | 과거 관측 검색 |
835
- | `memory_compress_file` | 구조를 유지하면서 markdown 파일 압축 |
836
- | `memory_save` | 통찰, 결정, 패턴 저장 |
837
- | `memory_patterns` | 반복 패턴 감지 |
838
- | `memory_smart_search` | 하이브리드 시맨틱 + 키워드 검색 |
839
- | `memory_file_history` | 특정 파일에 대한 과거 관측 |
840
- | `memory_sessions` | 최근 세션 목록 |
841
- | `memory_timeline` | 시간순 관측 |
842
- | `memory_profile` | 프로젝트 프로필 (개념, 파일, 패턴) |
843
- | `memory_export` | 모든 메모리 데이터 내보내기 |
844
- | `memory_relations` | 관계 그래프 쿼리 |
845
-
846
- </details>
847
-
848
- <details>
849
- <summary>확장 도구 (총 51개 — AGENTMEMORY_TOOLS=all 설정)</summary>
850
-
851
- | 도구 | 설명 |
852
- |------|-------------|
853
- | `memory_patterns` | 반복 패턴 감지 |
854
- | `memory_timeline` | 시간순 관측 |
855
- | `memory_relations` | 관계 그래프 쿼리 |
856
- | `memory_graph_query` | 지식 그래프 순회 |
857
- | `memory_consolidate` | 4-tier 통합 실행 |
858
- | `memory_claude_bridge_sync` | MEMORY.md와 동기화 |
859
- | `memory_team_share` | 팀원과 공유 |
860
- | `memory_team_feed` | 최근 공유 항목 |
861
- | `memory_audit` | 작업 감사 로그 |
862
- | `memory_governance_delete` | 감사 로그를 남기는 삭제 |
863
- | `memory_snapshot_create` | Git 버전 관리 스냅샷 |
864
- | `memory_action_create` | 의존성이 있는 작업 항목 생성 |
865
- | `memory_action_update` | 작업 상태 업데이트 |
866
- | `memory_frontier` | 우선순위로 정렬된 차단 해제된 작업 |
867
- | `memory_next` | 가장 중요한 다음 작업 하나 |
868
- | `memory_lease` | 독점 작업 leases (멀티 에이전트) |
869
- | `memory_routine_run` | 워크플로우 루틴 인스턴스화 |
870
- | `memory_signal_send` | 에이전트 간 메시징 |
871
- | `memory_signal_read` | 수신 확인이 있는 메시지 읽기 |
872
- | `memory_checkpoint` | 외부 조건 게이트 |
873
- | `memory_mesh_sync` | 인스턴스 간 P2P 동기화 |
874
- | `memory_sentinel_create` | 이벤트 기반 워처 |
875
- | `memory_sentinel_trigger` | 외부에서 sentinel 발화 |
876
- | `memory_sketch_create` | 일시적 작업 그래프 |
877
- | `memory_sketch_promote` | 영구로 승격 |
878
- | `memory_crystallize` | 작업 체인 압축 |
879
- | `memory_diagnose` | 헬스 체크 |
880
- | `memory_heal` | 정체된 상태 자동 수정 |
881
- | `memory_facet_tag` | dimension:value 태그 |
882
- | `memory_facet_query` | facet 태그로 쿼리 |
883
- | `memory_verify` | 출처 추적 |
884
-
885
- </details>
886
-
887
- ### 6 리소스 · 3 프롬프트 · 4 Skills
888
-
889
- | 유형 | 이름 | 설명 |
890
- |------|------|-------------|
891
- | Resource | `agentmemory://status` | 헬스, 세션 수, 메모리 수 |
892
- | Resource | `agentmemory://project/{name}/profile` | 프로젝트별 인텔리전스 |
893
- | Resource | `agentmemory://memories/latest` | 최신 10개 활성 메모리 |
894
- | Resource | `agentmemory://graph/stats` | 지식 그래프 통계 |
895
- | Prompt | `recall_context` | 검색 + 컨텍스트 메시지 반환 |
896
- | Prompt | `session_handoff` | 에이전트 간 핸드오프 데이터 |
897
- | Prompt | `detect_patterns` | 반복 패턴 분석 |
898
- | Skill | `/recall` | 메모리 검색 |
899
- | Skill | `/remember` | 장기 메모리에 저장 |
900
- | Skill | `/session-history` | 최근 세션 요약 |
901
- | Skill | `/forget` | 관측/세션 삭제 |
902
-
903
- ### 독립형 MCP
904
-
905
- 전체 서버 없이 실행 — 모든 MCP 클라이언트용. 다음 둘 다 동작합니다:
906
-
907
- ```bash
908
- npx -y @agentmemory/agentmemory mcp # canonical (always available)
909
- npx -y @agentmemory/mcp # shim package alias
910
- ```
911
-
912
- 또는 에이전트의 MCP 설정에 추가:
913
-
914
- 대부분의 에이전트 (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
915
- ```json
916
- {
917
- "mcpServers": {
918
- "agentmemory": {
919
- "command": "npx",
920
- "args": ["-y", "@agentmemory/mcp"],
921
- "env": {
922
- "AGENTMEMORY_URL": "http://localhost:3111"
923
- }
924
- }
925
- }
926
- }
927
- ```
928
-
929
- 파일을 교체하지 말고 호스트의 기존 `mcpServers` 객체에 `agentmemory` 항목을 병합하십시오. 호스트의 `localhost`에 도달할 수 없는 샌드박스 클라이언트의 경우 env 블록에 `"AGENTMEMORY_FORCE_PROXY": "1"`을 추가하고 `AGENTMEMORY_URL`을 샌드박스가 도달할 수 있는 경로로 설정하십시오.
930
-
931
- OpenCode (`opencode.json`):
932
- ```json
933
- {
934
- "mcp": {
935
- "agentmemory": {
936
- "type": "local",
937
- "command": ["npx", "-y", "@agentmemory/mcp"],
938
- "enabled": true
939
- }
940
- },
941
- "plugin": ["./plugins/agentmemory-capture.ts"]
942
- }
943
- ```
944
-
945
- 저장소에서 플러그인 파일을 복사하십시오:
946
- ```bash
947
- mkdir -p ~/.config/opencode/plugins
948
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
949
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
950
- ```
951
-
952
- ---
953
-
954
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="실시간 뷰어" height="32" /></picture></h2>
955
-
956
- `3113` 포트에서 자동 시작됩니다. 라이브 관측 스트림, 세션 탐색기, 메모리 브라우저, 지식 그래프 시각화, 헬스 대시보드.
957
-
958
- ```bash
959
- open http://localhost:3113
960
- ```
961
-
962
- 뷰어 서버는 기본적으로 `127.0.0.1`에 바인딩됩니다. REST가 서빙하는 `/agentmemory/viewer` 엔드포인트는 일반 `AGENTMEMORY_SECRET` bearer-token 규칙을 따릅니다. CSP 헤더는 응답별 script nonce를 사용하며 인라인 핸들러 속성을 비활성화합니다 (`script-src-attr 'none'`).
963
-
964
- ---
965
-
966
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
967
-
968
- `:3113`의 뷰어는 에이전트가 **기억한 것**을 보여줍니다. [iii console](https://iii.dev/docs/console)은 에이전트가 **무엇을 했는지**를 보여줍니다 — 모든 메모리 작업을 OpenTelemetry 추적으로, 모든 KV 항목을 편집 가능하게, 모든 함수를 호출 가능하게, 모든 스트림을 탭 가능하게. 동일한 메모리에 대한 두 창: 하나는 제품 형태, 하나는 엔진 형태.
969
-
970
- `memory_smart_search`가 발화되는 것을 보고 BM25 스캔 → 임베딩 조회 → RRF 융합 → 리랭커를 워터폴로 확인하십시오. KV 브라우저에서 정체된 통합 타이머를 편집하십시오. 조정된 페이로드로 `PostToolUse` hook을 재생하십시오. WebSocket 스트림을 고정하고 관측이 실시간으로 도착하는 것을 지켜보십시오.
971
-
972
- agentmemory는 모든 함수, 트리거, 상태 스코프, 스트림이 iii 프리미티브이기 때문에 — 사용자 정의도, 계측할 것도 없기 때문에 — 이를 무료로 제공합니다.
973
-
974
- <p align="center">
975
- <img src="../assets/iii-console/workers.png" alt="iii console Workers 페이지 — 연결된 워커들, 라이브 함수 수와 런타임 메타데이터가 표시된 agentmemory 인스턴스 포함" width="720" />
976
- <br/>
977
- <em>Workers 페이지: 연결된 모든 워커 — agentmemory 자체 포함 — PID, 함수 수, 런타임, last-seen 표시.</em>
978
- </p>
979
-
980
- **이미 설치됨.** 콘솔은 `iii`와 함께 제공됩니다 — 별도의 인스톨러가 없습니다.
981
-
982
- **agentmemory와 함께 실행:**
983
-
984
- ```bash
985
- # agentmemory viewer holds port 3113, so run the console on 3114.
986
- # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
987
- iii console --port 3114
988
- ```
989
-
990
- 그런 다음 `http://localhost:3114`을 여십시오. 실험적인 architecture-graph 페이지를 위해 `--enable-flow`를 추가하십시오.
991
-
992
- 엔진 엔드포인트를 옮긴 경우에만 덮어쓰십시오:
993
-
994
- ```bash
995
- iii console --port 3114 \
996
- --engine-port 3111 \
997
- --ws-port 3112 \
998
- --bridge-port 49134
999
- ```
1000
-
1001
- **콘솔에서 할 수 있는 일:**
1002
-
1003
- | 페이지 | 용도 |
1004
- |------|-----------|
1005
- | **Workers** | 연결된 모든 워커와 그 라이브 메트릭 확인 — agentmemory 워커 자체 포함. |
1006
- | **Functions** | JSON 페이로드로 agentmemory의 모든 함수를 직접 호출 — 클라이언트를 연결하지 않고 `memory.recall`, `memory.consolidate`, `graph.query`를 테스트하기에 편리. |
1007
- | **Triggers** | HTTP, cron, event, state 트리거를 재생 — 통합 cron을 수동으로 발화, HTTP 라우트를 재시도, state 변경을 발생. |
1008
- | **States** | 전체 CRUD가 가능한 KV 브라우저 — 세션, 메모리 슬롯, 라이프사이클 타이머, 임베딩 인덱스 — 값을 그 자리에서 편집. |
1009
- | **Streams** | iii 스트림을 통해 흐르는 메모리 쓰기, hook 이벤트, 관측 업데이트를 위한 라이브 WebSocket 모니터. |
1010
- | **Queues** | 내구성 있는 큐 토픽 + 데드 레터 관리. 실패한 임베딩 / 압축 작업을 재생하거나 폐기. |
1011
- | **Traces** | OpenTelemetry 워터폴 / 플레임 / 서비스별 분해 뷰. `trace_id`로 필터링하여 단일 `memory.search`가 생성한 함수, DB 호출, 임베딩 요청을 정확히 확인. |
1012
- | **Logs** | trace/span ID에 필터링·상관된 구조화된 OTEL 로그. |
1013
- | **Config** | 런타임 설정 — 엔진이 실행 중인 워커, 프로바이더, 포트를 정확히 확인. |
1014
- | **Flow** | (선택, `--enable-flow`) 모든 워커, 트리거, 스트림의 인터랙티브 architecture graph. |
1015
-
1016
- <p align="center">
1017
- <img src="../assets/iii-console/traces-waterfall.png" alt="span별 지속 시간을 보여주는 iii console trace waterfall view" width="720" />
1018
- <br/>
1019
- <em>Traces: 모든 메모리 작업에 대한 워터폴 / 플레임 / 서비스 분해.</em>
1020
- </p>
1021
-
1022
- **Traces는 이미 켜져 있습니다:**
1023
-
1024
- `iii-config.yaml`은 `iii-observability` 워커가 활성화된 상태로 제공됩니다(`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs). 추가 설정이 필요 없습니다 — agentmemory가 시작되는 순간 모든 메모리 작업이 콘솔이 읽을 수 있는 trace span과 구조화된 로그를 방출합니다.
1025
-
1026
- 대신 Jaeger/Honeycomb/Grafana Tempo로 내보내고 싶다면 `exporter: memory`를 `exporter: otlp`로 변경하고 iii의 가시성 문서에 따라 collector 엔드포인트를 설정하십시오.
1027
-
1028
- > **참고:** 콘솔 자체에는 인증이 적용되지 않습니다 — `127.0.0.1`에 바인딩된 채로 두고(기본값) 절대 공개적으로 노출하지 마십시오.
1029
-
1030
- ---
1031
-
1032
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1033
-
1034
- agentmemory는 **��미 실행 중인 [iii](https://iii.dev) 인스턴스**입니다. 함수, 트리거, KV 상태, 스트림, OTEL 추적 — 모두 iii 프리미티브입니다. Postgres, Redis, Express, pm2, Prometheus를 설치하지 않은 이유는 iii가 이들을 대체하기 때문입니다.
1035
-
1036
- 그 말은 명령어 하나로 agentmemory에 완전히 새로운 기능을 확장할 수 있다는 뜻입니다.
1037
-
1038
- ### 명령어 하나로 agentmemory 확장
1039
-
1040
- ```bash
1041
- iii worker add iii-pubsub # fan memory writes out to every connected instance
1042
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1043
- iii worker add iii-queue # durable retries for embedding + compression jobs
1044
- iii worker add iii-observability # OTEL traces on every memory op (default on)
1045
- iii worker add iii-sandbox # run recalled code inside an isolated microVM
1046
- iii worker add iii-database # swap in a SQL-backed state adapter
1047
- iii worker add mcp # generic MCP host alongside the agentmemory MCP
1048
- ```
1049
-
1050
- 각 `iii worker add`는 agentmemory가 이미 실행 중인 동일한 엔진에 새 함수와 트리거를 등록합니다. 뷰어와 콘솔은 즉시 이를 인식합니다 — 재로드도, 새 통합도, 새 컨테이너도 필요 없습니다.
1051
-
1052
- | `iii worker add` | agentmemory 위에 무엇이 추가되는가 |
1053
- |---|---|
1054
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 멀티 인스턴스 메모리: 모든 `remember`가 팬아웃, 모든 `search`가 합집합을 읽음 |
1055
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 스케줄링된 라이프사이클 — 야간 통합, 주간 스냅샷, 고정된 시계에 따른 감쇠 |
1056
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 내구성 있는 재시도: 실패한 임베딩 + 압축 작업은 재시작에도 살아남아 관측 손실 없음 |
1057
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 모든 함수에 OTEL traces, metrics, logs — 첫날부터 `iii-config.yaml`에 연결됨 |
1058
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall`에서 나온 코드를 셸이 아니라 일회용 VM 안에서 실행 |
1059
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 인메모리 KV 기본값을 넘어설 때 SQL 기반 state adapter |
1060
- | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory의 MCP 옆에 추가 MCP 서버를 세우고 동일한 엔진을 공유 |
1061
-
1062
- 전체 레지스트리: [workers.iii.dev](https://workers.iii.dev). 그곳의 모든 워커는 agentmemory가 사용하는 동일한 프리미티브로 구성됩니다 — 그리고 이미 갖고 있는 agentmemory도 그중 하나입니다.
1063
-
1064
- ### iii가 무엇을 대체하는가
1065
-
1066
- | 전통적인 스택 | agentmemory에서의 사용 |
1067
- |---|---|
1068
- | Express.js / Fastify | iii HTTP Triggers |
1069
- | SQLite / Postgres + pgvector | iii KV State + 인메모리 벡터 인덱스 |
1070
- | SSE / Socket.io | iii Streams (WebSocket) |
1071
- | pm2 / systemd | iii engine worker supervision |
1072
- | Prometheus / Grafana | iii OTEL + 헬스 모니터 |
1073
- | 사용자 정의 플러그인 시스템 | `iii worker add <name>` |
1074
-
1075
- **118개 소스 파일 · ~21,800 LOC · 950+ tests · 123개 함수 · 34개 KV 스코프** — 모두 세 가지 프리미티브 위에. `agentmemory plugin install`이 없습니다. 플러그인 시스템은 iii 자체입니다.
1076
-
1077
- ---
1078
-
1079
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="설정" height="32" /></picture></h2>
1080
-
1081
- ### LLM 프로바이더
1082
-
1083
- agentmemory는 환경에서 자동 감지합니다. 기본적으로 프로바이더를 구성하거나 Claude subscription 폴백에 명시적으로 옵트인하지 않는 한 LLM 호출이 발생하지 않습니다.
1084
-
1085
- | 프로바이더 | 설정 | 비고 |
1086
- |----------|--------|-------|
1087
- | **No-op (기본)** | 설정 불필요 | LLM 기반 압축/요약이 비활성화됨. 합성 BM25 압축 + 리콜은 여전히 동작. 이전에 Claude-subscription 폴백에 의존했다면 아래의 `AGENTMEMORY_ALLOW_AGENT_SDK` 참고. |
1088
- | Anthropic API | `ANTHROPIC_API_KEY` | 토큰당 청구 |
1089
- | MiniMax | `MINIMAX_API_KEY` | Anthropic 호환 |
1090
- | Gemini | `GEMINI_API_KEY` | 임베딩도 활성화 |
1091
- | OpenRouter | `OPENROUTER_API_KEY` | 모든 모델 |
1092
- | Claude subscription 폴백 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 옵트인 전용. `@anthropic-ai/claude-agent-sdk` 세션을 스폰 — 무한 Stop-hook 재귀를 일으킨 전력이 있어서(#149 후속) 더 이상 기본값이 아닙니다. |
1093
-
1094
- ### 비용 인식 모델 선택
1095
-
1096
- 백그라운드 압축은 모든 관측마다 실행되므로 모델 선택이 월별 지출에 의미 있게 영향을 미칩니다. 캡처된 워크로드 데이터: 635 요청 / 888K 토큰 / 35시간의 활성 사용, 2026-05-23 가격으로 세 가지 OpenRouter 모델에 대해 실행.
1097
-
1098
- | 티어 | 모델 | Input / 1M | Output / 1M | 캡처된 35h 비용 | 비고 |
1099
- |------|-------|------------|-------------|---------------------------|-------|
1100
- | 권장 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 견고한 압축 + 요약 품질, Sonnet 대비 ~10배 저렴. |
1101
- | 권장 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 더 오래되었지만 압축 전용 워크로드에 여전히 적합. |
1102
- | 권장 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 세션이 코드 중심이라면 강한 코드 추론. |
1103
- | 프리미엄 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 고품질이지만 항시 백그라운드 작업에는 비쌈. |
1104
- | 프리미엄 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet과 유사한 티어. |
1105
- | 회피 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 추론 클래스 모델; 압축에는 막대한 과지출. |
1106
-
1107
- `OPENROUTER_MODEL`이 프리미엄 티어 패턴과 일치하면 agentmemory가 런타임 경고를 출력합니다. 정보에 기반한 결정을 내렸다면 `AGENTMEMORY_SUPPRESS_COST_WARNING=1`로 한 번에 침묵시키십시오.
1108
-
1109
- 메모리 작업에서의 품질 대 비용 트레이드오프: 압축은 비교적 느슨한 품질 기준을 가진 요약 작업입니다(사용자가 아니라 에이전트가 요약을 다시 읽습니다). DeepSeek-V4-Pro / Qwen3-Coder는 이 작업에서 Sonnet과 반올림 오차 내에 들어가면서 ~10배 적은 비용이 듭니다. 프리미엄 티어 모델은 직접 읽는 쿼리에 남겨두십시오.
1110
-
1111
- 출처: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1112
-
1113
- ### 멀티 에이전트 메모리 (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1114
-
1115
- 여러 역할(architect / developer / reviewer / researcher / support-agent)이 하나의 agentmemory 서버를 공유하는 멀티 에이전트 설정에서, `AGENT_ID`는 모든 쓰기에 그것을 작성한 역할을 태깅합니다. `AGENTMEMORY_AGENT_SCOPE`는 리콜이 그 태그로 필터링되는지 여부를 제어합니다.
1116
-
1117
- ```env
1118
- TEAM_ID=company
1119
- USER_ID=engineering-team
1120
- AGENT_ID=architect
1121
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1122
- ```
1123
-
1124
- 두 가지 모드:
1125
-
1126
- | 모드 | 쓰기 태그 | 리콜 필터링 | 사용 시점 |
1127
- |------|------------|---------------|-------------|
1128
- | `shared` (기본) | 예 | 아니오 | 감사 로그가 있는 크로스 에이전트 컨텍스트. architect는 developer가 기록한 내용을 볼 수 있지만, 모든 행은 누가 말했는지 기록합니다. |
1129
- | `isolated` | 예 | 예 | 엄격한 분리. architect는 developer의 관측 / 메모리 / 세션을 절대 보지 않습니다. |
1130
-
1131
- `AGENT_ID`가 설정되었을 때 태깅되는 것: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. 역할은 `api::session::start` → `mem::observe` → `mem::compress` → KV로 흐릅니다.
1132
-
1133
- isolated 모드에서 필터링되는 것: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. 각 엔드포인트는 요청별로 덮어쓰기 위해 `?agentId=<role>`을 받고, env 스코프를 완전히 옵트아웃하기 위해 `?agentId=*`을 받습니다. `/memories`는 또한 `agentId`가 undefined인 pre-AGENT_ID 메모리를 노출하기 위해 `?includeOrphans=true`를 받습니다.
1134
-
1135
- SDK / REST 레이어에서의 호출별 덮어쓰기: 모든 변형 엔드포인트(`/session/start`, `/remember`)는 env를 이기는 `agentId` 필드를 request body에서 받습니다. 많은 역할을 하나의 서버 프로세스로 라우팅하는 런타임에 유용합니다.
1136
-
1137
- `AGENT_ID`가 설정되지 않았을 때, 메모리는 스코프되지 않은 상태로 유지됩니다(레거시 동작, 태그 없음, 필터 없음).
1138
-
1139
- ### 포트
1140
-
1141
- agentmemory + iii-engine은 기본적으로 네 개의 포트에 바인딩합니다. 재시작이 `port in use`로 실패한다면, 이 표가 어떤 프로세스를 찾을지 알려줍니다.
1142
-
1143
- | 포트 | 프로세스 | 용도 | Env 덮어쓰기 |
1144
- |------|---------|---------|--------------|
1145
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1146
- | `3112` | iii-engine | 내부 streams 워커 (agentmemory + 뷰어가 소비) | `III_STREAMS_PORT` |
1147
- | `3113` | agentmemory | 실시간 뷰어 (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1148
- | `49134` | iii-engine | WebSocket — 워커가 여기에 등록, OTel 텔레메트리가 이 위로 흐름 | `III_ENGINE_URL` (전체 URL, 기본 `ws://localhost:49134`) |
1149
-
1150
- 크래시된 실행 후 포트가 바인딩된 채로 남아 있을 때의 정리:
1151
-
1152
- ```bash
1153
- # macOS / Linux — find whatever is on each port and kill it
1154
- lsof -i :3111,3112,3113,49134
1155
- pkill -f agentmemory || true
1156
- pkill -f 'iii ' || true
1157
-
1158
- # Windows
1159
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1160
- taskkill /F /PID <pid>
1161
- ```
1162
-
1163
- `agentmemory stop`은 정상 종료 시 워커�� 엔진 pidfile을 모두 깔끔하게 회수합니다 (#640, #474). 위의 수동 정리는 어떤 pidfile도 남지 않은 크래시 후 케이스에만 해당됩니다.
1164
-
1165
- ### 설정 파일
1166
-
1167
- 매 셸에서 변수를 export하는 대신 agentmemory 런타임 설정을 `~/.agentmemory/.env`에 두십시오. 뷰어가 `export ANTHROPIC_API_KEY=...` 같은 setup 힌트를 보여주면, `export` 접두사 없이 `ANTHROPIC_API_KEY=...`로 이 파일에 복사한 후 agentmemory를 재시작하십시오.
1168
-
1169
- 프로세스 환경 변수는 여전히 동작하며 파일의 값보다 우선순위가 높습니다.
1170
-
1171
- Windows에서 동일한 파일은 `%USERPROFILE%\.agentmemory\.env`에 있습니다:
1172
-
1173
- ```powershell
1174
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1175
- notepad $HOME\.agentmemory\.env
1176
- ```
1177
-
1178
- API 키 대신 Claude Code Pro/Max subscription으로 테스트하려면 명시적으로 옵트인하십시오:
1179
-
1180
- ```env
1181
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1182
- AGENTMEMORY_AUTO_COMPRESS=true
1183
- ```
1184
-
1185
- 원한다면 동일한 파일에서 graph 또는 consolidation 기능을 활성화하십시오:
1186
-
1187
- ```env
1188
- GRAPH_EXTRACTION_ENABLED=true
1189
- CONSOLIDATION_ENABLED=true
1190
- ```
1191
-
1192
- ### 환경 변수
1193
-
1194
- `~/.agentmemory/.env` 생성:
1195
-
1196
- ```env
1197
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1198
- # ANTHROPIC_API_KEY=sk-ant-...
1199
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1200
- # GEMINI_API_KEY=...
1201
- # OPENROUTER_API_KEY=...
1202
- # MINIMAX_API_KEY=...
1203
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1204
- # # OpenAI LLM provider (here) AND the OpenAI
1205
- # # embedding provider (further below). Set
1206
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1207
- # # to embeddings only.
1208
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1209
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1210
- # # Auto-detected from `.openai.azure.com` hostname; uses
1211
- # # api-key header + api-version query param.
1212
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1213
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1214
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1215
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1216
- # # for back-compat with v0.9.17. New configs should
1217
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1218
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1219
- # # Honored only by OpenAI's reasoning models (o1, o3,
1220
- # # gpt-*-reasoning) and providers that mirror that
1221
- # # schema (Ollama Cloud thinking models). Standard
1222
- # # chat models reject this field with 400. Set to
1223
- # # "none" for thinking models that return reasoning
1224
- # # but no content.
1225
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1226
- # # for LLM (useful if you only want OpenAI for embeddings)
1227
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1228
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1229
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1230
-
1231
- # Embedding provider (auto-detected, or override)
1232
- # EMBEDDING_PROVIDER=local
1233
- # VOYAGE_API_KEY=...
1234
- # OPENAI_API_KEY=sk-...
1235
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1236
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1237
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1238
-
1239
- # Outbound LLM / embedding timeout
1240
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1241
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1242
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1243
- # embedding). For the OpenAI LLM path, the
1244
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1245
- # takes precedence when set, for back-compat
1246
- # with v0.9.17.
1247
- # Increase for slow networks or large batch calls;
1248
- # decrease to fail-fast on rate-limit holds.
1249
-
1250
- # Search tuning
1251
- # BM25_WEIGHT=0.4
1252
- # VECTOR_WEIGHT=0.6
1253
- # TOKEN_BUDGET=2000
1254
-
1255
- # Auth
1256
- # AGENTMEMORY_SECRET=your-secret
1257
-
1258
- # Ports (defaults: 3111 API, 3113 viewer)
1259
- # III_REST_PORT=3111
1260
-
1261
- # Features
1262
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1263
- # every PostToolUse hook calls your
1264
- # LLM provider to compress the
1265
- # observation — expect significant
1266
- # token spend on active sessions.
1267
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1268
- # memory slots — persona,
1269
- # user_preferences, tool_guidelines,
1270
- # project_context, guidance,
1271
- # pending_items, session_patterns,
1272
- # self_notes. Size-limited; agent
1273
- # edits via memory_slot_* tools.
1274
- # Pinned slots addressable for
1275
- # SessionStart injection.
1276
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1277
- # Stop hook fires mem::slot-reflect:
1278
- # scans recent observations, auto-
1279
- # appends TODOs to pending_items,
1280
- # counts patterns in
1281
- # session_patterns, records touched
1282
- # files in project_context. Fire-
1283
- # and-forget; does not block.
1284
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1285
- # - SessionStart may inject ~1-2K
1286
- # chars of project context into
1287
- # the first turn of each session
1288
- # (this is what actually reaches
1289
- # the model — Claude Code treats
1290
- # SessionStart stdout as context)
1291
- # - PreToolUse fires /agentmemory/enrich
1292
- # on every file-touching tool call
1293
- # (resource cleanup, not a token
1294
- # fix — PreToolUse stdout is debug
1295
- # log only per Claude Code docs)
1296
- # Observations are still captured via
1297
- # PostToolUse regardless of this flag.
1298
- # GRAPH_EXTRACTION_ENABLED=false
1299
- # CONSOLIDATION_ENABLED=true
1300
- # LESSON_DECAY_ENABLED=true
1301
- # OBSIDIAN_AUTO_EXPORT=false
1302
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1303
- # CLAUDE_MEMORY_BRIDGE=false
1304
- # SNAPSHOT_ENABLED=false
1305
-
1306
- # Team
1307
- # TEAM_ID=
1308
- # USER_ID=
1309
- # TEAM_MODE=private
1310
-
1311
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1312
- # AGENTMEMORY_TOOLS=core
1313
- ```
1314
-
1315
- ---
1316
-
1317
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1318
-
1319
- `3111` 포트의 124개 엔드포인트. REST API는 기본적으로 `127.0.0.1`에 바인딩됩니다. 보호된 엔드포인트는 `AGENTMEMORY_SECRET`이 설정되었을 때 `Authorization: Bearer <secret>`를 요구하며, mesh sync 엔드포인트는 양쪽 피어 모두에서 `AGENTMEMORY_SECRET`을 요구합니다.
1320
-
1321
- <details>
1322
- <summary>주요 엔드포인트</summary>
1323
-
1324
- | Method | Path | 설명 |
1325
- |--------|------|-------------|
1326
- | `GET` | `/agentmemory/health` | 헬스 체크 (항상 공개) |
1327
- | `POST` | `/agentmemory/session/start` | 세션 시작 + 컨텍스트 가져오기 |
1328
- | `POST` | `/agentmemory/session/end` | 세션 종료 |
1329
- | `POST` | `/agentmemory/observe` | 관측 캡처 |
1330
- | `POST` | `/agentmemory/smart-search` | 하이브리드 검색 |
1331
- | `POST` | `/agentmemory/context` | 컨텍스트 생성 |
1332
- | `POST` | `/agentmemory/remember` | 장기 메모리에 저장 |
1333
- | `POST` | `/agentmemory/forget` | 관측 삭제 |
1334
- | `POST` | `/agentmemory/enrich` | 파일 컨텍스트 + 메모리 + 버그 |
1335
- | `GET` | `/agentmemory/profile` | 프로젝트 프로필 |
1336
- | `GET` | `/agentmemory/export` | 모든 데이터 내보내기 |
1337
- | `POST` | `/agentmemory/import` | JSON에서 가져오기 |
1338
- | `POST` | `/agentmemory/graph/query` | 지식 그래프 쿼리 |
1339
- | `POST` | `/agentmemory/team/share` | 팀과 공유 |
1340
- | `GET` | `/agentmemory/audit` | 감사 로그 |
1341
-
1342
- 전체 엔드포인트 목록: [`src/triggers/api.ts`](../src/triggers/api.ts)
1343
-
1344
- </details>
1345
-
1346
- ---
1347
-
1348
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="개발" height="32" /></picture></h2>
1349
-
1350
- ```bash
1351
- npm run dev # Hot reload
1352
- npm run build # Production build
1353
- npm test # 950+ tests
1354
- npm run test:integration # API tests (requires running services)
1355
- ```
1356
-
1357
- **전제 조건:** Node.js >= 20, [iii-engine](https://iii.dev/docs) 또는 Docker
1358
-
1359
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="라이선스" height="32" /></picture></h2>
1360
-
1361
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.pt-BR.md DELETED
@@ -1,1370 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — Memória persistente para agentes de codificação com IA" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- Seu agente de codificação lembra de tudo. Chega de re-explicar.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Memória persistente para Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode e qualquer cliente MCP.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- Português |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Documento de design: 1200 stars / 172 forks no gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>O gist estende o padrão LLM Wiki do Karpathy com pontuação de confiança, ciclo de vida, grafos de conhecimento e busca híbrida: agentmemory é a implementação.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="Demonstração do agentmemory" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">Instalação</a> &bull;
73
- <a href="#quick-start">Início rápido</a> &bull;
74
- <a href="#benchmarks">Benchmarks</a> &bull;
75
- <a href="#vs-competitors">Comparativo</a> &bull;
76
- <a href="#works-with-every-agent">Agentes</a> &bull;
77
- <a href="#how-it-works">Como funciona</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">Viewer</a> &bull;
80
- <a href="#iii-console">iii Console</a> &bull;
81
- <a href="#powered-by-iii">Powered by iii</a> &bull;
82
- <a href="#configuration">Configuração</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Install
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # start the memory server on :3111
95
- agentmemory demo # seed sample sessions + prove recall
96
- agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- Ou via `npx` (sem instalação):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- Atenção — o npx faz cache por versão. Se um simples `npx @agentmemory/agentmemory` servir uma release antiga, force a mais recente com `npx -y @agentmemory/agentmemory@latest`, ou limpe o cache uma vez com `rm -rf ~/.npm/_npx` (macOS/Linux; no Windows apague `%LOCALAPPDATA%\npm-cache\_npx`). A primeira execução via npx a partir da v0.9.16+ pergunta inline se você quer instalar globalmente, de modo que o comando `agentmemory` simples funcione em qualquer lugar depois.
106
-
107
- Opções completas em [Início rápido](#quick-start) abaixo. Conexão específica por agente em [Funciona com qualquer agente](#works-with-every-agent).
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funciona com qualquer agente" height="32" /></picture></h2>
112
-
113
- agentmemory funciona com qualquer agente que suporte hooks, MCP ou REST API. Todos os agentes compartilham o mesmo servidor de memória.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>native plugin + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>native plugin + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>native plugin + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>native plugin + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>native plugin + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>native Memory trait backend</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP server</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP server</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + plugin</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP server</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP server</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP server</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP server</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP server</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP server</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>Funciona com <strong>qualquer</strong> agente que fale MCP ou HTTP. Um servidor, memórias compartilhadas entre todos eles.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- Você explica a mesma arquitetura toda sessão. Você redescobre os mesmos bugs. Você reensina as mesmas preferências. A memória integrada (CLAUDE.md, .cursorrules) bate no teto das 200 linhas e fica desatualizada. agentmemory resolve isso. Ele captura silenciosamente o que seu agente faz, comprime em memória pesquisável e injeta o contexto certo quando a próxima sessão começa. Um comando. Funciona em todos os agentes.
209
-
210
- **O que muda:** Na sessão 1 você configura autenticação JWT. Na sessão 2 você pede rate limiting. O agente já sabe que sua autenticação usa o middleware jose em `src/middleware/auth.ts`, que seus testes cobrem a validação de tokens e que você escolheu jose em vez de jsonwebtoken por compatibilidade com Edge. Sem re-explicar. Sem copiar e colar. O agente simplesmente *sabe*.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **Novidade na v0.9.0** — Landing em [agent-memory.dev](https://agent-memory.dev), conector de filesystem (`@agentmemory/fs-watcher`), MCP standalone agora faz proxy para o servidor em execução, então hooks e viewer combinam, política de auditoria codificada em cada caminho de deleção, e health para de marcar `memory_critical` em processos Node pequenos. Notas completas em [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Precisão de recuperação
227
-
228
- **coding-agent-life-v1** (corpus interno, reproduzível em sandbox)
229
-
230
- | Adaptador | P@5 | R@5 | Taxa de acerto top-5 | Latência p50 |
231
- |---|---|---|---|---|
232
- | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- Taxa de acerto top-5 de 100%. **2,2×** mais precisão que a baseline grep com a mesma entrada. Detalhamento completo por tipo: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 perguntas)
238
-
239
- | Sistema | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Economia de tokens
248
-
249
- | Abordagem | Tokens/ano | Custo/ano |
250
- |---|---|---|
251
- | Colar contexto completo | 19.5M+ | Impossível (excede a janela) |
252
- | Resumido por LLM | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + embeddings locais | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Modelo de embedding: `all-MiniLM-L6-v2` (local, gratuito, sem API key). Relatórios completos: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparativo com concorrentes: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
-
262
- **Reproduza localmente:** [`eval/README.md`](../eval/README.md) — harness com adaptadores plugáveis para LongMemEval `_s` (500-Q públicas) e `coding-agent-life-v1` (corpus interno de 15 sessões). Adaptadores grep / vector / agentmemory são pontuados lado a lado, saída em NDJSON, e as scorecards publicadas ficam em [`docs/benchmarks/`](../docs/benchmarks/).
263
-
264
- **Combina com [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) e [Graphify](https://github.com/safishamsi/graphify).** Indexação de grafos de código, pipelines de build multiagente e grafos de conhecimento mais amplos sobre docs / PDFs / imagens / vídeos. agentmemory lembra do trabalho; esses três projetos iluminam o resto da camada de contexto. Recipes e tabela de roteamento por pergunta: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Comparativo" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">Built-in (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>Tipo</strong></td>
280
- <td>Engine de memória + servidor MCP</td>
281
- <td>API de camada de memória</td>
282
- <td>Runtime de agente completo</td>
283
- <td>Arquivo estático</td>
284
- </tr>
285
- <tr>
286
- <td><strong>Retrieval R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>Captura automática</strong></td>
294
- <td>12 hooks (esforço manual zero)</td>
295
- <td>Chamadas manuais a <code>add()</code></td>
296
- <td>O agente se autoedita</td>
297
- <td>Edição manual</td>
298
- </tr>
299
- <tr>
300
- <td><strong>Busca</strong></td>
301
- <td>BM25 + Vector + Graph (fusão RRF)</td>
302
- <td>Vector + Graph</td>
303
- <td>Vector (archival)</td>
304
- <td>Carrega tudo no contexto</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Multiagente</strong></td>
308
- <td>MCP + REST + leases + signals</td>
309
- <td>API (sem coordenação)</td>
310
- <td>Somente dentro do runtime do Letta</td>
311
- <td>Arquivos por agente</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Dependência de framework</strong></td>
315
- <td>Nenhuma (qualquer cliente MCP)</td>
316
- <td>Nenhuma</td>
317
- <td>Alta (precisa usar Letta)</td>
318
- <td>Formato por agente</td>
319
- </tr>
320
- <tr>
321
- <td><strong>Dependências externas</strong></td>
322
- <td>Nenhuma (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + BD vetorial</td>
325
- <td>Nenhuma</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Ciclo de vida da memória</strong></td>
329
- <td>Consolidação de 4 níveis + decaimento + auto-esquecimento</td>
330
- <td>Extração passiva</td>
331
- <td>Gerenciado pelo agente</td>
332
- <td>Poda manual</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Eficiência de tokens</strong></td>
336
- <td>~1.900 tokens/sessão ($10/ano)</td>
337
- <td>Varia conforme a integração</td>
338
- <td>Memória principal no contexto</td>
339
- <td>22K+ tokens com 240 obs</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Viewer em tempo real</strong></td>
343
- <td>Sim (port 3113)</td>
344
- <td>Dashboard na nuvem</td>
345
- <td>Dashboard na nuvem</td>
346
- <td>Não</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Self-hosted</strong></td>
350
- <td>Sim (padrão)</td>
351
- <td>Opcional</td>
352
- <td>Opcional</td>
353
- <td>Sim</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Início rápido" height="32" /></picture></h2>
360
-
361
- Compatibilidade: este release tem como alvo o `iii-sdk` estável `^0.11.0` e o iii-engine v0.11.x.
362
-
363
- ### Experimente em 30 segundos
364
-
365
- ```bash
366
- # Terminal 1: start the server
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: seed sample data and see recall in action
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` semeia 3 sessões realistas (autenticação JWT, correção de N+1 queries, rate limiting) e roda buscas semânticas sobre elas. Você verá que ele encontra "N+1 query fix" ao buscar "database performance optimization" — algo que matching por palavra-chave não consegue fazer.
374
-
375
- Abra `http://localhost:3113` para acompanhar a memória sendo construída ao vivo.
376
-
377
- ### Recomendado: instale globalmente
378
-
379
- `npx` faz cache por versão. Se você rodou `npx @agentmemory/agentmemory@0.9.14` semana passada, um simples `npx @agentmemory/agentmemory` pode servir a versão velha 0.9.14 a partir de `~/.npm/_npx/`, e não a mais recente. Instale uma vez e o comando `agentmemory` funciona em qualquer lugar:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # start the server (same as the npx form)
386
- agentmemory stop # tear it down
387
- agentmemory remove # uninstall everything we created
388
- agentmemory connect claude-code # wire one agent
389
- agentmemory doctor # interactive diagnostics + fix prompts
390
- ```
391
-
392
- A partir da v0.9.16, a primeira execução via npx pergunta inline se você quer instalar globalmente — responda `Y` uma vez e está pronto. Se pular, recorra a qualquer um destes para um fetch limpo:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
- ```
398
-
399
- No Windows / PowerShell, o equivalente para limpar cache é `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — a forma `npx -y ...@latest` acima é a opção multiplataforma.
400
-
401
- ### Session Replay
402
-
403
- Toda sessão que o agentmemory grava é reproduzível. Abra o viewer, escolha a aba **Replay** e arraste pela timeline: prompts, chamadas a tools, resultados e respostas renderizam como eventos discretos com play/pause, controle de velocidade (0,5×–4×) e atalhos de teclado (espaço para alternar, setas para avançar passo a passo).
404
-
405
- Já tem transcripts antigos JSONL do Claude Code que quer trazer para cá?
406
-
407
- ```bash
408
- # Import everything under the default ~/.claude/projects
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Or import a single file
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- As sessões importadas aparecem no seletor de Replay ao lado das nativas. Sob o capô, cada entrada passa pelas funções iii `mem::replay::load`, `mem::replay::sessions` e `mem::replay::import-jsonl` — sem servidores paralelos.
416
-
417
- ### Atualização / Manutenção
418
-
419
- Use o comando de manutenção quando você intencionalmente quiser atualizar seu runtime local:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- Aviso: este comando muta o workspace/runtime atual. Pode atualizar dependências JavaScript, pode rodar `cargo install iii-engine --force` e pode puxar imagens Docker.
426
-
427
- Detalhes de implementação estão em `src/cli.ts` (veja `runUpgrade` na região `src/cli.ts:544-595`).
428
-
429
- ### Claude Code (um bloco, cole)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code sem instalar o plugin (caminho MCP standalone)
436
-
437
- Se você cabear o servidor MCP do agentmemory via `~/.claude.json` diretamente em vez de usar `/plugin install`, o Claude Code nunca resolve `${CLAUDE_PLUGIN_ROOT}` e você tem que apontar os scripts de hook para caminhos absolutos em `~/.claude/settings.json`. Esses caminhos tipicamente embutem a versão do agentmemory (ex: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), então a próxima atualização quebra silenciosamente todos os hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- Contorno:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- Isso mescla os mesmos comandos de hook em `~/.claude/settings.json` com caminhos absolutos resolvidos para o diretório `plugin/` empacotado do pacote `@agentmemory/agentmemory` atualmente instalado. Rode o comando novamente após atualizar o agentmemory para atualizar os caminhos. Entradas de usuário no mesmo arquivo são preservadas; apenas entradas anteriores do agentmemory são substituídas. Usar o caminho `/plugin install` continua sendo a abordagem recomendada.
446
- Para deploys remotos ou protegidos, inicie o Claude Code com `AGENTMEMORY_URL` e `AGENTMEMORY_SECRET` definidos. O plugin repassa ambos os valores para seu servidor MCP empacotado; quando `AGENTMEMORY_URL` está vazio, o shim MCP usa `http://localhost:3111`.
447
-
448
- ### Codex CLI (plataforma de plugins do Codex)
449
-
450
- ```bash
451
- # 1. start the memory server in a separate terminal
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. register the agentmemory marketplace and install the plugin
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- O plugin do Codex é servido a partir do mesmo diretório `plugin/` do plugin do Claude Code. Ele registra:
460
-
461
- - `@agentmemory/mcp` como servidor MCP (faz proxy de todas as 51 tools quando `AGENTMEMORY_URL` aponta para um servidor agentmemory em execução; cai para 7 tools localmente quando não há servidor acessível)
462
- - 6 hooks de ciclo de vida: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- A engine de hooks do Codex injeta `CLAUDE_PLUGIN_ROOT` nos subprocessos de hook (conforme [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), então os mesmos scripts de hook funcionam nos dois hosts sem duplicação. Os eventos Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure são exclusivos do Claude Code e não são registrados para o Codex.
466
-
467
- #### Codex Desktop: hooks do plugin atualmente silenciosos (com contorno)
468
-
469
- `CodexHooks` e `PluginHooks` são estáveis e habilitados por padrão em [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), mas as builds atuais do Codex Desktop não despacham `hooks.json` local de plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). As tools MCP continuam funcionando; só as observações de ciclo de vida estão faltando.
470
-
471
- Até que o upstream corrija, espelhe os mesmos comandos de hook no `~/.codex/hooks.json` global:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- Isso adiciona um bloco idempotente em `~/.codex/hooks.json` referenciando caminhos absolutos para os scripts empacotados (sem necessidade de expansão de `${CLAUDE_PLUGIN_ROOT}` no escopo de usuário). Rode o mesmo comando novamente após atualizar o agentmemory para atualizar os caminhos. Entradas de usuário no mesmo arquivo são preservadas; só entradas anteriores do agentmemory são substituídas.
478
-
479
- <details>
480
- <summary><b>OpenClaw (cole este prompt)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- Guia completo: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (cole este prompt)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- Guia completo: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### Outros agentes
526
-
527
- Inicie o servidor de memória: `npx @agentmemory/agentmemory`
528
-
529
- A entrada do agentmemory é o **mesmo bloco de servidor MCP** em todo host que usa o formato `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **Mescle esta entrada no objeto `mcpServers` existente** no arquivo de configuração do host — não substitua o arquivo. Se o arquivo já tem outros servidores, adicione `agentmemory` ao lado deles como outra chave dentro de `mcpServers`. Se `mcpServers` não existe, cole o bloco dentro de `{ "mcpServers": { ... } }`. Os placeholders `${VAR}` herdam `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` do shell no momento em que o servidor MCP sobe — variáveis não definidas passam string vazia e o shim cai para `http://localhost:3111`. Uma entrada cabeada cobre deploys tanto locais quanto remotos (k8s / com reverse-proxy).
543
-
544
- | Agente | Arquivo de configuração | Notas |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | Mescle em `mcpServers`. Deeplink de um clique também disponível no site. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Mescle em `mcpServers`. Reinicie o Claude Desktop após editar. |
548
- | **Cline / Roo Code / Kilo Code** | Configurações MCP do Cline (Settings UI → MCP Servers → Edit) | Mesmo bloco `mcpServers`. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Mesmo bloco `mcpServers`. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (mescla automaticamente). |
551
- | **OpenClaw** | Configuração MCP do OpenClaw | Mesmo bloco `mcpServers`, ou use o [memory plugin](../integrations/openclaw/) mais profundo. |
552
- | **Codex CLI (somente MCP)** | `.codex/config.toml` | Formato TOML: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, ou adicione `[mcp_servers.agentmemory]` manualmente. |
553
- | **Codex CLI (plugin completo)** | Marketplace de plugins do Codex | `codex plugin marketplace add rohitg00/agentmemory` e depois `codex plugin add agentmemory@agentmemory`. Registra MCP + 6 hooks de ciclo de vida (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. No Codex Desktop, rode também `agentmemory connect codex --with-hooks` até que [openai/codex#16430](https://github.com/openai/codex/issues/16430) seja mergeado — os hooks de plugin estão silenciosos lá. |
554
- | **OpenCode (somente MCP)** | `opencode.json` | Formato diferente — chave `mcp` no topo, comando como array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (plugin completo)** | `plugin/opencode/` | 22 hooks de captura automática cobrindo ciclo de vida de sessão, mensagens, tools e erros. Dois comandos slash (`/recall`, `/remember`). Copie `plugin/opencode/` para seu workspace do OpenCode e adicione a entrada do plugin em `opencode.json`. Tabela completa de hooks + análise de gaps em [`plugin/opencode/README.md`](../plugin/opencode/README.md). |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | Copie [`integrations/pi`](../integrations/pi/) e reinicie o pi. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | Use o [memory provider plugin](../integrations/hermes/) mais profundo com `memory.provider: agentmemory`. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` escreve o bloco `mcpServers` padrão. O payload dos hooks é compatível em nível de campo com o Claude Code, então os scripts dos 12 hooks existentes funcionam sem modificação — cabê-los na seção `hooks` do mesmo `settings.json`. |
559
- | **Antigravity** (substitui o Gemini CLI) | `mcp_config.json` (no diretório User do Antigravity) | `agentmemory connect antigravity` escreve o bloco `mcpServers` padrão. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Use após o sunset do Gemini CLI em 2026-06-18. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` escreve a configuração no nível do usuário. Overrides por workspace vão em `.kiro/settings/mcp.json` ao lado do seu código. |
561
- | **Goose** | UI de configurações MCP do Goose | Mesmo bloco `mcpServers`. |
562
- | **Aider** | n/a | Fale diretamente com a REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **Qualquer agente (32+)** | n/a | `npx skillkit install agentmemory` autodetecta o host e mescla. |
564
-
565
- **Clientes MCP em sandbox** (Flatpak / Snap / contêineres restritivos) que não conseguem alcançar o `localhost` do host: também defina `"AGENTMEMORY_FORCE_PROXY": "1"` no bloco `env`, e aponte `AGENTMEMORY_URL` para uma rota que o sandbox realmente alcance (ex: seu IP de LAN). Veja [#234](https://github.com/rohitg00/agentmemory/issues/234) para o passo a passo de diagnóstico.
566
-
567
- ### Acesso programático (Python / Rust / Node)
568
-
569
- agentmemory registra suas operações principais como funções iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Qualquer linguagem com um SDK iii pode chamá-las diretamente via `ws://localhost:49134` — sem um cliente REST separado por linguagem.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- Exemplo prático: [`examples/python/`](../examples/python/) (quickstart + fluxo de observação/recall). A REST em `:3111` continua disponível para hosts sem runtime iii.
590
-
591
- ### A partir do código-fonte
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- Isso inicia o agentmemory com um `iii-engine` local se `iii` já estiver instalado, ou cai para Docker Compose se o Docker estiver disponível. REST, streams e o viewer fazem bind em `127.0.0.1` por padrão.
599
-
600
- Instale o `iii-engine` manualmente. **O agentmemory atualmente fixa o `iii-engine` em `v0.11.2`** — `v0.11.6` introduz um novo modelo que faz sandbox de tudo via `iii worker add` que o agentmemory ainda não foi refatorado para usar. O pin sai assim que o refactor cair. Sobrescreva com `AGENTMEMORY_III_VERSION=<version>` se você migrou manualmente para o modelo de sandbox.
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** troque `aarch64-apple-darwin` por `x86_64-apple-darwin`
604
- - **Linux x64:** troque por `x86_64-unknown-linux-gnu`
605
- - **Linux arm64:** troque por `aarch64-unknown-linux-gnu`
606
- - **Windows:** baixe `iii-x86_64-pc-windows-msvc.zip` de [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extraia `iii.exe`, adicione ao PATH
607
-
608
- Ou use Docker (o `docker-compose.yml` empacotado puxa `iiidev/iii:0.11.2`). Docs completas: [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory roda em Windows 10/11, mas só o pacote Node.js não é suficiente — você também precisa do runtime `iii-engine` (um binário nativo separado) como processo em segundo plano. O instalador oficial upstream é um script `sh` e hoje não há instalador PowerShell nem pacote scoop/winget, então usuários de Windows têm dois caminhos:
613
-
614
- **Opção A — Binário Windows pré-compilado (recomendado):**
615
-
616
- ```powershell
617
- # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
- # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
- # model that engine v0.11.6+ requires)
620
- # 2. Download iii-x86_64-pc-windows-msvc.zip
621
- # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
- # 3. Extract iii.exe somewhere on PATH, or place it at:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory checks that location automatically)
625
- # 4. Verify:
626
- iii --version
627
- # Should print: 0.11.2
628
-
629
- # 5. Then run agentmemory as usual:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **Opção B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Install Docker Desktop for Windows
637
- # 2. Start Docker Desktop and make sure the engine is running
638
- # 3. Run agentmemory — it will auto-start the bundled compose file:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **Opção C — apenas MCP standalone (sem engine):** se você só precisa das tools MCP para seu agente e não precisa da REST API, viewer ou cron jobs, pule o engine completamente:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # or via the shim package:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Diagnóstico para Windows:** se `npx @agentmemory/agentmemory` falhar, rode novamente com `--verbose` para ver o stderr real do engine. Modos de falha comuns:
651
-
652
- | Sintoma | Correção |
653
- |---|---|
654
- | `iii-engine process started` seguido de `did not become ready within 15s` | Engine crashou na inicialização — rode novamente com `--verbose`, verifique stderr |
655
- | `Could not start iii-engine` | Nem `iii.exe` nem Docker estão instalados. Veja Opção A ou B acima |
656
- | Conflito de porta | `netstat -ano \| findstr :3111` para ver o que está em bind, mate o processo ou use `--port <N>` |
657
- | Fallback do Docker é pulado mesmo com Docker instalado | Confira se o Docker Desktop está de fato rodando (ícone na bandeja do sistema) |
658
-
659
- > Nota: não existe `cargo install iii-engine` — `iii` não é publicado no crates.io. Os únicos métodos de instalação suportados são o binário pré-compilado acima, o script de instalação `sh` upstream (somente macOS/Linux) e a imagem Docker.
660
-
661
- ---
662
-
663
- <h2 id="deploy">Deploy</h2>
664
-
665
- Templates de um clique para hosts gerenciados. Cada um inclui um
666
- Dockerfile autocontido que puxa `@agentmemory/agentmemory` do npm
667
- e copia o binário do iii engine da imagem oficial `iiidev/iii` no
668
- Docker Hub — sem necessidade de imagem pré-compilada do agentmemory.
669
- Armazenamento persistente monta em `/data`; o entrypoint de primeiro
670
- boot sobrescreve a configuração iii empacotada pelo npm (que faz
671
- bind em `127.0.0.1`) por uma ajustada para deploy que faz bind em
672
- `0.0.0.0` e usa caminhos absolutos `/data`, gera o segredo HMAC e
673
- depois reduz privilégios de `root` para `node` via `gosu` antes de
674
- fazer exec do CLI do agentmemory.
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- O botão de deploy de um clique do Render exige um `render.yaml` na raiz do repositório, que mantemos limpo de propósito. Use o fluxo Render Blueprint documentado em [`deploy/render/`](../deploy/render/README.md) para apontar para o blueprint do repo manualmente.
682
-
683
- Detalhes completos de setup (captura de HMAC, túnel SSH do viewer, rotação, backup, mínimos de custo) ficam em [`deploy/`](../deploy/README.md):
684
-
685
- - [`deploy/fly`](../deploy/fly/README.md) — máquina única com `auto_stop_machines = "stop"`; mais barato em idle.
686
- - [`deploy/railway`](../deploy/railway/README.md) — taxa plana do plano Hobby, volume no dashboard.
687
- - [`deploy/render`](../deploy/render/README.md) — fluxo Blueprint, snapshots automáticos de disco nos planos pagos.
688
- - [`deploy/coolify`](../deploy/coolify/README.md) — self-hosted no seu próprio VPS via [Coolify](https://coolify.io/self-hosted); mesma stack Docker Compose, você possui o host e os dados.
689
-
690
- Somente a porta `3111` é publicada. O viewer em `3113` fica em bind no loopback dentro do contêiner — o README de cada template documenta o padrão de túnel SSH para alcançá-lo.
691
-
692
- ---
693
-
694
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Por que agentmemory" height="32" /></picture></h2>
695
-
696
- Todo agente de codificação esquece tudo quando a sessão termina. Você desperdiça os primeiros 5 minutos de toda sessão re-explicando sua stack. agentmemory roda em segundo plano e elimina isso por completo.
697
-
698
- ```text
699
- Session 1: "Add auth to the API"
700
- Agent writes code, runs tests, fixes bugs
701
- agentmemory silently captures every tool use
702
- Session ends -> observations compressed into structured memory
703
-
704
- Session 2: "Now add rate limiting"
705
- Agent already knows:
706
- - Auth uses JWT middleware in src/middleware/auth.ts
707
- - Tests in test/auth.test.ts cover token validation
708
- - You chose jose over jsonwebtoken for Edge compatibility
709
- Zero re-explaining. Starts working immediately.
710
- ```
711
-
712
- ### vs memória integrada do agente
713
-
714
- Todo agente de codificação com IA vem com memória integrada — Claude Code tem `MEMORY.md`, Cursor tem notepads, Cline tem memory bank. Funcionam como post-its. agentmemory é o banco de dados pesquisável por trás dos post-its.
715
-
716
- | | Integrada (CLAUDE.md) | agentmemory |
717
- |---|---|---|
718
- | Escala | teto de 200 linhas | Ilimitado |
719
- | Busca | Carrega tudo no contexto | BM25 + vector + graph (só top-K) |
720
- | Custo em tokens | 22K+ com 240 observações | ~1.900 tokens (92% menos) |
721
- | Cross-agent | Arquivos por agente | MCP + REST (qualquer agente) |
722
- | Coordenação | Nenhuma | Leases, signals, actions, routines |
723
- | Observabilidade | Leitura manual de arquivos | Viewer em tempo real em :3113 |
724
-
725
- ---
726
-
727
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Como funciona" height="32" /></picture></h2>
728
-
729
- ### Pipeline de memória
730
-
731
- ```text
732
- PostToolUse hook fires
733
- -> SHA-256 dedup (5min window)
734
- -> Privacy filter (strip secrets, API keys)
735
- -> Store raw observation
736
- -> LLM compress -> structured facts + concepts + narrative
737
- -> Vector embedding (6 providers + local)
738
- -> Index in BM25 + vector
739
-
740
- Stop / SessionEnd hook fires
741
- -> Summarize session
742
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
743
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
744
-
745
- SessionStart hook fires
746
- -> Load project profile (top concepts, files, patterns)
747
- -> Hybrid search (BM25 + vector + graph)
748
- -> Token budget (default: 2000 tokens)
749
- -> Inject into conversation
750
- ```
751
-
752
- ### Consolidação de memória em 4 níveis
753
-
754
- Inspirada em como o cérebro humano processa memória — não muito diferente da consolidação do sono.
755
-
756
- | Nível | O quê | Analogia |
757
- |------|------|---------|
758
- | **Working** | Observações brutas a partir do uso de tools | Memória de curto prazo |
759
- | **Episodic** | Resumos de sessão comprimidos | "O que aconteceu" |
760
- | **Semantic** | Fatos e padrões extraídos | "O que eu sei" |
761
- | **Procedural** | Workflows e padrões de decisão | "Como fazer" |
762
-
763
- As memórias decaem com o tempo (curva de Ebbinghaus). Memórias acessadas com frequência se reforçam. Memórias velhas são evictadas automaticamente. Contradições são detectadas e resolvidas.
764
-
765
- ### O que é capturado
766
-
767
- | Hook | Captura |
768
- |------|----------|
769
- | `SessionStart` | Caminho do projeto, ID da sessão |
770
- | `UserPromptSubmit` | Prompts do usuário (filtrados por privacidade) |
771
- | `PreToolUse` | Padrões de acesso a arquivos + contexto enriquecido |
772
- | `PostToolUse` | Nome da tool, entrada, saída |
773
- | `PostToolUseFailure` | Contexto do erro |
774
- | `PreCompact` | Reinjeta memória antes da compactação |
775
- | `SubagentStart/Stop` | Ciclo de vida de sub-agentes |
776
- | `Stop` | Resumo de fim de sessão |
777
- | `SessionEnd` | Marcador de sessão completa |
778
-
779
- ### Principais capacidades
780
-
781
- | Capacidade | Descrição |
782
- |---|---|
783
- | **Captura automática** | Todo uso de tool registrado via hooks — esforço manual zero |
784
- | **Busca semântica** | BM25 + vector + grafo de conhecimento com fusão RRF |
785
- | **Evolução de memória** | Versionamento, supersessão, grafos de relacionamento |
786
- | **Auto-esquecimento** | Expiração por TTL, detecção de contradição, evicção por importância |
787
- | **Privacy first** | API keys, segredos e tags `<private>` são removidos antes do armazenamento |
788
- | **Self-healing** | Circuit breaker, cadeia de fallback de providers, monitoramento de saúde |
789
- | **Ponte Claude** | Sincronização bidirecional com MEMORY.md |
790
- | **Grafo de conhecimento** | Extração de entidades + travessia BFS |
791
- | **Memória de time** | Compartilhado namespaced + privado entre membros do time |
792
- | **Provenance de citação** | Rastreia qualquer memória de volta às observações originais |
793
- | **Snapshots Git** | Versiona, faz rollback e diff do estado de memória |
794
-
795
- ---
796
-
797
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Busca" height="32" /></picture></h2>
798
-
799
- Recuperação triple-stream combinando três sinais:
800
-
801
- | Stream | O que faz | Quando |
802
- |---|---|---|
803
- | **BM25** | Matching de palavra-chave com stemming + expansão de sinônimos | Sempre ativo |
804
- | **Vector** | Similaridade de cosseno sobre embeddings densos | Provider de embedding configurado |
805
- | **Graph** | Travessia do grafo de conhecimento via matching de entidades | Entidades detectadas na query |
806
-
807
- Fundidos com Reciprocal Rank Fusion (RRF, k=60) e diversificados por sessão (máximo de 3 resultados por sessão).
808
-
809
- BM25 tokeniza grego, cirílico, hebraico, árabe e latim acentuado de fábrica. Para memórias em chinês / japonês / coreano, instale os segmentadores opcionais (`npm install @node-rs/jieba tiny-segmenter`) para quebrar runs CJK em tokens em nível de palavra; sem eles, o agentmemory faz soft-fallback para tokenização por run inteiro e imprime uma dica única no stderr.
810
-
811
- ### Providers de embedding
812
-
813
- agentmemory autodetecta seu provider. Para melhores resultados, instale embeddings locais (gratuito):
814
-
815
- ```bash
816
- npm install @xenova/transformers
817
- ```
818
-
819
- | Provider | Modelo | Custo | Notas |
820
- |---|---|---|---|
821
- | **Local (recomendado)** | `all-MiniLM-L6-v2` | Gratuito | Offline, +8pp de recall sobre BM25-only |
822
- | Gemini | `gemini-embedding-001` | Free tier | 100+ idiomas, 768/1536/3072 dims (MRL), entrada de 2048 tokens. Substitui `text-embedding-004` ([deprecado, encerramento em 14 de janeiro de 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
823
- | OpenAI | `text-embedding-3-small` | $0.02/1M | Maior qualidade |
824
- | Voyage AI | `voyage-code-3` | Pago | Otimizado para código |
825
- | Cohere | `embed-english-v3.0` | Trial gratuito | Uso geral |
826
- | OpenRouter | Qualquer modelo | Varia | Proxy multi-modelo |
827
-
828
- ---
829
-
830
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Servidor MCP" height="32" /></picture></h2>
831
-
832
- 53 tools, 6 resources, 3 prompts e 4 skills — o toolkit MCP de memória mais completo para qualquer agente.
833
-
834
- > **Shim MCP vs servidor completo:** o pacote publicado `@agentmemory/mcp` é um shim fino. Expõe a superfície completa de 51 tools **apenas quando consegue alcançar um servidor agentmemory em execução** via `AGENTMEMORY_URL` (modo proxy). Sem servidor acessível, o shim cai para um set local de 7 tools (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). A variável de ambiente `AGENTMEMORY_TOOLS=core|all` é uma flag *do lado do servidor* — defini-la no bloco `env` do shim não tem efeito. Se você vê só 7 tools no Cursor / OpenCode / Gemini CLI, inicie `npx @agentmemory/agentmemory` (ou a stack Docker) e defina `AGENTMEMORY_URL=http://localhost:3111`.
835
-
836
- ### 51 Tools
837
-
838
- <details>
839
- <summary>Tools principais (sempre disponíveis)</summary>
840
-
841
- | Tool | Descrição |
842
- |------|-------------|
843
- | `memory_recall` | Busca observações passadas |
844
- | `memory_compress_file` | Comprime arquivos markdown preservando a estrutura |
845
- | `memory_save` | Salva um insight, decisão ou padrão |
846
- | `memory_patterns` | Detecta padrões recorrentes |
847
- | `memory_smart_search` | Busca híbrida semântica + por palavras |
848
- | `memory_file_history` | Observações passadas sobre arquivos específicos |
849
- | `memory_sessions` | Lista sessões recentes |
850
- | `memory_timeline` | Observações cronológicas |
851
- | `memory_profile` | Perfil de projeto (conceitos, arquivos, padrões) |
852
- | `memory_export` | Exporta todos os dados de memória |
853
- | `memory_relations` | Consulta o grafo de relacionamentos |
854
-
855
- </details>
856
-
857
- <details>
858
- <summary>Tools estendidas (51 no total — defina AGENTMEMORY_TOOLS=all)</summary>
859
-
860
- | Tool | Descrição |
861
- |------|-------------|
862
- | `memory_patterns` | Detecta padrões recorrentes |
863
- | `memory_timeline` | Observações cronológicas |
864
- | `memory_relations` | Consulta o grafo de relacionamentos |
865
- | `memory_graph_query` | Travessia do grafo de conhecimento |
866
- | `memory_consolidate` | Executa a consolidação de 4 níveis |
867
- | `memory_claude_bridge_sync` | Sincroniza com MEMORY.md |
868
- | `memory_team_share` | Compartilha com membros do time |
869
- | `memory_team_feed` | Itens compartilhados recentes |
870
- | `memory_audit` | Trilha de auditoria de operações |
871
- | `memory_governance_delete` | Deleção com trilha de auditoria |
872
- | `memory_snapshot_create` | Snapshot versionado no Git |
873
- | `memory_action_create` | Cria itens de trabalho com dependências |
874
- | `memory_action_update` | Atualiza status de action |
875
- | `memory_frontier` | Actions desbloqueadas ranqueadas por prioridade |
876
- | `memory_next` | A única action mais importante a seguir |
877
- | `memory_lease` | Leases exclusivos de actions (multiagente) |
878
- | `memory_routine_run` | Instancia rotinas de workflow |
879
- | `memory_signal_send` | Mensageria entre agentes |
880
- | `memory_signal_read` | Lê mensagens com confirmação de recebimento |
881
- | `memory_checkpoint` | Portões de condições externas |
882
- | `memory_mesh_sync` | Sincronização P2P entre instâncias |
883
- | `memory_sentinel_create` | Watchers dirigidos por eventos |
884
- | `memory_sentinel_trigger` | Dispara sentinels externamente |
885
- | `memory_sketch_create` | Grafos de actions efêmeros |
886
- | `memory_sketch_promote` | Promove para permanente |
887
- | `memory_crystallize` | Compacta cadeias de actions |
888
- | `memory_diagnose` | Health checks |
889
- | `memory_heal` | Corrige automaticamente estado travado |
890
- | `memory_facet_tag` | Tags dimension:value |
891
- | `memory_facet_query` | Consulta por tags de facet |
892
- | `memory_verify` | Rastreia provenance |
893
-
894
- </details>
895
-
896
- ### 6 Resources · 3 Prompts · 4 Skills
897
-
898
- | Tipo | Nome | Descrição |
899
- |------|------|-------------|
900
- | Resource | `agentmemory://status` | Saúde, contagem de sessões, contagem de memórias |
901
- | Resource | `agentmemory://project/{name}/profile` | Inteligência por projeto |
902
- | Resource | `agentmemory://memories/latest` | As 10 memórias ativas mais recentes |
903
- | Resource | `agentmemory://graph/stats` | Estatísticas do grafo de conhecimento |
904
- | Prompt | `recall_context` | Busca + retorna mensagens de contexto |
905
- | Prompt | `session_handoff` | Dados de handoff entre agentes |
906
- | Prompt | `detect_patterns` | Analisa padrões recorrentes |
907
- | Skill | `/recall` | Busca na memória |
908
- | Skill | `/remember` | Salva na memória de longo prazo |
909
- | Skill | `/session-history` | Resumos recentes de sessões |
910
- | Skill | `/forget` | Deleta observações/sessões |
911
-
912
- ### MCP standalone
913
-
914
- Rode sem o servidor completo — para qualquer cliente MCP. Qualquer um destes funciona:
915
-
916
- ```bash
917
- npx -y @agentmemory/agentmemory mcp # canonical (always available)
918
- npx -y @agentmemory/mcp # shim package alias
919
- ```
920
-
921
- Ou adicione à configuração MCP do seu agente:
922
-
923
- A maioria dos agentes (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
924
- ```json
925
- {
926
- "mcpServers": {
927
- "agentmemory": {
928
- "command": "npx",
929
- "args": ["-y", "@agentmemory/mcp"],
930
- "env": {
931
- "AGENTMEMORY_URL": "http://localhost:3111"
932
- }
933
- }
934
- }
935
- }
936
- ```
937
-
938
- Mescle a entrada `agentmemory` no objeto `mcpServers` existente do seu host em vez de substituir o arquivo. Para clientes em sandbox que não conseguem alcançar o `localhost` do host, adicione `"AGENTMEMORY_FORCE_PROXY": "1"` ao bloco env e defina `AGENTMEMORY_URL` para uma rota que o sandbox alcance.
939
-
940
- OpenCode (`opencode.json`):
941
- ```json
942
- {
943
- "mcp": {
944
- "agentmemory": {
945
- "type": "local",
946
- "command": ["npx", "-y", "@agentmemory/mcp"],
947
- "enabled": true
948
- }
949
- },
950
- "plugin": ["./plugins/agentmemory-capture.ts"]
951
- }
952
- ```
953
-
954
- Copie o arquivo do plugin do repo:
955
- ```bash
956
- mkdir -p ~/.config/opencode/plugins
957
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
958
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
959
- ```
960
-
961
- ---
962
-
963
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Viewer em tempo real" height="32" /></picture></h2>
964
-
965
- Sobe automaticamente na porta `3113`. Stream ao vivo de observações, explorador de sessões, navegador de memórias, visualização do grafo de conhecimento e dashboard de saúde.
966
-
967
- ```bash
968
- open http://localhost:3113
969
- ```
970
-
971
- O servidor do viewer faz bind em `127.0.0.1` por padrão. O endpoint servido por REST `/agentmemory/viewer` segue as regras normais de bearer-token `AGENTMEMORY_SECRET`. Os headers CSP usam um nonce de script por resposta e desabilitam atributos de handler inline (`script-src-attr 'none'`).
972
-
973
- ---
974
-
975
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
976
-
977
- O viewer em `:3113` mostra o que seu agente **lembrou**. O [iii console](https://iii.dev/docs/console) mostra o que seu agente **fez** — cada operação de memória como uma trace do OpenTelemetry, cada entrada KV editável, cada função invocável, cada stream observável. Duas janelas sobre a mesma memória: uma em formato de produto, outra em formato de engine.
978
-
979
- Veja um `memory_smart_search` disparar e enxergue o scan BM25 → busca de embedding → fusão RRF → reranker como um waterfall. Edite um timer de consolidação travado no navegador KV. Reproduza um hook `PostToolUse` com payload ajustado. Fixe o stream WebSocket e veja as observações chegando ao vivo.
980
-
981
- agentmemory oferece isso de graça porque toda função, trigger, escopo de estado e stream é um primitivo iii — nada custom, nada para instrumentar.
982
-
983
- <p align="center">
984
- <img src="../assets/iii-console/workers.png" alt="Página Workers do iii console — workers conectados incluindo instâncias do agentmemory com contagem de funções ao vivo e metadados de runtime" width="720" />
985
- <br/>
986
- <em>Página Workers: todo worker conectado — incluindo o próprio agentmemory — com PID, contagem de funções, runtime e last-seen.</em>
987
- </p>
988
-
989
- **Já instalado.** O console vem junto com `iii` — sem instalador separado.
990
-
991
- **Suba junto com o agentmemory:**
992
-
993
- ```bash
994
- # agentmemory viewer holds port 3113, so run the console on 3114.
995
- # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
996
- iii console --port 3114
997
- ```
998
-
999
- Depois abra `http://localhost:3114`. Adicione `--enable-flow` para a página experimental de grafo de arquitetura.
1000
-
1001
- Sobrescreva endpoints do engine apenas se você os tiver movido:
1002
-
1003
- ```bash
1004
- iii console --port 3114 \
1005
- --engine-port 3111 \
1006
- --ws-port 3112 \
1007
- --bridge-port 49134
1008
- ```
1009
-
1010
- **O que você pode fazer pelo console:**
1011
-
1012
- | Página | Use para |
1013
- |------|-----------|
1014
- | **Workers** | Ver todo worker conectado e suas métricas ao vivo — incluindo o próprio worker do agentmemory. |
1015
- | **Functions** | Invocar qualquer função do agentmemory diretamente com um payload JSON — útil para testar `memory.recall`, `memory.consolidate`, `graph.query` sem cabear um cliente. |
1016
- | **Triggers** | Reproduzir triggers HTTP, cron, event e state — disparar o cron de consolidação manualmente, reexecutar uma rota HTTP, emitir uma mudança de estado. |
1017
- | **States** | Navegador KV com CRUD completo — sessões, slots de memória, timers de ciclo de vida, índice de embeddings — edite valores no lugar. |
1018
- | **Streams** | Monitor WebSocket ao vivo para escritas de memória, eventos de hook e atualizações de observação à medida que fluem pelos streams iii. |
1019
- | **Queues** | Tópicos de fila duráveis + gestão de dead-letter. Reproduza ou descarte jobs de embedding / compressão que falharam. |
1020
- | **Traces** | Vistas waterfall / flame / breakdown por serviço do OpenTelemetry. Filtre por `trace_id` para ver exatamente quais funções, chamadas a DB e requisições de embedding um único `memory.search` produziu. |
1021
- | **Logs** | Logs OTEL estruturados filtrados e correlacionados a trace/span IDs. |
1022
- | **Config** | Configuração de runtime — veja exatamente com quais workers, providers e portas seu engine está rodando. |
1023
- | **Flow** | (Opcional, `--enable-flow`) Grafo de arquitetura interativo de todo worker, trigger e stream. |
1024
-
1025
- <p align="center">
1026
- <img src="../assets/iii-console/traces-waterfall.png" alt="Visão waterfall de trace do iii console mostrando duração por span" width="720" />
1027
- <br/>
1028
- <em>Traces: waterfall / flame / breakdown por serviço para toda operação de memória.</em>
1029
- </p>
1030
-
1031
- **Traces já estão ativos:**
1032
-
1033
- `iii-config.yaml` vem com o worker `iii-observability` habilitado (`exporter: memory`, `sampling_ratio: 1.0`, métricas + logs). Sem configuração extra — no momento em que o agentmemory inicia, toda operação de memória emite um trace span e um log estruturado que o console consegue ler.
1034
-
1035
- Se você quiser exportar para Jaeger/Honeycomb/Grafana Tempo, troque `exporter: memory` por `exporter: otlp` e configure o endpoint do collector conforme a documentação de observabilidade do iii.
1036
-
1037
- > **Aviso:** nenhum auth é aplicado no console em si — mantenha-o em bind em `127.0.0.1` (o padrão) e nunca o exponha publicamente.
1038
-
1039
- ---
1040
-
1041
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1042
-
1043
- agentmemory **já é uma instância [iii](https://iii.dev) em execução**. Funções, triggers, estado KV, streams, traces OTEL — tudo são primitivos iii. Você não instalou Postgres, Redis, Express, pm2 ou Prometheus, porque o iii os substitui.
1044
-
1045
- Isso significa que mais um comando estende o agentmemory com uma capacidade totalmente nova.
1046
-
1047
- ### Estenda o agentmemory com um comando
1048
-
1049
- ```bash
1050
- iii worker add iii-pubsub # fan memory writes out to every connected instance
1051
- iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1052
- iii worker add iii-queue # durable retries for embedding + compression jobs
1053
- iii worker add iii-observability # OTEL traces on every memory op (default on)
1054
- iii worker add iii-sandbox # run recalled code inside an isolated microVM
1055
- iii worker add iii-database # swap in a SQL-backed state adapter
1056
- iii worker add mcp # generic MCP host alongside the agentmemory MCP
1057
- ```
1058
-
1059
- Cada `iii worker add` registra novas funções e triggers no mesmo engine onde o agentmemory já está rodando. O viewer e o console os reconhecem na hora — sem reload, sem nova integração, sem novo contêiner.
1060
-
1061
- | `iii worker add` | O que você ganha em cima do agentmemory |
1062
- |---|---|
1063
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Memória multi-instância: todo `remember` faz fanout, todo `search` lê a união |
1064
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Ciclo de vida agendado — consolidação noturna, snapshots semanais, decaimento em relógio fixo |
1065
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Retries duráveis: jobs falhos de embedding + compressão sobrevivem a restart, sem observações perdidas |
1066
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Traces OTEL, métricas, logs em toda função — cabeado em `iii-config.yaml` desde o primeiro dia |
1067
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Código que veio do `memory_recall` roda dentro de uma VM descartável, não no seu shell |
1068
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptador de estado baseado em SQL quando você ultrapassa o KV in-memory padrão |
1069
- | [`mcp`](https://workers.iii.dev/workers/mcp) | Suba servidores MCP adicionais ao lado do MCP do agentmemory, compartilhando o mesmo engine |
1070
-
1071
- Registry completo: [workers.iii.dev](https://workers.iii.dev). Todo worker lá se compõe pelos mesmos primitivos que o agentmemory usa — e o agentmemory que você já tem é um deles.
1072
-
1073
- ### O que o iii substitui
1074
-
1075
- | Stack tradicional | agentmemory usa |
1076
- |---|---|
1077
- | Express.js / Fastify | iii HTTP Triggers |
1078
- | SQLite / Postgres + pgvector | iii KV State + índice vetorial in-memory |
1079
- | SSE / Socket.io | iii Streams (WebSocket) |
1080
- | pm2 / systemd | Supervisão de workers do iii engine |
1081
- | Prometheus / Grafana | iii OTEL + monitor de saúde |
1082
- | Sistemas de plugin customizados | `iii worker add <name>` |
1083
-
1084
- **118 arquivos de código · ~21.800 LOC · 950+ tests · 123 funções · 34 escopos KV** — tudo em cima de três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
1085
-
1086
- ---
1087
-
1088
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuração" height="32" /></picture></h2>
1089
-
1090
- ### Providers de LLM
1091
-
1092
- agentmemory autodetecta a partir do seu ambiente. Por padrão, nenhuma chamada LLM é feita a menos que você configure um provider ou opte explicitamente pelo fallback de assinatura do Claude.
1093
-
1094
- | Provider | Config | Notas |
1095
- |----------|--------|-------|
1096
- | **No-op (padrão)** | Sem configuração | Compress/summarize via LLM DESATIVADO. Compressão sintética BM25 + recall ainda funcionam. Veja `AGENTMEMORY_ALLOW_AGENT_SDK` abaixo se você dependia do fallback de assinatura do Claude. |
1097
- | Anthropic API | `ANTHROPIC_API_KEY` | Cobrança por token |
1098
- | MiniMax | `MINIMAX_API_KEY` | Compatível com Anthropic |
1099
- | Gemini | `GEMINI_API_KEY` | Também habilita embeddings |
1100
- | OpenRouter | `OPENROUTER_API_KEY` | Qualquer modelo |
1101
- | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Apenas opt-in. Cria sessões de `@anthropic-ai/claude-agent-sdk` — costumava causar recursão sem limite no Stop-hook (seguimento do #149), por isso não é mais o padrão. |
1102
-
1103
- ### Seleção de modelo com consciência de custo
1104
-
1105
- A compressão em background roda em toda observação, então a escolha de modelo muda o gasto mensal de forma significativa. Dados de workload capturados: 635 requisições / 888K tokens / 35 horas de uso ativo, executados contra três modelos OpenRouter a preços de 2026-05-23.
1106
-
1107
- | Tier | Modelo | Input / 1M | Output / 1M | Custo para as 35h capturadas | Notas |
1108
- |------|-------|------------|-------------|---------------------------|-------|
1109
- | Recomendado | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Qualidade sólida de compressão + sumarização a um custo ~10× menor que o Sonnet. |
1110
- | Recomendado | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Mais antigo mas ainda OK para workloads só de compressão. |
1111
- | Recomendado | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Bom raciocínio de código se suas sessões forem muito orientadas a código. |
1112
- | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Alta qualidade, mas caro para trabalho de background sempre ativo. |
1113
- | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Tier similar ao Sonnet. |
1114
- | Evitar | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Modelo classe reasoning; gasto desproporcional para compressão. |
1115
-
1116
- agentmemory imprime um aviso em runtime quando `OPENROUTER_MODEL` casa com um padrão de tier premium. Defina `AGENTMEMORY_SUPPRESS_COST_WARNING=1` para silenciar depois que você tiver tomado uma decisão informada.
1117
-
1118
- Trade-off qualidade vs custo para trabalho de memória: compressão é uma tarefa de sumarização com critério de qualidade relativamente frouxo (quem relê o resumo é o agente, não o usuário). DeepSeek-V4-Pro / Qwen3-Coder ficam dentro do erro de arredondamento do Sonnet nessa tarefa, custando ~10× menos. Reserve os modelos tier premium para as queries que você lê diretamente.
1119
-
1120
- Fontes: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1121
-
1122
- ### Memória multiagente (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1123
-
1124
- Em setups multiagente onde vários papéis compartilham um servidor agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` etiqueta cada escrita com o papel que a fez. `AGENTMEMORY_AGENT_SCOPE` controla se o recall filtra por essa tag.
1125
-
1126
- ```env
1127
- TEAM_ID=company
1128
- USER_ID=engineering-team
1129
- AGENT_ID=architect
1130
- AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1131
- ```
1132
-
1133
- Dois modos:
1134
-
1135
- | Modo | Etiqueta escritas | Filtra recall | Quando usar |
1136
- |------|------------|---------------|-------------|
1137
- | `shared` (padrão) | sim | não | Contexto cross-agent com trilha de auditoria. O architect pode ver o que o developer anotou, mas toda linha registra quem disse. |
1138
- | `isolated` | sim | sim | Separação estrita. O architect nunca vê observações / memórias / sessões do developer. |
1139
-
1140
- O que é etiquetado quando `AGENT_ID` está definido: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. O papel flui `api::session::start` → `mem::observe` → `mem::compress` → KV.
1141
-
1142
- O que é filtrado no modo isolated: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Cada endpoint aceita `?agentId=<role>` para sobrescrever por requisição, e `?agentId=*` para sair do escopo do env por completo. `/memories` também aceita `?includeOrphans=true` para mostrar memórias pré-AGENT_ID cujo `agentId` é undefined.
1143
-
1144
- Override por chamada na camada SDK / REST: todo endpoint mutador (`/session/start`, `/remember`) aceita um campo `agentId` no body da requisição que vence o env. Útil para runtimes que roteiam muitos papéis por um único processo de servidor.
1145
-
1146
- Quando `AGENT_ID` não está definido, a memória permanece sem escopo (comportamento legado, sem tags, sem filtros).
1147
-
1148
- ### Portas
1149
-
1150
- agentmemory + iii-engine fazem bind em quatro portas por padrão. Se um restart falhar com `port in use`, esta tabela diz qual processo procurar.
1151
-
1152
- | Porta | Processo | Propósito | Override por env |
1153
- |------|---------|---------|--------------|
1154
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1155
- | `3112` | iii-engine | Worker de streams interno (consumido por agentmemory + viewer) | `III_STREAMS_PORT` |
1156
- | `3113` | agentmemory | Viewer em tempo real (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1157
- | `49134` | iii-engine | WebSocket — workers se registram aqui, telemetria OTel flui por cima | `III_ENGINE_URL` (URL completa, padrão `ws://localhost:49134`) |
1158
-
1159
- Limpeza de processo travado quando as portas ficam ocupadas após uma execução crashada:
1160
-
1161
- ```bash
1162
- # macOS / Linux — find whatever is on each port and kill it
1163
- lsof -i :3111,3112,3113,49134
1164
- pkill -f agentmemory || true
1165
- pkill -f 'iii ' || true
1166
-
1167
- # Windows
1168
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1169
- taskkill /F /PID <pid>
1170
- ```
1171
-
1172
- `agentmemory stop` recolhe tanto o worker quanto o pidfile do engine de forma limpa no shutdown graceful (#640, #474). A limpeza manual acima só serve para o caso pós-crash em que nenhum pidfile foi deixado para trás.
1173
-
1174
- ### Arquivo de configuração
1175
-
1176
- Coloque a configuração de runtime do agentmemory em `~/.agentmemory/.env` em vez de exportar variáveis em cada shell. Se o viewer mostrar uma dica de setup como `export ANTHROPIC_API_KEY=...`, copie para este arquivo como `ANTHROPIC_API_KEY=...` sem o prefixo `export`, depois reinicie o agentmemory.
1177
-
1178
- Variáveis de ambiente do processo continuam funcionando e têm precedência sobre os valores no arquivo.
1179
-
1180
- No Windows, o mesmo arquivo fica em `%USERPROFILE%\.agentmemory\.env`:
1181
-
1182
- ```powershell
1183
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1184
- notepad $HOME\.agentmemory\.env
1185
- ```
1186
-
1187
- Para testar com uma assinatura Claude Code Pro/Max em vez de uma API key, faça opt-in explícito:
1188
-
1189
- ```env
1190
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1191
- AGENTMEMORY_AUTO_COMPRESS=true
1192
- ```
1193
-
1194
- Ligue features de graph ou consolidation no mesmo arquivo se quiser:
1195
-
1196
- ```env
1197
- GRAPH_EXTRACTION_ENABLED=true
1198
- CONSOLIDATION_ENABLED=true
1199
- ```
1200
-
1201
- ### Variáveis de ambiente
1202
-
1203
- Crie `~/.agentmemory/.env`:
1204
-
1205
- ```env
1206
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1207
- # ANTHROPIC_API_KEY=sk-ant-...
1208
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1209
- # GEMINI_API_KEY=...
1210
- # OPENROUTER_API_KEY=...
1211
- # MINIMAX_API_KEY=...
1212
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1213
- # # OpenAI LLM provider (here) AND the OpenAI
1214
- # # embedding provider (further below). Set
1215
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1216
- # # to embeddings only.
1217
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1218
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1219
- # # Auto-detected from `.openai.azure.com` hostname; uses
1220
- # # api-key header + api-version query param.
1221
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1222
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1223
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1224
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1225
- # # for back-compat with v0.9.17. New configs should
1226
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1227
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1228
- # # Honored only by OpenAI's reasoning models (o1, o3,
1229
- # # gpt-*-reasoning) and providers that mirror that
1230
- # # schema (Ollama Cloud thinking models). Standard
1231
- # # chat models reject this field with 400. Set to
1232
- # # "none" for thinking models that return reasoning
1233
- # # but no content.
1234
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1235
- # # for LLM (useful if you only want OpenAI for embeddings)
1236
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1237
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1238
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1239
-
1240
- # Embedding provider (auto-detected, or override)
1241
- # EMBEDDING_PROVIDER=local
1242
- # VOYAGE_API_KEY=...
1243
- # OPENAI_API_KEY=sk-...
1244
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1245
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1246
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1247
-
1248
- # Outbound LLM / embedding timeout
1249
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1250
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1251
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1252
- # embedding). For the OpenAI LLM path, the
1253
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1254
- # takes precedence when set, for back-compat
1255
- # with v0.9.17.
1256
- # Increase for slow networks or large batch calls;
1257
- # decrease to fail-fast on rate-limit holds.
1258
-
1259
- # Search tuning
1260
- # BM25_WEIGHT=0.4
1261
- # VECTOR_WEIGHT=0.6
1262
- # TOKEN_BUDGET=2000
1263
-
1264
- # Auth
1265
- # AGENTMEMORY_SECRET=your-secret
1266
-
1267
- # Ports (defaults: 3111 API, 3113 viewer)
1268
- # III_REST_PORT=3111
1269
-
1270
- # Features
1271
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1272
- # every PostToolUse hook calls your
1273
- # LLM provider to compress the
1274
- # observation — expect significant
1275
- # token spend on active sessions.
1276
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1277
- # memory slots — persona,
1278
- # user_preferences, tool_guidelines,
1279
- # project_context, guidance,
1280
- # pending_items, session_patterns,
1281
- # self_notes. Size-limited; agent
1282
- # edits via memory_slot_* tools.
1283
- # Pinned slots addressable for
1284
- # SessionStart injection.
1285
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1286
- # Stop hook fires mem::slot-reflect:
1287
- # scans recent observations, auto-
1288
- # appends TODOs to pending_items,
1289
- # counts patterns in
1290
- # session_patterns, records touched
1291
- # files in project_context. Fire-
1292
- # and-forget; does not block.
1293
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1294
- # - SessionStart may inject ~1-2K
1295
- # chars of project context into
1296
- # the first turn of each session
1297
- # (this is what actually reaches
1298
- # the model — Claude Code treats
1299
- # SessionStart stdout as context)
1300
- # - PreToolUse fires /agentmemory/enrich
1301
- # on every file-touching tool call
1302
- # (resource cleanup, not a token
1303
- # fix — PreToolUse stdout is debug
1304
- # log only per Claude Code docs)
1305
- # Observations are still captured via
1306
- # PostToolUse regardless of this flag.
1307
- # GRAPH_EXTRACTION_ENABLED=false
1308
- # CONSOLIDATION_ENABLED=true
1309
- # LESSON_DECAY_ENABLED=true
1310
- # OBSIDIAN_AUTO_EXPORT=false
1311
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1312
- # CLAUDE_MEMORY_BRIDGE=false
1313
- # SNAPSHOT_ENABLED=false
1314
-
1315
- # Team
1316
- # TEAM_ID=
1317
- # USER_ID=
1318
- # TEAM_MODE=private
1319
-
1320
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1321
- # AGENTMEMORY_TOOLS=core
1322
- ```
1323
-
1324
- ---
1325
-
1326
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1327
-
1328
- 124 endpoints na porta `3111`. A REST API faz bind em `127.0.0.1` por padrão. Endpoints protegidos exigem `Authorization: Bearer <secret>` quando `AGENTMEMORY_SECRET` está definido, e endpoints de mesh sync exigem `AGENTMEMORY_SECRET` em ambos os peers.
1329
-
1330
- <details>
1331
- <summary>Endpoints principais</summary>
1332
-
1333
- | Method | Path | Descrição |
1334
- |--------|------|-------------|
1335
- | `GET` | `/agentmemory/health` | Health check (sempre público) |
1336
- | `POST` | `/agentmemory/session/start` | Inicia sessão + obtém contexto |
1337
- | `POST` | `/agentmemory/session/end` | Encerra sessão |
1338
- | `POST` | `/agentmemory/observe` | Captura observação |
1339
- | `POST` | `/agentmemory/smart-search` | Busca híbrida |
1340
- | `POST` | `/agentmemory/context` | Gera contexto |
1341
- | `POST` | `/agentmemory/remember` | Salva na memória de longo prazo |
1342
- | `POST` | `/agentmemory/forget` | Deleta observações |
1343
- | `POST` | `/agentmemory/enrich` | Contexto de arquivo + memórias + bugs |
1344
- | `GET` | `/agentmemory/profile` | Perfil de projeto |
1345
- | `GET` | `/agentmemory/export` | Exporta todos os dados |
1346
- | `POST` | `/agentmemory/import` | Importa de JSON |
1347
- | `POST` | `/agentmemory/graph/query` | Query do grafo de conhecimento |
1348
- | `POST` | `/agentmemory/team/share` | Compartilha com o time |
1349
- | `GET` | `/agentmemory/audit` | Trilha de auditoria |
1350
-
1351
- Lista completa de endpoints: [`src/triggers/api.ts`](../src/triggers/api.ts)
1352
-
1353
- </details>
1354
-
1355
- ---
1356
-
1357
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Desenvolvimento" height="32" /></picture></h2>
1358
-
1359
- ```bash
1360
- npm run dev # Hot reload
1361
- npm run build # Production build
1362
- npm test # 950+ tests
1363
- npm run test:integration # API tests (requires running services)
1364
- ```
1365
-
1366
- **Pré-requisitos:** Node.js >= 20, [iii-engine](https://iii.dev/docs) ou Docker
1367
-
1368
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licença" height="32" /></picture></h2>
1369
-
1370
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.ru-RU.md DELETED
The diff for this file is too large to render. See raw diff
 
READMEs/README.tr-TR.md DELETED
@@ -1,1381 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — AI kodlama ajanları için kalıcı bellek" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- Kodlama ajanınız her şeyi hatırlasın. Aynı şeyi bir daha açıklamayın.
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode ve her MCP istemcisi için kalıcı bellek.
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- Türkçe |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>Bu gist, Karpathy'nin LLM Wiki desenini güven puanlaması, yaşam döngüsü, bilgi grafları ve hibrit aramayla genişletir: agentmemory bunun uygulamasıdır.</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">Kurulum</a> &bull;
73
- <a href="#quick-start">Hızlı Başlangıç</a> &bull;
74
- <a href="#benchmarks">Kıyaslamalar</a> &bull;
75
- <a href="#vs-competitors">Rakiplerle Karşılaştırma</a> &bull;
76
- <a href="#works-with-every-agent">Ajanlar</a> &bull;
77
- <a href="#how-it-works">Nasıl Çalışır</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">Görüntüleyici</a> &bull;
80
- <a href="#iii-console">iii Konsolu</a> &bull;
81
- <a href="#powered-by-iii">iii ile çalışır</a> &bull;
82
- <a href="#configuration">Yapılandırma</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## Kurulum
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # bir kez — `agentmemory` PATH'te kullanılabilir
92
- # macOS/Linux sistem Node kurulumlarında EACCES hatası alırsanız şununla deneyin:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # bellek sunucusunu :3111 üzerinde başlat
95
- agentmemory demo # örnek oturumlar yükle + recall'u kanıtla
96
- agentmemory connect claude-code # ajanınızı bağlayın (ayrıca: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- Veya `npx` ile (kurulum gerekmez):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- Dikkat — npx sürüm bazında önbelleğe alır. Eğer çıplak bir `npx @agentmemory/agentmemory` eski bir sürümü servis ediyorsa, en güncelini `npx -y @agentmemory/agentmemory@latest` ile zorlayın veya önbelleği `rm -rf ~/.npm/_npx` ile bir kez temizleyin (macOS/Linux; Windows'ta `%LOCALAPPDATA%\npm-cache\_npx` dizinini silin). v0.9.16+ sonrası ilk npx çalıştırması, çıplak `agentmemory` komutunun her yerden çalışması için global kurulum yapmanızı satır içi olarak sorar.
106
-
107
- Tüm seçenekler aşağıdaki [Hızlı Başlangıç](#quick-start) bölümünde. Ajana özel bağlantılar için [Her ajanla çalışır](#works-with-every-agent) bölümüne bakın.
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
-
113
- agentmemory; hook'ları, MCP'yi veya REST API'yi destekleyen her ajanla çalışır. Tüm ajanlar aynı bellek sunucusunu paylaşır.
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>yerel eklenti + 12 hook + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>yerel eklenti + 6 hook + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>yerel eklenti + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>yerel eklenti + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>yerel eklenti + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>yerel Memory trait arka uç</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP sunucusu</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP sunucusu</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hook + MCP + eklenti</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP sunucusu</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP sunucusu</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP sunucusu</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP sunucusu</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP sunucusu</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP sunucusu</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>MCP veya HTTP konuşan <strong>herhangi bir</strong> ajanla çalışır. Tek sunucu, tüm ajanlar arasında paylaşılan bellek.</sub>
204
- </p>
205
-
206
- ---
207
-
208
- Her oturumda aynı mimariyi tekrar tekrar anlatıyorsunuz. Aynı bug'ları yeniden keşfediyorsunuz. Aynı tercihleri yeniden öğretiyorsunuz. Yerleşik bellek (CLAUDE.md, .cursorrules) 200 satırda tıkanır ve eskir. agentmemory bunu düzeltir. Ajanınızın yaptıklarını sessizce yakalar, aranabilir belleğe sıkıştırır ve bir sonraki oturum başladığında doğru bağlamı enjekte eder. Tek komut. Ajanlar arası çalışır.
209
-
210
- **Neler değişiyor:** Oturum 1'de JWT kimlik doğrulamasını kuruyorsunuz. Oturum 2'de hız sınırlaması istiyorsunuz. Ajan zaten biliyor: kimlik doğrulamanız `src/middleware/auth.ts` içinde jose middleware kullanıyor, testleriniz token doğrulamasını kapsıyor ve Edge uyumluluğu için jsonwebtoken yerine jose'yi seçtiniz. Yeniden anlatma yok. Kopyala-yapıştır yok. Ajan basitçe *biliyor*.
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0'da yeni** — [agent-memory.dev](https://agent-memory.dev) tanıtım sitesi, dosya sistemi bağlayıcısı (`@agentmemory/fs-watcher`), bağımsız MCP artık çalışan sunucuya proxy yapıyor (böylece hook'lar ve görüntüleyici hemfikir), her silme yolunda kodlanmış denetim politikası, küçük Node süreçlerinde sağlık `memory_critical` olarak işaretlenmiyor. Tüm notlar [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) içinde.
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### Geri Getirme Doğruluğu
227
-
228
- **coding-agent-life-v1** (kurum içi corpus, sandbox-yeniden üretilebilir)
229
-
230
- | Adaptör | P@5 | R@5 | Top-5 isabet oranı | p50 gecikme |
231
- |---|---|---|---|---|
232
- | **agentmemory hibrit** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep referansı | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- %100 Top-5 isabet oranı. Aynı girdide grep referansından **2.2×** daha iyi hassasiyet. Tam tip bazında döküm: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
-
237
- **LongMemEval-S** (ICLR 2025, 500 soru)
238
-
239
- | Sistem | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | Yalnız BM25 yedeği | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Token Tasarrufu
248
-
249
- | Yaklaşım | Token/yıl | Maliyet/yıl |
250
- |---|---|---|
251
- | Tam bağlamı yapıştır | 19.5M+ | İmkansız (pencereyi aşar) |
252
- | LLM-özetlenmiş | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + yerel embedding | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > Embedding modeli: `all-MiniLM-L6-v2` (yerel, ücretsiz, API anahtarı gerekmez). Tam raporlar: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Rakip karşılaştırması: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory'nin mem0, Letta, Khoj, claude-mem, Hippo ile karşılaştırması.
261
-
262
- **Yerel olarak yeniden üretin:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s` (genel 500 soru) + `coding-agent-life-v1` (kurum içi 15 oturum corpus) için adaptör-takılabilir harness. Grep / vektör / agentmemory adaptörleri yan yana puanlanır, NDJSON çıktısı, yayımlanan puan tabloları [`docs/benchmarks/`](../docs/benchmarks/) içine düşer.
263
-
264
- **[codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) ve [Graphify](https://github.com/safishamsi/graphify) ile birlikte çalışır.** Kod-graf indeksleme, çok-ajanlı build pipeline'ları ve doküman / PDF / görsel / video boyunca daha geniş bilgi grafları. agentmemory çalışmayı hatırlar; bu üç proje bağlam katmanının geri kalanını aydınlatır. Tarifler + soru-yönlendirme tablosu: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">Yerleşik (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>Tür</strong></td>
280
- <td>Bellek motoru + MCP sunucusu</td>
281
- <td>Bellek katmanı API'si</td>
282
- <td>Tam ajan runtime'ı</td>
283
- <td>Statik dosya</td>
284
- </tr>
285
- <tr>
286
- <td><strong>Geri getirme R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>Otomatik yakalama</strong></td>
294
- <td>12 hook (sıfır manuel çaba)</td>
295
- <td>Manuel <code>add()</code> çağrıları</td>
296
- <td>Ajan kendi düzenler</td>
297
- <td>Manuel düzenleme</td>
298
- </tr>
299
- <tr>
300
- <td><strong>Arama</strong></td>
301
- <td>BM25 + Vektör + Graf (RRF füzyonu)</td>
302
- <td>Vektör + Graf</td>
303
- <td>Vektör (arşiv)</td>
304
- <td>Her şeyi bağlama yükler</td>
305
- </tr>
306
- <tr>
307
- <td><strong>Çoklu ajan</strong></td>
308
- <td>MCP + REST + lease'ler + sinyaller</td>
309
- <td>API (koordinasyon yok)</td>
310
- <td>Yalnızca Letta runtime'ı içinde</td>
311
- <td>Ajan başına dosya</td>
312
- </tr>
313
- <tr>
314
- <td><strong>Framework bağımlılığı</strong></td>
315
- <td>Yok (herhangi bir MCP istemcisi)</td>
316
- <td>Yok</td>
317
- <td>Yüksek (Letta kullanılmalı)</td>
318
- <td>Ajan başına format</td>
319
- </tr>
320
- <tr>
321
- <td><strong>Harici bağımlılıklar</strong></td>
322
- <td>Yok (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + vektör DB</td>
325
- <td>Yok</td>
326
- </tr>
327
- <tr>
328
- <td><strong>Bellek yaşam döngüsü</strong></td>
329
- <td>4 katmanlı konsolidasyon + decay + otomatik-unutma</td>
330
- <td>Pasif çıkarım</td>
331
- <td>Ajan-yönetimli</td>
332
- <td>Manuel ayıklama</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Token verimliliği</strong></td>
336
- <td>~1,900 token/oturum ($10/yıl)</td>
337
- <td>Entegrasyona göre değişir</td>
338
- <td>Çekirdek bellek bağlamda</td>
339
- <td>240 gözlemde 22K+ token</td>
340
- </tr>
341
- <tr>
342
- <td><strong>Gerçek zamanlı görüntüleyici</strong></td>
343
- <td>Var (port 3113)</td>
344
- <td>Bulut panel</td>
345
- <td>Bulut panel</td>
346
- <td>Yok</td>
347
- </tr>
348
- <tr>
349
- <td><strong>Self-hosted</strong></td>
350
- <td>Evet (varsayılan)</td>
351
- <td>İsteğe bağlı</td>
352
- <td>İsteğe bağlı</td>
353
- <td>Evet</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
-
361
- Uyumluluk: bu sürüm kararlı `iii-sdk` `^0.11.0` ve iii-engine v0.11.x'i hedefler.
362
-
363
- ### 30 saniyede deneyin
364
-
365
- ```bash
366
- # Terminal 1: sunucuyu başlatın
367
- npx @agentmemory/agentmemory
368
-
369
- # Terminal 2: örnek veriyi yükleyin ve geri çağırmayı iş başında görün
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo`, 3 gerçekçi oturum yükler (JWT auth, N+1 sorgu düzeltmesi, hız sınırlaması) ve bunlar üzerinde anlamsal aramalar çalıştırır. "veritabanı performans optimizasyonu" araması yaptığınızda "N+1 sorgu düzeltmesi"ni bulduğunu göreceksiniz — anahtar kelime eşleştirmesi bunu yapamaz.
374
-
375
- Belleğin canlı oluşumunu izlemek için `http://localhost:3113` adresini açın.
376
-
377
- ### Önerilen: globally kurun
378
-
379
- `npx` sürüm bazında önbelleğe alır. Geçen hafta `npx @agentmemory/agentmemory@0.9.14`'ü çalıştırdıysanız, çıplak bir `npx @agentmemory/agentmemory` `~/.npm/_npx/`'ten en son sürümü değil, eski 0.9.14'ü servis edebilir. Bir kez kurun ve çıplak `agentmemory` komutu her yerde çalışsın:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # macOS/Linux sistem Node kurulumlarında EACCES hatası alırsanız şununla deneyin:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # sunucuyu başlatın (npx şekliyle aynı)
386
- agentmemory stop # kapatın
387
- agentmemory remove # oluşturduğumuz her şeyi kaldırın
388
- agentmemory connect claude-code # tek bir ajanı bağlayın
389
- agentmemory doctor # interaktif teşhis + düzeltme istemleri
390
- ```
391
-
392
- v0.9.16 ve sonrası ile birlikte, ilk npx çalıştırması global kurmanızı satır içi olarak ister — bir kez `Y` yanıtlayın, hazırsınız. Atlarsanız, taze bir indirme için şunlardan birine geri dönün:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # npm'den en güncelini zorlar (platformlar arası)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # yalnız macOS/Linux (POSIX shell)
397
- ```
398
-
399
- Windows / PowerShell'de eşdeğer cache temizleme komutu `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` şeklindedir — yukarıdaki `npx -y ...@latest` formu platformlar arası seçenektir.
400
-
401
- ### Oturum Tekrar Oynatma (Session Replay)
402
-
403
- agentmemory'nin kaydettiği her oturum tekrar oynatılabilir. Görüntüleyiciyi açın, **Replay** sekmesini seçin ve zaman çizelgesini tarayın: istemler, araç çağrıları, araç sonuçları ve yanıtlar; oynat/duraklat, hız kontrolü (0.5×–4×) ve klavye kısayollarıyla (boşluk geçiş, oklar adım atlama) ayrı olaylar olarak görüntülenir.
404
-
405
- Halihazırda içeri aktarmak istediğiniz eski Claude Code JSONL kayıtlarınız mı var?
406
-
407
- ```bash
408
- # Varsayılan ~/.claude/projects altındaki her şeyi içeri aktar
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # Veya tek bir dosya içeri aktar
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- İçeri aktarılan oturumlar yerli olanların yanında Replay seçicisinde görünür. Arka planda her giriş `mem::replay::load`, `mem::replay::sessions` ve `mem::replay::import-jsonl` iii fonksiyonları üzerinden yönlendirilir — yan kanal sunucu yok.
416
-
417
- ### Yükseltme / Bakım
418
-
419
- Yerel runtime'ınızı bilinçli olarak güncellemek istediğinizde bakım komutunu kullanın:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- Uyarı: bu komut mevcut çalışma alanını/runtime'ı değiştirir. JavaScript bağımlılıklarını güncelleyebilir, `cargo install iii-engine --force` çalıştırabilir ve Docker imajlarını çekebilir.
426
-
427
- Uygulama detayları `src/cli.ts` içinde (`src/cli.ts:544-595` bölgesi civarında `runUpgrade`'a bakın).
428
-
429
- ### Claude Code (tek blok, yapıştırın)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Eklenti kurulumu olmadan Claude Code (MCP-bağımsız yol)
436
-
437
- Eğer `/plugin install` kullanmak yerine agentmemory'nin MCP sunucusunu doğrudan `~/.claude.json` üzerinden bağlarsanız, Claude Code `${CLAUDE_PLUGIN_ROOT}`'u asla çözmez ve hook scriptlerini `~/.claude/settings.json` içinde mutlak yollara işaret etmek zorunda kalırsınız. Bu yollar genellikle agentmemory sürümünü gömer (örn. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), bu yüzden bir sonraki yükseltme her hook'u sessizce kırar ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
-
439
- Geçici çözüm:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- Bu, aynı hook komutlarını `~/.claude/settings.json` içine, kurulu `@agentmemory/agentmemory` paketinin paketli `plugin/` dizinine çözülmüş mutlak yollarla birleştirir. agentmemory'yi yükselttikten sonra yolları yenilemek için komutu yeniden çalıştırın. Aynı dosyadaki kullanıcı girdileri korunur; yalnızca önceki agentmemory girdileri değiştirilir. `/plugin install` yolunu kullanmak hâlâ önerilen yaklaşımdır.
446
- Uzak veya korumalı deployment'lar için Claude Code'u `AGENTMEMORY_URL` ve `AGENTMEMORY_SECRET` ayarlanmış olarak başlatın. Eklenti her iki değeri de paketli MCP sunucusuna geçirir; `AGENTMEMORY_URL` boş olduğunda MCP shim'i `http://localhost:3111`'i kullanır.
447
-
448
- ### Codex CLI (Codex eklenti platformu)
449
-
450
- ```bash
451
- # 1. ayrı bir terminalde bellek sunucusunu başlatın
452
- npx @agentmemory/agentmemory
453
-
454
- # 2. agentmemory marketplace'i kaydedin ve eklentiyi kurun
455
- codex plugin marketplace add rohitg00/agentmemory
456
- codex plugin add agentmemory@agentmemory
457
- ```
458
-
459
- Codex eklentisi, Claude Code eklentisiyle aynı `plugin/` dizininden gelir. Şunları kaydeder:
460
-
461
- - `@agentmemory/mcp` MCP sunucusu olarak (`AGENTMEMORY_URL` çalışan bir agentmemory sunucusuna işaret ettiğinde tüm 51 tool'u proxy yapar; erişilebilir sunucu yoksa yerel olarak 7 tool'a düşer)
462
- - 6 yaşam döngüsü hook'u: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
- - 4 skill: `/recall`, `/remember`, `/session-history`, `/forget`
464
-
465
- Codex'in hook motoru, hook alt süreçlerine `CLAUDE_PLUGIN_ROOT` enjekte eder (bkz. [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), bu sayede aynı hook scriptleri her iki host'ta da çoğaltma yapmadan çalışır. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure olayları yalnızca Claude Code'a özeldir ve Codex için kaydedilmez.
466
-
467
- #### Codex Desktop: eklenti hook'ları şu anda sessiz (geçici çözüm mevcut)
468
-
469
- `CodexHooks` ve `PluginHooks` her ikisi de [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) içinde stable + varsayılan olarak etkin, ancak Codex Desktop sürümleri şu anda eklenti-yerel `hooks.json`'u dağıtmıyor ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP tool'ları hâlâ çalışıyor; yalnızca yaşam döngüsü gözlemleri eksik.
470
-
471
- Düzeltme upstream'e iner inmez, aynı hook komutlarını global `~/.codex/hooks.json` içine yansıtın:
472
-
473
- ```bash
474
- agentmemory connect codex --with-hooks
475
- ```
476
-
477
- Bu, `~/.codex/hooks.json`'a paketli scriptlere mutlak yollarla atıfta bulunan idempotent bir blok ekler (user-scope'ta `${CLAUDE_PLUGIN_ROOT}` genişlemesi gerekmez). agentmemory'yi yükselttikten sonra yolları yenilemek için aynı komutu yeniden çalıştırın. Aynı dosyadaki kullanıcı girdileri korunur; yalnızca önceki agentmemory girdileri değiştirilir.
478
-
479
- <details>
480
- <summary><b>OpenClaw (bu istemi yapıştırın)</b></summary>
481
-
482
- ```text
483
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
-
485
- {
486
- "mcpServers": {
487
- "agentmemory": {
488
- "command": "npx",
489
- "args": ["-y", "@agentmemory/mcp"],
490
- "env": {
491
- "AGENTMEMORY_URL": "http://localhost:3111"
492
- }
493
- }
494
- }
495
- }
496
-
497
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
- ```
499
-
500
- Tam kılavuz: [`integrations/openclaw/`](../integrations/openclaw/)
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><b>Hermes Agent (bu istemi yapıştırın)</b></summary>
506
-
507
- ```text
508
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
-
510
- mcp_servers:
511
- agentmemory:
512
- command: npx
513
- args: ["-y", "@agentmemory/mcp"]
514
-
515
- memory:
516
- provider: agentmemory
517
-
518
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
- ```
520
-
521
- Tam kılavuz: [`integrations/hermes/`](../integrations/hermes/)
522
-
523
- </details>
524
-
525
- ### Diğer ajanlar
526
-
527
- Bellek sunucusunu başlatın: `npx @agentmemory/agentmemory`
528
-
529
- agentmemory girdisi, `mcpServers` şeklini kullanan her host'ta (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw) **aynı MCP sunucu bloğudur**:
530
-
531
- ```json
532
- "agentmemory": {
533
- "command": "npx",
534
- "args": ["-y", "@agentmemory/mcp"],
535
- "env": {
536
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
- }
539
- }
540
- ```
541
-
542
- **Bu girdiyi host'un yapılandırma dosyasındaki mevcut `mcpServers` nesnesine birleştirin** — dosyayı değiştirmeyin. Dosyada zaten başka sunucular varsa, `agentmemory`'yi `mcpServers` içindeki başka bir anahtar olarak yanlarına ekleyin. `mcpServers` tamamen eksikse, bloğu `{ "mcpServers": { ... } }` içine yapıştırın. `${VAR}` yer tutucuları, MCP-sunucu lansmanında shell'den `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET`'i miras alır — ayarsız değişkenler boş string geçirir ve shim `http://localhost:3111`'e geri döner. Bir tane bağlı girdi hem yerel hem uzak (k8s / reverse-proxy'li) dağıtımları kapsar.
543
-
544
- | Ajan | Yapılandırma dosyası | Notlar |
545
- |---|---|---|
546
- | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` içine birleştirin. Web sitesinde tek tıklamayla deeplink de mevcut. |
547
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers` içine birleştirin. Düzenlemeden sonra Claude Desktop'ı yeniden başlatın. |
548
- | **Cline / Roo Code / Kilo Code** | Cline MCP ayarları (Settings UI → MCP Servers → Edit) | Aynı `mcpServers` bloğu. |
549
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Aynı `mcpServers` bloğu. |
550
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (otomatik birleştirir). |
551
- | **OpenClaw** | OpenClaw MCP yapılandırması | Aynı `mcpServers` bloğu veya daha derin [bellek eklentisi](../integrations/openclaw/) kullanın. |
552
- | **Codex CLI (yalnız MCP)** | `.codex/config.toml` | TOML şekli: `codex mcp add agentmemory -- npx -y @agentmemory/mcp` veya manuel olarak `[mcp_servers.agentmemory]` ekleyin. |
553
- | **Codex CLI (tam eklenti)** | Codex eklenti marketplace | `codex plugin marketplace add rohitg00/agentmemory` ardından `codex plugin add agentmemory@agentmemory`. MCP + 6 yaşam döngüsü hook'u (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skill kaydeder. Codex Desktop'ta, [openai/codex#16430](https://github.com/openai/codex/issues/16430) inene kadar `agentmemory connect codex --with-hooks` da çalıştırın — eklenti hook'ları şu anda orada sessiz. |
554
- | **OpenCode (yalnız MCP)** | `opencode.json` | Farklı şekil — üst seviye `mcp` anahtarı, komut dizi olarak: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
- | **OpenCode (tam eklenti)** | `plugin/opencode/` | Oturum yaşam döngüsü, mesajlar, araçlar, hataları kapsayan 22 otomatik yakalama hook'u. İki slash komut (`/recall`, `/remember`). `plugin/opencode/`'u OpenCode çalışma alanınıza kopyalayın ve eklenti girdisini `opencode.json`'a ekleyin. Tam hook tablosu + gap analizi için [`plugin/opencode/README.md`](../plugin/opencode/README.md) bakın. |
556
- | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/)'yi kopyalayın ve pi'yi yeniden başlatın. |
557
- | **Hermes Agent** | `~/.hermes/config.yaml` | Daha derin [bellek sağlayıcı eklentisi](../integrations/hermes/)'ni `memory.provider: agentmemory` ile kullanın. |
558
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` standart `mcpServers` bloğunu yazar. Hook yükü Claude Code ile alan-uyumludur, bu yüzden mevcut 12 hook scripti değişiklik yapmadan çalışır — aynı `settings.json`'daki `hooks` bölümü üzerinden bağlayın. |
559
- | **Antigravity** (Gemini CLI'nin yerini alır) | `mcp_config.json` (Antigravity'nin User dizininde) | `agentmemory connect antigravity` standart `mcpServers` bloğunu yazar. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. 2026-06-18 Gemini CLI sonlandırılması sonrasında kullanın. |
560
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` kullanıcı-seviyesi yapılandırmayı yazar. Çalışma alanı override'ları kodunuzun yanındaki `.kiro/settings/mcp.json`'a gider. |
561
- | **Goose** | Goose MCP ayarları UI | Aynı `mcpServers` bloğu. |
562
- | **Aider** | n/a | REST API ile doğrudan konuşun: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
- | **Herhangi bir ajan (32+)** | n/a | `npx skillkit install agentmemory` host'u otomatik algılar ve birleştirir. |
564
-
565
- **Sandbox'lı MCP istemcileri** (Flatpak / Snap / kısıtlayıcı container'lar) host'un `localhost`'una erişemez: ayrıca `env` bloğunda `"AGENTMEMORY_FORCE_PROXY": "1"` ayarlayın ve `AGENTMEMORY_URL`'i sandbox'ın gerçekten erişebileceği bir rotaya yönlendirin (örn. LAN IP'niz). Teşhis adım adımı için bkz. [#234](https://github.com/rohitg00/agentmemory/issues/234).
566
-
567
- ### Programatik erişim (Python / Rust / Node)
568
-
569
- agentmemory çekirdek işlemlerini iii fonksiyonları olarak kaydeder (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). iii SDK'sı olan herhangi bir dil, bunları doğrudan `ws://localhost:49134` üzerinden çağırabilir — dil başına ayrı bir REST istemcisi yok.
570
-
571
- ```bash
572
- pip install iii-sdk # Python
573
- cargo add iii-sdk # Rust
574
- npm install iii-sdk # Node
575
- ```
576
-
577
- ```python
578
- from iii import register_worker
579
-
580
- iii = register_worker("ws://localhost:49134")
581
- iii.connect()
582
-
583
- iii.trigger({
584
- "function_id": "mem::smart-search",
585
- "payload": {"project": "demo", "query": "how do tokens refresh"},
586
- })
587
- ```
588
-
589
- Çalışan örnek: [`examples/python/`](../examples/python/) (quickstart + gözlem/recall akışı). iii runtime'ı olmayan host'lar için REST `:3111` üzerinde kullanılmaya devam eder.
590
-
591
- ### Kaynaktan
592
-
593
- ```bash
594
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
- npm install && npm run build && npm start
596
- ```
597
-
598
- Bu, `iii` zaten kuruluysa yerel bir `iii-engine` ile agentmemory'yi başlatır veya Docker mevcutsa Docker Compose'a düşer. REST, stream'ler ve görüntüleyici varsayılan olarak `127.0.0.1`'e bağlanır.
599
-
600
- `iii-engine`'i manuel olarak kurun. **agentmemory şu anda `iii-engine`'i `v0.11.2`'ye sabitliyor** — `v0.11.6`, agentmemory'nin henüz refactor edilmediği yeni bir sandbox-her-şey-üzerinden-`iii worker add` modelini tanıtıyor. Refactor geldiğinde sabitleme kaldırılır. Sandbox modeline manuel olarak geçtiyseniz `AGENTMEMORY_III_VERSION=<version>` ile override edin.
601
-
602
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
- - **macOS x64:** `aarch64-apple-darwin`'i `x86_64-apple-darwin` ile değiştirin
604
- - **Linux x64:** `x86_64-unknown-linux-gnu` ile değiştirin
605
- - **Linux arm64:** `aarch64-unknown-linux-gnu` ile değiştirin
606
- - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2)'den `iii-x86_64-pc-windows-msvc.zip`'i indirin, `iii.exe`'yi çıkarın, PATH'e ekleyin
607
-
608
- Veya Docker kullanın (paketli `docker-compose.yml` `iiidev/iii:0.11.2`'yi çeker). Tam dokümanlar: [iii.dev/docs](https://iii.dev/docs).
609
-
610
- ### Windows
611
-
612
- agentmemory Windows 10/11'de çalışır, ancak yalnızca Node.js paketi yeterli değildir — arka planda çalışan bir süreç olarak `iii-engine` runtime'ı (ayrı yerel ikilik) da gerekir. Resmi upstream kurucu bir `sh` scripti ve bugün için PowerShell kurucusu veya scoop/winget paketi yok, bu yüzden Windows kullanıcılarının iki yolu var:
613
-
614
- **Seçenek A — Önceden derlenmiş Windows ikiliği (önerilen):**
615
-
616
- ```powershell
617
- # 1. Tarayıcınızda https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 açın
618
- # (engine v0.11.6+'nın gerektirdiği yeni sandbox modeli için
619
- # agentmemory refactor edilene kadar v0.11.2'ye sabitliyoruz)
620
- # 2. iii-x86_64-pc-windows-msvc.zip indirin
621
- # (veya ARM makinedeyseniz iii-aarch64-pc-windows-msvc.zip)
622
- # 3. iii.exe'yi PATH'te bir yere çıkarın veya şuraya yerleştirin:
623
- # %USERPROFILE%\.local\bin\iii.exe
624
- # (agentmemory bu konumu otomatik kontrol eder)
625
- # 4. Doğrulayın:
626
- iii --version
627
- # Şunu yazmalı: 0.11.2
628
-
629
- # 5. Ardından agentmemory'yi her zamanki gibi çalıştırın:
630
- npx -y @agentmemory/agentmemory
631
- ```
632
-
633
- **Seçenek B — Docker Desktop:**
634
-
635
- ```powershell
636
- # 1. Windows için Docker Desktop kurun
637
- # 2. Docker Desktop'ı başlatın ve engine'in çalıştığından emin olun
638
- # 3. agentmemory'yi çalıştırın — paketli compose dosyasını otomatik başlatır:
639
- npx -y @agentmemory/agentmemory
640
- ```
641
-
642
- **Seçenek C — yalnızca bağımsız MCP (engine yok):** yalnızca ajanınız için MCP araçlarına ihtiyacınız varsa ve REST API'sine, görüntüleyiciye veya cron işlerine gerek yoksa engine'i tamamen atlayın:
643
-
644
- ```powershell
645
- npx -y @agentmemory/agentmemory mcp
646
- # veya shim paketi üzerinden:
647
- npx -y @agentmemory/mcp
648
- ```
649
-
650
- **Windows için teşhis:** `npx @agentmemory/agentmemory` başarısız olursa, gerçek engine stderr'ini görmek için `--verbose` ile yeniden çalıştırın. Yaygın hata türleri:
651
-
652
- | Belirti | Düzeltme |
653
- |---|---|
654
- | `iii-engine process started` ardından `did not become ready within 15s` | Engine başlatma sırasında çöktü — `--verbose` ile yeniden çalıştırın, stderr'i kontrol edin |
655
- | `Could not start iii-engine` | Ne `iii.exe` ne de Docker kurulu. Yukarıdaki Seçenek A veya B'ye bakın |
656
- | Port çakışması | `netstat -ano \| findstr :3111` ile neyin bağlı olduğunu görün, ardından öldürün veya `--port <N>` kullanın |
657
- | Docker kurulu olsa bile Docker fallback atlanıyor | Docker Desktop'ın gerçekten çalıştığından emin olun (sistem tepsisi simgesi) |
658
-
659
- > Not: `cargo install iii-engine` yoktur — `iii` crates.io'da yayımlanmamıştır. Tek desteklenen kurulum yöntemleri yukarıdaki önceden derlenmiş ikilik, upstream `sh` kurulum scripti (yalnızca macOS/Linux) ve Docker imajıdır.
660
-
661
- ---
662
-
663
- <h2 id="deploy">Deploy</h2>
664
-
665
- Yönetilen host'lar için tek tıklamayla şablonlar. Her biri,
666
- npm'den `@agentmemory/agentmemory`'yi çeken ve iii engine
667
- ikilisini resmi `iiidev/iii` Docker Hub imajından kopyalayan
668
- kendi kendine yeten bir Dockerfile içerir — önceden derlenmiş
669
- bir agentmemory imajı gerekmez. Kalıcı depolama `/data`'ya
670
- bağlanır; ilk açılış entrypoint'i, npm-paketli iii yapılandırmasını
671
- (ki `127.0.0.1`'e bağlanır) `0.0.0.0`'a bağlanan ve mutlak
672
- `/data` yollarını kullanan deploy-ayarlı bir tanesiyle üzerine
673
- yazar, HMAC secret'ını üretir, ardından agentmemory CLI'sini
674
- exec etmeden önce `gosu` aracılığıyla yetkileri `root`'tan
675
- `node`'a düşürür.
676
-
677
- <p>
678
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
679
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
680
- </p>
681
-
682
- Render'ın tek-tıklamayla deploy düğmesi, depo kökünde `render.yaml`
683
- gerektirir; biz bunu bilerek temiz tutuyoruz. Deponun içindeki blueprint'e
684
- manuel olarak işaret etmek için [`deploy/render/`](../deploy/render/README.md) içinde belgelenen Render Blueprint akışını kullanın.
685
-
686
- Tam kurulum detayları (HMAC yakalama, görüntüleyici SSH tüneli,
687
- döndürme, yedekleme, maliyet alt sınırları) [`deploy/`](../deploy/README.md) içinde:
688
-
689
- - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"` ile
690
- tek makine; en ucuz boşta çalışma.
691
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby planı sabit ücret,
692
- panelden volume.
693
- - [`deploy/render`](../deploy/render/README.md) — Blueprint akışı,
694
- ücretli planlarda otomatik disk snapshot'ları.
695
- - [`deploy/coolify`](../deploy/coolify/README.md) — kendi VPS'inizde
696
- [Coolify](https://coolify.io/self-hosted) üzerinden self-hosted; aynı
697
- Docker Compose stack'i, host ve verinin sahibi sizsiniz.
698
-
699
- Yalnızca `3111` portu yayımlanır. `3113`'teki görüntüleyici container içinde
700
- loopback'e bağlı kalır �� her şablonun README'si ona ulaşmak için SSH-tünel
701
- desenini belgeler.
702
-
703
- ---
704
-
705
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
706
-
707
- Her kodlama ajanı, oturum sona erdiğinde her şeyi unutur. Her oturumun ilk 5 dakikasını yığınınızı yeniden anlatarak harcarsınız. agentmemory arka planda çalışır ve bunu tamamen ortadan kaldırır.
708
-
709
- ```text
710
- Session 1: "Add auth to the API"
711
- Agent writes code, runs tests, fixes bugs
712
- agentmemory silently captures every tool use
713
- Session ends -> observations compressed into structured memory
714
-
715
- Session 2: "Now add rate limiting"
716
- Agent already knows:
717
- - Auth uses JWT middleware in src/middleware/auth.ts
718
- - Tests in test/auth.test.ts cover token validation
719
- - You chose jose over jsonwebtoken for Edge compatibility
720
- Zero re-explaining. Starts working immediately.
721
- ```
722
-
723
- ### Yerleşik ajan belleğiyle karşılaştırma
724
-
725
- Her AI kodlama ajanı yerleşik bellekle gelir — Claude Code'da `MEMORY.md`, Cursor'da notepad, Cline'da memory bank var. Bunlar yapışkan notlar gibi çalışır. agentmemory, o yapışkan notların ardındaki aranabilir veritabanıdır.
726
-
727
- | | Yerleşik (CLAUDE.md) | agentmemory |
728
- |---|---|---|
729
- | Ölçek | 200 satır sınırı | Sınırsız |
730
- | Arama | Her şeyi bağlama yükler | BM25 + vektör + graf (yalnız top-K) |
731
- | Token maliyeti | 240 gözlemde 22K+ | ~1,900 token (%92 daha az) |
732
- | Ajanlar arası | Ajan başına dosya | MCP + REST (herhangi bir ajan) |
733
- | Koordinasyon | Yok | Lease'ler, sinyaller, action'lar, routine'ler |
734
- | Gözlemlenebilirlik | Dosyaları manuel okuma | :3113'te gerçek zamanlı görüntüleyici |
735
-
736
- ---
737
-
738
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
739
-
740
- ### Bellek Pipeline'ı
741
-
742
- ```text
743
- PostToolUse hook fires
744
- -> SHA-256 dedup (5min window)
745
- -> Privacy filter (strip secrets, API keys)
746
- -> Store raw observation
747
- -> LLM compress -> structured facts + concepts + narrative
748
- -> Vector embedding (6 providers + local)
749
- -> Index in BM25 + vector
750
-
751
- Stop / SessionEnd hook fires
752
- -> Summarize session
753
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
754
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
755
-
756
- SessionStart hook fires
757
- -> Load project profile (top concepts, files, patterns)
758
- -> Hybrid search (BM25 + vector + graph)
759
- -> Token budget (default: 2000 tokens)
760
- -> Inject into conversation
761
- ```
762
-
763
- ### 4 Katmanlı Bellek Konsolidasyonu
764
-
765
- İnsan beyninin belleği nasıl işlediğinden ilham aldı — uyku konsolidasyonundan çok da farklı değil.
766
-
767
- | Katman | Ne | Analoji |
768
- |------|------|---------|
769
- | **Working** | Araç kullanımından ham gözlemler | Kısa süreli bellek |
770
- | **Episodic** | Sıkıştırılmış oturum özetleri | "Ne oldu" |
771
- | **Semantic** | Çıkarılmış olgular ve desenler | "Ne biliyorum" |
772
- | **Procedural** | İş akışları ve karar desenleri | "Nasıl yapılır" |
773
-
774
- Bellekler zamanla decay olur (Ebbinghaus eğrisi). Sık erişilen bellekler güçlenir. Bayat bellekler otomatik tahliye edilir. Çelişkiler algılanır ve çözülür.
775
-
776
- ### Ne Yakalanır
777
-
778
- | Hook | Yakalar |
779
- |------|----------|
780
- | `SessionStart` | Proje yolu, oturum ID |
781
- | `UserPromptSubmit` | Kullanıcı istemleri (gizlilik-filtrelenmiş) |
782
- | `PreToolUse` | Dosya erişim desenleri + zenginleştirilmiş bağlam |
783
- | `PostToolUse` | Tool adı, girdi, çıktı |
784
- | `PostToolUseFailure` | Hata bağlamı |
785
- | `PreCompact` | Sıkıştırmadan önce belleği yeniden enjekte eder |
786
- | `SubagentStart/Stop` | Alt-ajan yaşam döngüsü |
787
- | `Stop` | Oturum sonu özeti |
788
- | `SessionEnd` | Oturum tamamlandı işareti |
789
-
790
- ### Temel Yetenekler
791
-
792
- | Yetenek | Açıklama |
793
- |---|---|
794
- | **Otomatik yakalama** | Her tool kullanımı hook'lar üzerinden kaydedilir — sıfır manuel çaba |
795
- | **Anlamsal arama** | RRF füzyonu ile BM25 + vektör + bilgi grafı |
796
- | **Bellek evrimi** | Sürümleme, supersede, ilişki grafları |
797
- | **Otomatik unutma** | TTL süresi dolması, çelişki algılama, önem tahliyesi |
798
- | **Gizlilik öncelikli** | API anahtarları, secret'lar, `<private>` etiketleri depolamadan önce çıkarılır |
799
- | **Kendini iyileştirme** | Devre kesici, sağlayıcı yedek zinciri, sağlık izleme |
800
- | **Claude bridge** | MEMORY.md ile çift yönlü sync |
801
- | **Bilgi grafı** | Entity çıkarımı + BFS gezinti |
802
- | **Takım belleği** | İsimlendirilmiş paylaşımlı + özel takım üyeleri arasında |
803
- | **Atıf provenansı** | Herhangi bir belleği kaynak gözlemlere kadar izleyin |
804
- | **Git snapshot'ları** | Bellek durumunu sürümleyin, geri alın ve diff'leyin |
805
-
806
- ---
807
-
808
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
809
-
810
- Üç sinyali birleştiren üçlü-akış geri getirme:
811
-
812
- | Akış | Ne yapar | Ne zaman |
813
- |---|---|---|
814
- | **BM25** | Eş anlamlı genişletmeli stem'lenmiş anahtar kelime eşleştirme | Her zaman açık |
815
- | **Vektör** | Yoğun embedding'ler üzerinde kosinüs benzerliği | Embedding sağlayıcı yapılandırılmış |
816
- | **Graf** | Entity eşleştirme yoluyla bilgi grafı gezintisi | Sorguda entity'ler tespit edildiğinde |
817
-
818
- Reciprocal Rank Fusion (RRF, k=60) ile birleştirilir ve oturum-çeşitlendirilir (oturum başına maksimum 3 sonuç).
819
-
820
- BM25, Yunanca, Kiril, İbranice, Arapça ve aksanlı Latin'i kutudan çıkar çıkmaz tokenize eder. Çince / Japonca / Korece bellekler için, CJK akışlarını kelime-seviyesinde token'lara bölmek üzere isteğe bağlı segmenter'ları kurun (`npm install @node-rs/jieba tiny-segmenter`); bunlar olmadan agentmemory yumuşak olarak tüm-akış tokenizasyonuna düşer ve stderr'e bir kerelik bir ipucu yazdırır.
821
-
822
- ### Embedding sağlayıcıları
823
-
824
- agentmemory sağlayıcınızı otomatik algılar. En iyi sonuçlar için yerel embedding'leri kurun (ücretsiz):
825
-
826
- ```bash
827
- npm install @xenova/transformers
828
- ```
829
-
830
- | Sağlayıcı | Model | Maliyet | Notlar |
831
- |---|---|---|---|
832
- | **Yerel (önerilen)** | `all-MiniLM-L6-v2` | Ücretsiz | Çevrim dışı, BM25-only üzerinde +8pp recall |
833
- | Gemini | `gemini-embedding-001` | Ücretsiz katman | 100+ dil, 768/1536/3072 boyut (MRL), 2048-token girdi. `text-embedding-004`'ün yerini alır ([deprecated, 14 Ocak 2026'da kapanış](https://ai.google.dev/gemini-api/docs/deprecations)) |
834
- | OpenAI | `text-embedding-3-small` | 1M başı $0.02 | En yüksek kalite |
835
- | Voyage AI | `voyage-code-3` | Ücretli | Kod için optimize edilmiş |
836
- | Cohere | `embed-english-v3.0` | Ücretsiz deneme | Genel amaçlı |
837
- | OpenRouter | Herhangi bir model | Değişken | Çok-modelli proxy |
838
-
839
- ---
840
-
841
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
842
-
843
- 53 tool, 6 kaynak, 3 prompt ve 4 skill — herhangi bir ajan için en kapsamlı MCP bellek toolkit'i.
844
-
845
- > **MCP shim vs tam sunucu:** yayımlanan `@agentmemory/mcp` paketi ince bir shim'dir. Tam 51-tool yüzeyini **yalnızca `AGENTMEMORY_URL` üzerinden çalışan bir agentmemory sunucusuna erişebildiğinde** açığa çıkarır (proxy modu). Erişilebilir sunucu yoksa, shim 7-tool yerel sete (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`) düşer. `AGENTMEMORY_TOOLS=core|all` env değişkeni *sunucu tarafı* bir bayraktır — shim'in `env` bloğunda ayarlamak hiçbir etki yapmaz. Cursor / OpenCode / Gemini CLI'da yalnızca 7 tool görüyorsanız, `npx @agentmemory/agentmemory` (veya Docker stack'i) başlatın ve `AGENTMEMORY_URL=http://localhost:3111` ayarlayın.
846
-
847
- ### 51 Tool
848
-
849
- <details>
850
- <summary>Çekirdek tool'lar (her zaman kullanılabilir)</summary>
851
-
852
- | Tool | Açıklama |
853
- |------|-------------|
854
- | `memory_recall` | Geçmiş gözlemleri ara |
855
- | `memory_compress_file` | Yapıyı koruyarak markdown dosyalarını sıkıştır |
856
- | `memory_save` | Bir içgörü, karar veya deseni kaydet |
857
- | `memory_patterns` | Tekrar eden desenleri algıla |
858
- | `memory_smart_search` | Hibrit anlamsal + anahtar kelime araması |
859
- | `memory_file_history` | Belirli dosyalar hakkında geçmiş gözlemler |
860
- | `memory_sessions` | Son oturumları listele |
861
- | `memory_timeline` | Kronolojik gözlemler |
862
- | `memory_profile` | Proje profili (kavramlar, dosyalar, desenler) |
863
- | `memory_export` | Tüm bellek verisini dışa aktar |
864
- | `memory_relations` | İlişki grafını sorgula |
865
-
866
- </details>
867
-
868
- <details>
869
- <summary>Genişletilmiş tool'lar (51 toplam — AGENTMEMORY_TOOLS=all ayarla)</summary>
870
-
871
- | Tool | Açıklama |
872
- |------|-------------|
873
- | `memory_patterns` | Tekrar eden desenleri algıla |
874
- | `memory_timeline` | Kronolojik gözlemler |
875
- | `memory_relations` | İlişki grafını sorgula |
876
- | `memory_graph_query` | Bilgi grafı gezintisi |
877
- | `memory_consolidate` | 4 katmanlı konsolidasyonu çalıştır |
878
- | `memory_claude_bridge_sync` | MEMORY.md ile sync |
879
- | `memory_team_share` | Takım üyeleriyle paylaş |
880
- | `memory_team_feed` | Son paylaşılan öğeler |
881
- | `memory_audit` | İşlemlerin denetim izi |
882
- | `memory_governance_delete` | Denetim izi ile sil |
883
- | `memory_snapshot_create` | Git-sürümlü snapshot |
884
- | `memory_action_create` | Bağımlılıklarla iş öğesi oluştur |
885
- | `memory_action_update` | Action durumunu güncelle |
886
- | `memory_frontier` | Önceliğe göre sıralanmış engellenmemiş action'lar |
887
- | `memory_next` | Tek en önemli sonraki action |
888
- | `memory_lease` | Exclusive action lease'leri (çoklu ajan) |
889
- | `memory_routine_run` | İş akışı routine'lerini örnekle |
890
- | `memory_signal_send` | Ajanlar arası mesajlaşma |
891
- | `memory_signal_read` | Onay alındıyla mesajları oku |
892
- | `memory_checkpoint` | Harici koşul kapıları |
893
- | `memory_mesh_sync` | Örnekler arasında P2P sync |
894
- | `memory_sentinel_create` | Event-driven gözcüler |
895
- | `memory_sentinel_trigger` | Sentinel'leri harici olarak tetikle |
896
- | `memory_sketch_create` | Ephemeral action grafları |
897
- | `memory_sketch_promote` | Kalıcıya yükselt |
898
- | `memory_crystallize` | Action zincirlerini kompakt et |
899
- | `memory_diagnose` | Sağlık kontrolleri |
900
- | `memory_heal` | Sıkışmış durumu otomatik düzelt |
901
- | `memory_facet_tag` | Boyut:değer etiketleri |
902
- | `memory_facet_query` | Facet etiketlerine göre sorgula |
903
- | `memory_verify` | Provenansı izle |
904
-
905
- </details>
906
-
907
- ### 6 Kaynak · 3 Prompt · 4 Skill
908
-
909
- | Tür | İsim | Açıklama |
910
- |------|------|-------------|
911
- | Resource | `agentmemory://status` | Sağlık, oturum sayısı, bellek sayısı |
912
- | Resource | `agentmemory://project/{name}/profile` | Proje başına zeka |
913
- | Resource | `agentmemory://memories/latest` | En son 10 aktif bellek |
914
- | Resource | `agentmemory://graph/stats` | Bilgi grafı istatistikleri |
915
- | Prompt | `recall_context` | Ara + bağlam mesajları döndür |
916
- | Prompt | `session_handoff` | Ajanlar arasında handoff verisi |
917
- | Prompt | `detect_patterns` | Tekrar eden desenleri analiz et |
918
- | Skill | `/recall` | Belleği ara |
919
- | Skill | `/remember` | Uzun süreli belleğe kaydet |
920
- | Skill | `/session-history` | Son oturum özetleri |
921
- | Skill | `/forget` | Gözlemleri/oturumları sil |
922
-
923
- ### Bağımsız MCP
924
-
925
- Tam sunucu olmadan çalıştır — herhangi bir MCP istemcisi için. Şunlardan herhangi biri çalışır:
926
-
927
- ```bash
928
- npx -y @agentmemory/agentmemory mcp # kanonik (her zaman kullanılabilir)
929
- npx -y @agentmemory/mcp # shim paketi takma adı
930
- ```
931
-
932
- Veya ajanınızın MCP yapılandırmasına ekleyin:
933
-
934
- Çoğu ajan (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
935
- ```json
936
- {
937
- "mcpServers": {
938
- "agentmemory": {
939
- "command": "npx",
940
- "args": ["-y", "@agentmemory/mcp"],
941
- "env": {
942
- "AGENTMEMORY_URL": "http://localhost:3111"
943
- }
944
- }
945
- }
946
- }
947
- ```
948
-
949
- `agentmemory` girdisini, dosyayı değiştirmek yerine host'unuzun mevcut `mcpServers` nesnesine birleştirin. Host'un `localhost`'una erişemeyen sandbox'lı istemciler için env bloğuna `"AGENTMEMORY_FORCE_PROXY": "1"` ekleyin ve `AGENTMEMORY_URL`'i sandbox'ın erişebileceği bir rotaya ayarlayın.
950
-
951
- OpenCode (`opencode.json`):
952
- ```json
953
- {
954
- "mcp": {
955
- "agentmemory": {
956
- "type": "local",
957
- "command": ["npx", "-y", "@agentmemory/mcp"],
958
- "enabled": true
959
- }
960
- },
961
- "plugin": ["./plugins/agentmemory-capture.ts"]
962
- }
963
- ```
964
-
965
- Eklenti dosyasını depodan kopyalayın:
966
- ```bash
967
- mkdir -p ~/.config/opencode/plugins
968
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
969
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
970
- ```
971
-
972
- ---
973
-
974
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
975
-
976
- `3113` portunda otomatik başlar. Canlı gözlem akışı, oturum gezgini, bellek tarayıcısı, bilgi grafı görselleştirmesi ve sağlık paneli.
977
-
978
- ```bash
979
- open http://localhost:3113
980
- ```
981
-
982
- Görüntüleyici sunucusu varsayılan olarak `127.0.0.1`'e bağlanır. REST-servisli `/agentmemory/viewer` endpoint'i normal `AGENTMEMORY_SECRET` bearer-token kurallarını izler. CSP başlıkları yanıt başına bir script nonce'ı kullanır ve satır içi handler özniteliklerini devre dışı bırakır (`script-src-attr 'none'`).
983
-
984
- ---
985
-
986
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
987
-
988
- `:3113`'teki görüntüleyici ajanınızın **hatırladıklarını** gösterir. [iii konsolu](https://iii.dev/docs/console) ajanınızın **yaptıklarını** gösterir — her bellek op'u bir OpenTelemetry trace'i olarak, her KV girdisi düzenlenebilir, her fonksiyon çağrılabilir, her stream dinlenebilir. Aynı belleğe iki pencere: biri ürün-şekilli, diğeri motor-şekilli.
989
-
990
- Bir `memory_smart_search`'ün ateşlenmesini izleyin ve BM25 taramasını → embedding aramasını → RRF füzyonunu → reranker'ı bir şelale olarak görün. Sıkışmış bir konsolidasyon zamanlayıcısını KV tarayıcıda düzenleyin. `PostToolUse` hook'unu değiştirilmiş bir payload ile tekrar oynatın. WebSocket stream'ini sabitleyin ve gözlemlerin canlı olarak indiğini izleyin.
991
-
992
- agentmemory bunu ücretsiz dağıtır çünkü her fonksiyon, trigger, durum kapsamı ve stream bir iii primitif'idir — özel hiçbir şey, enstrümante edilecek hiçbir şey yok.
993
-
994
- <p align="center">
995
- <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
996
- <br/>
997
- <em>Workers sayfası: bağlı her worker — agentmemory'nin kendisi dahil — PID, fonksiyon sayısı, runtime ve son-görülme ile birlikte.</em>
998
- </p>
999
-
1000
- **Zaten kurulu.** Konsol `iii` ile birlikte gelir — ayrı kurucu yok.
1001
-
1002
- **agentmemory ile birlikte başlat:**
1003
-
1004
- ```bash
1005
- # agentmemory görüntüleyicisi 3113 portunu tutar, bu yüzden konsolu 3114'te çalıştırın.
1006
- # Engine REST (3111), WebSocket (3112) ve bridge (49134) varsayılanları agentmemory ile eşleşir.
1007
- iii console --port 3114
1008
- ```
1009
-
1010
- Ardından `http://localhost:3114`'ü açın. Deneysel mimari-grafı sayfası için `--enable-flow` ekleyin.
1011
-
1012
- Yalnızca taşıdıysanız engine endpoint'lerini override edin:
1013
-
1014
- ```bash
1015
- iii console --port 3114 \
1016
- --engine-port 3111 \
1017
- --ws-port 3112 \
1018
- --bridge-port 49134
1019
- ```
1020
-
1021
- **Konsoldan neler yapabilirsiniz:**
1022
-
1023
- | Sayfa | Şunun için kullanın |
1024
- |------|-----------|
1025
- | **Workers** | Bağlı her worker'ı ve canlı metriklerini görün — agentmemory worker'ının kendisi dahil. |
1026
- | **Functions** | agentmemory'nin herhangi bir fonksiyonunu doğrudan JSON payload ile çağırın — bir istemci bağlamadan `memory.recall`, `memory.consolidate`, `graph.query` test etmek için kullanışlı. |
1027
- | **Triggers** | HTTP, cron, event ve state trigger'larını tekrar oynatın — konsolidasyon cron'unu manuel olarak ateşleyin, bir HTTP route'unu yeniden deneyin, bir durum değişikliği yayın. |
1028
- | **States** | Tam CRUD ile KV tarayıcı — oturumlar, bellek slot'ları, yaşam döngüsü zamanlayıcıları, embedding'ler indeksi — değerleri yerinde düzenleyin. |
1029
- | **Streams** | Bellek yazımları, hook olayları ve gözlem güncellemeleri için iii stream'leri üzerinden akarken canlı WebSocket monitörü. |
1030
- | **Queues** | Dayanıklı kuyruk konuları + dead-letter yönetimi. Başarısız embedding / sıkıştırma işlerini tekrar oynatın veya bırakın. |
1031
- | **Traces** | OpenTelemetry şelale / alev / hizmet-dağılımı görünümleri. `trace_id` ile filtreleyerek tek bir `memory.search`'ün hangi fonksiyonları, DB çağrılarını ve embedding isteklerini ürettiğini tam olarak görün. |
1032
- | **Logs** | Trace/span ID'lerine korelasyonlu, yapılandırılmış OTEL logları. |
1033
- | **Config** | Runtime yapılandırması — engine'inizin hangi worker'lar, sağlayıcılar ve portlarla çalıştığını tam olarak görün. |
1034
- | **Flow** | (İsteğe bağlı, `--enable-flow`) Her worker, trigger ve stream'in interaktif mimari grafı. |
1035
-
1036
- <p align="center">
1037
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1038
- <br/>
1039
- <em>Traces: her bellek işlemi için şelale / alev / hizmet dağılımı.</em>
1040
- </p>
1041
-
1042
- **Trace'ler zaten açık:**
1043
-
1044
- `iii-config.yaml` `iii-observability` worker'ı etkinleştirilmiş olarak gelir (`exporter: memory`, `sampling_ratio: 1.0`, metrikler + log'lar). Ekstra yapılandırma gerekmez — agentmemory başlar başlamaz, her bellek işlemi konsolun okuyabileceği bir trace span'ı ve yapılandırılmış bir log yayar.
1045
-
1046
- Bunun yerine Jaeger/Honeycomb/Grafana Tempo'ya dışa aktarmak isterseniz, `exporter: memory`'yi `exporter: otlp` olarak değiştirin ve collector endpoint'ini iii'nin observability dokümanlarına göre ayarlayın.
1047
-
1048
- > **Dikkat:** konsolun kendisinde hiçbir auth zorlanmaz — `127.0.0.1`'e bağlı tutun (varsayılan) ve asla genel kullanıma açmayın.
1049
-
1050
- ---
1051
-
1052
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1053
-
1054
- agentmemory **zaten çalışan bir [iii](https://iii.dev) örneğidir**. Fonksiyonlar, trigger'lar, KV state, stream'ler, OTEL trace'leri — hepsi iii primitifleridir. Postgres, Redis, Express, pm2 veya Prometheus kurmadınız çünkü iii bunların yerini alıyor.
1055
-
1056
- Bu da, tek bir komutun agentmemory'yi tamamen yeni bir yetenekle genişlettiği anlamına gelir.
1057
-
1058
- ### agentmemory'yi tek komutla genişletin
1059
-
1060
- ```bash
1061
- iii worker add iii-pubsub # bellek yazımlarını bağlı her örneğe fan-out et
1062
- iii worker add iii-cron # zamanlanmış konsolidasyon, decay süpürmeleri, snapshot rotasyonu
1063
- iii worker add iii-queue # embedding + sıkıştırma işleri için dayanıklı yeniden denemeler
1064
- iii worker add iii-observability # her bellek op'unda OTEL trace'leri (varsayılan açık)
1065
- iii worker add iii-sandbox # hatırlanan kodu izole bir microVM içinde çalıştır
1066
- iii worker add iii-database # SQL destekli bir state adaptörü tak
1067
- iii worker add mcp # agentmemory MCP'sinin yanında genel MCP host'u
1068
- ```
1069
-
1070
- Her `iii worker add` agentmemory'nin zaten çalıştığı aynı engine'e yeni fonksiyonlar ve trigger'lar kaydeder. Görüntüleyici ve konsol bunları anında alır — yeniden yükleme yok, yeni entegrasyon yok, yeni container yok.
1071
-
1072
- | `iii worker add` | agentmemory'nin üzerine ne elde edersiniz |
1073
- |---|---|
1074
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Çoklu-örnek bellek: her `remember` fan-out olur, her `search` birleşimi okur |
1075
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Zamanlanmış yaşam döngüsü — geceleri konsolidasyon, haftalık snapshot'lar, sabit bir saatte decay |
1076
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Dayanıklı yeniden denemeler: başarısız embedding + sıkıştırma işleri yeniden başlatmaya dayanır, kayıp gözlem yok |
1077
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL trace'leri, metrikleri, log'ları her fonksiyonda — birinci günden itibaren `iii-config.yaml`'da bağlı |
1078
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall`'dan çıkan kod, shell'inizde değil, bir kullan-at VM içinde çalışır |
1079
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | In-memory KV varsayılanlarını aştığınızda SQL destekli state adaptörü |
1080
- | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory'ninin yanında ekstra MCP sunucuları ayağa kaldırın, aynı engine'i paylaşın |
1081
-
1082
- Tam kayıt defteri: [workers.iii.dev](https://workers.iii.dev). Oradaki her worker, agentmemory'nin kullandığı aynı primitifler aracılığıyla bir araya gelir — ve elinizde olan agentmemory de onlardan biridir.
1083
-
1084
- ### iii'nin yerini aldığı şeyler
1085
-
1086
- | Geleneksel stack | agentmemory kullanır |
1087
- |---|---|
1088
- | Express.js / Fastify | iii HTTP Triggers |
1089
- | SQLite / Postgres + pgvector | iii KV State + in-memory vektör indeksi |
1090
- | SSE / Socket.io | iii Streams (WebSocket) |
1091
- | pm2 / systemd | iii engine worker süpervizyonu |
1092
- | Prometheus / Grafana | iii OTEL + sağlık monitörü |
1093
- | Özel eklenti sistemleri | `iii worker add <name>` |
1094
-
1095
- **118 kaynak dosya · ~21,800 LOC · 950+ test · 123 fonksiyon · 34 KV scope** — hepsi üç primitif üzerinde. `agentmemory plugin install` yok. Eklenti sistemi iii'nin kendisi.
1096
-
1097
- ---
1098
-
1099
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1100
-
1101
- ### LLM Sağlayıcıları
1102
-
1103
- agentmemory ortamınızdan otomatik algılar. Varsayılan olarak, bir sağlayıcı yapılandırmadıkça veya Claude abonelik fallback'ine açıkça opt-in yapmadıkça hiçbir LLM çağrısı yapılmaz.
1104
-
1105
- | Sağlayıcı | Yapılandırma | Notlar |
1106
- |----------|--------|-------|
1107
- | **No-op (varsayılan)** | Yapılandırma gerekmez | LLM destekli compress/summarize DEVRE DIŞI. Sentetik BM25 sıkıştırma + recall hâlâ çalışır. Eskiden Claude-abonelik fallback'ine dayanıyorsanız aşağıdaki `AGENTMEMORY_ALLOW_AGENT_SDK`'ya bakın. |
1108
- | Anthropic API | `ANTHROPIC_API_KEY` | Token başına faturalama |
1109
- | MiniMax | `MINIMAX_API_KEY` | Anthropic-uyumlu |
1110
- | Gemini | `GEMINI_API_KEY` | Embedding'leri de etkinleştirir |
1111
- | OpenRouter | `OPENROUTER_API_KEY` | Herhangi bir model |
1112
- | Claude abonelik fallback'i | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Yalnızca opt-in. `@anthropic-ai/claude-agent-sdk` oturumları doğurur — eskiden sınırsız Stop-hook recursion'ına neden oluyordu (#149 takip), bu yüzden artık varsayılan değil. |
1113
-
1114
- ### Maliyet bilincine sahip model seçimi
1115
-
1116
- Arka plan sıkıştırması her gözlemde çalışır, bu yüzden model seçimi aylık harcamayı anlamlı ölçüde değiştirir. Yakalanan iş yükü verisi: 635 istek / 888K token / 35 saatlik aktif kullanım, 2026-05-23 fiyatlandırmasında üç OpenRouter modeline karşı çalıştırıldı.
1117
-
1118
- | Katman | Model | Girdi / 1M | Çıktı / 1M | Yakalanan 35 saat maliyeti | Notlar |
1119
- |------|-------|------------|-------------|---------------------------|-------|
1120
- | Önerilen | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Sonnet'ten ~10× daha düşük maliyetle sağlam sıkıştırma + özetleme kalitesi. |
1121
- | Önerilen | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Daha eski ama yalnızca-sıkıştırma iş yükleri için hâlâ iyi. |
1122
- | Önerilen | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Oturumlarınız yoğun olarak kod-şekilli ise güçlü kod muhakemesi. |
1123
- | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Yüksek kalite ancak her zaman açık arka plan çalışması için pahalı. |
1124
- | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet ile benzer katman. |
1125
- | Kaçının | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning sınıfı model; sıkıştırma için büyük aşırı harcama. |
1126
-
1127
- `OPENROUTER_MODEL` premium-katman bir desenle eşleştiğinde agentmemory bir runtime uyarısı yazdırır. Bilinçli bir seçim yaptıktan sonra susturmak için `AGENTMEMORY_SUPPRESS_COST_WARNING=1` ayarlayın.
1128
-
1129
- Bellek işi için kalite vs maliyet ödünleşmesi: sıkıştırma görece gevşek kalite çıtaları olan bir özetleme görevidir (özeti tekrar okuyan kullanıcı değil, ajandır). DeepSeek-V4-Pro / Qwen3-Coder bu görevde Sonnet'in yuvarlama hatası içinde kalırken ~10× daha az maliyetlidir. Premium katman modelleri doğrudan okuduğunuz sorgular için saklayın.
1130
-
1131
- Kaynaklar: [Sonnet 4.6 için OpenRouter fiyatlandırması](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek fiyatlandırma notları](https://api-docs.deepseek.com/quick_start/pricing/).
1132
-
1133
- ### Çoklu-ajan belleği (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1134
-
1135
- Birden fazla rolün tek bir agentmemory sunucusunu paylaştığı çoklu-ajan kurulumlarında (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` her yazıyı onu yapan rolle etiketler. `AGENTMEMORY_AGENT_SCOPE` recall'un bu etikete göre filtreleyip filtrelemeyeceğini kontrol eder.
1136
-
1137
- ```env
1138
- TEAM_ID=company
1139
- USER_ID=engineering-team
1140
- AGENT_ID=architect
1141
- AGENTMEMORY_AGENT_SCOPE=isolated # isteğe bağlı; varsayılan "shared"
1142
- ```
1143
-
1144
- İki mod:
1145
-
1146
- | Mod | Yazıları etiketle | Recall'u filtrele | Ne zaman kullanılır |
1147
- |------|------------|---------------|-------------|
1148
- | `shared` (varsayılan) | evet | hayır | Denetim iziyle ajanlar arası bağlam. Architect, developer'ın notlarını görebilir ancak her satır kim söylediğini kaydeder. |
1149
- | `isolated` | evet | evet | Katı ayrım. Architect developer'ın gözlemlerini / belleklerini / oturumlarını asla görmez. |
1150
-
1151
- `AGENT_ID` ayarlandığında ne etiketlenir: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Rol `api::session::start` → `mem::observe` → `mem::compress` → KV boyunca akar.
1152
-
1153
- İzole modda ne filtrelenir: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Her endpoint istek başına override için `?agentId=<role>` ve env kapsamından opt-out etmek için `?agentId=*` kabul eder. `/memories` ayrıca `agentId`'si undefined olan AGENT_ID öncesi belleklerin yüzeylenmesi için `?includeOrphans=true` kabul eder.
1154
-
1155
- SDK / REST katmanında çağrı başına override: her mutasyon endpoint'i (`/session/start`, `/remember`) istek gövdesinde env'i geçen bir `agentId` alanı kabul eder. Tek bir sunucu sürecinden birçok rolü yönlendiren runtime'lar için kullanışlıdır.
1156
-
1157
- `AGENT_ID` ayarlanmadığında bellek kapsam dışı kalır (eski davranış, etiket yok, filtre yok).
1158
-
1159
- ### Portlar
1160
-
1161
- agentmemory + iii-engine varsayılan olarak dört port'a bağlanır. Bir yeniden başlatma `port in use` ile başarısız olursa, bu tablo hangi süreci aramanız gerektiğini söyler.
1162
-
1163
- | Port | Süreç | Amaç | Env override |
1164
- |------|---------|---------|--------------|
1165
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1166
- | `3112` | iii-engine | Dahili stream'ler worker'ı (agentmemory + görüntüleyici tarafından tüketilir) | `III_STREAMS_PORT` |
1167
- | `3113` | agentmemory | Gerçek zamanlı görüntüleyici (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1168
- | `49134` | iii-engine | WebSocket — worker'lar burada kaydolur, OTel telemetri buradan akar | `III_ENGINE_URL` (tam URL, varsayılan `ws://localhost:49134`) |
1169
-
1170
- Çöken bir çalıştırma sonrası portlar bağlı kaldığında bayat-süreç temizliği:
1171
-
1172
- ```bash
1173
- # macOS / Linux — her portta ne varsa bulun ve öldürün
1174
- lsof -i :3111,3112,3113,49134
1175
- pkill -f agentmemory || true
1176
- pkill -f 'iii ' || true
1177
-
1178
- # Windows
1179
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1180
- taskkill /F /PID <pid>
1181
- ```
1182
-
1183
- `agentmemory stop` graceful shutdown'da hem worker hem de engine pidfile'ını temiz olarak biçer (#640, #474). Yukarıdaki manuel temizlik yalnızca her iki pidfile'ın da geride kalmadığı çökme sonrası durum içindir.
1184
-
1185
- ### Yapılandırma Dosyası
1186
-
1187
- agentmemory runtime yapılandırmasını her shell'de değişkenleri export etmek yerine `~/.agentmemory/.env`'a koyun. Görüntüleyici `export ANTHROPIC_API_KEY=...` gibi bir kurulum ipucu gösteriyorsa, `export` ön ekini koymadan bu dosyaya `ANTHROPIC_API_KEY=...` olarak kopyalayın, ardından agentmemory'yi yeniden başlatın.
1188
-
1189
- Süreç ortam değişkenleri hâlâ çalışır ve dosyadaki değerlere göre öncelik kazanır.
1190
-
1191
- Windows'ta aynı dosya `%USERPROFILE%\.agentmemory\.env` konumunda bulunur:
1192
-
1193
- ```powershell
1194
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1195
- notepad $HOME\.agentmemory\.env
1196
- ```
1197
-
1198
- API anahtarı yerine Claude Code Pro/Max aboneliğiyle test etmek için açıkça opt-in yapın:
1199
-
1200
- ```env
1201
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1202
- AGENTMEMORY_AUTO_COMPRESS=true
1203
- ```
1204
-
1205
- Graph veya konsolidasyon özelliklerini istiyorsanız aynı dosyada açın:
1206
-
1207
- ```env
1208
- GRAPH_EXTRACTION_ENABLED=true
1209
- CONSOLIDATION_ENABLED=true
1210
- ```
1211
-
1212
- ### Ortam Değişkenleri
1213
-
1214
- `~/.agentmemory/.env` oluşturun:
1215
-
1216
- ```env
1217
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1218
- # ANTHROPIC_API_KEY=sk-ant-...
1219
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1220
- # GEMINI_API_KEY=...
1221
- # OPENROUTER_API_KEY=...
1222
- # MINIMAX_API_KEY=...
1223
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1224
- # # OpenAI LLM provider (here) AND the OpenAI
1225
- # # embedding provider (further below). Set
1226
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1227
- # # to embeddings only.
1228
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1229
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1230
- # # Auto-detected from `.openai.azure.com` hostname; uses
1231
- # # api-key header + api-version query param.
1232
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1233
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1234
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1235
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1236
- # # for back-compat with v0.9.17. New configs should
1237
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1238
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1239
- # # Honored only by OpenAI's reasoning models (o1, o3,
1240
- # # gpt-*-reasoning) and providers that mirror that
1241
- # # schema (Ollama Cloud thinking models). Standard
1242
- # # chat models reject this field with 400. Set to
1243
- # # "none" for thinking models that return reasoning
1244
- # # but no content.
1245
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1246
- # # for LLM (useful if you only want OpenAI for embeddings)
1247
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1248
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1249
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1250
-
1251
- # Embedding provider (auto-detected, or override)
1252
- # EMBEDDING_PROVIDER=local
1253
- # VOYAGE_API_KEY=...
1254
- # OPENAI_API_KEY=sk-...
1255
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1256
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1257
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1258
-
1259
- # Outbound LLM / embedding timeout
1260
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1261
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1262
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1263
- # embedding). For the OpenAI LLM path, the
1264
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1265
- # takes precedence when set, for back-compat
1266
- # with v0.9.17.
1267
- # Increase for slow networks or large batch calls;
1268
- # decrease to fail-fast on rate-limit holds.
1269
-
1270
- # Search tuning
1271
- # BM25_WEIGHT=0.4
1272
- # VECTOR_WEIGHT=0.6
1273
- # TOKEN_BUDGET=2000
1274
-
1275
- # Auth
1276
- # AGENTMEMORY_SECRET=your-secret
1277
-
1278
- # Ports (defaults: 3111 API, 3113 viewer)
1279
- # III_REST_PORT=3111
1280
-
1281
- # Features
1282
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1283
- # every PostToolUse hook calls your
1284
- # LLM provider to compress the
1285
- # observation — expect significant
1286
- # token spend on active sessions.
1287
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1288
- # memory slots — persona,
1289
- # user_preferences, tool_guidelines,
1290
- # project_context, guidance,
1291
- # pending_items, session_patterns,
1292
- # self_notes. Size-limited; agent
1293
- # edits via memory_slot_* tools.
1294
- # Pinned slots addressable for
1295
- # SessionStart injection.
1296
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1297
- # Stop hook fires mem::slot-reflect:
1298
- # scans recent observations, auto-
1299
- # appends TODOs to pending_items,
1300
- # counts patterns in
1301
- # session_patterns, records touched
1302
- # files in project_context. Fire-
1303
- # and-forget; does not block.
1304
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1305
- # - SessionStart may inject ~1-2K
1306
- # chars of project context into
1307
- # the first turn of each session
1308
- # (this is what actually reaches
1309
- # the model — Claude Code treats
1310
- # SessionStart stdout as context)
1311
- # - PreToolUse fires /agentmemory/enrich
1312
- # on every file-touching tool call
1313
- # (resource cleanup, not a token
1314
- # fix — PreToolUse stdout is debug
1315
- # log only per Claude Code docs)
1316
- # Observations are still captured via
1317
- # PostToolUse regardless of this flag.
1318
- # GRAPH_EXTRACTION_ENABLED=false
1319
- # CONSOLIDATION_ENABLED=true
1320
- # LESSON_DECAY_ENABLED=true
1321
- # OBSIDIAN_AUTO_EXPORT=false
1322
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1323
- # CLAUDE_MEMORY_BRIDGE=false
1324
- # SNAPSHOT_ENABLED=false
1325
-
1326
- # Team
1327
- # TEAM_ID=
1328
- # USER_ID=
1329
- # TEAM_MODE=private
1330
-
1331
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1332
- # AGENTMEMORY_TOOLS=core
1333
- ```
1334
-
1335
- ---
1336
-
1337
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1338
-
1339
- `3111` portunda 124 endpoint. REST API varsayılan olarak `127.0.0.1`'e bağlanır. `AGENTMEMORY_SECRET` ayarlandığında korumalı endpoint'ler `Authorization: Bearer <secret>` gerektirir ve mesh sync endpoint'leri her iki eşte de `AGENTMEMORY_SECRET` gerektirir.
1340
-
1341
- <details>
1342
- <summary>Önemli endpoint'ler</summary>
1343
-
1344
- | Method | Path | Açıklama |
1345
- |--------|------|-------------|
1346
- | `GET` | `/agentmemory/health` | Sağlık kontrolü (her zaman public) |
1347
- | `POST` | `/agentmemory/session/start` | Oturum başlat + bağlam al |
1348
- | `POST` | `/agentmemory/session/end` | Oturumu bitir |
1349
- | `POST` | `/agentmemory/observe` | Gözlem yakala |
1350
- | `POST` | `/agentmemory/smart-search` | Hibrit arama |
1351
- | `POST` | `/agentmemory/context` | Bağlam üret |
1352
- | `POST` | `/agentmemory/remember` | Uzun süreli belleğe kaydet |
1353
- | `POST` | `/agentmemory/forget` | Gözlemleri sil |
1354
- | `POST` | `/agentmemory/enrich` | Dosya bağlamı + bellekler + bug'lar |
1355
- | `GET` | `/agentmemory/profile` | Proje profili |
1356
- | `GET` | `/agentmemory/export` | Tüm veriyi dışa aktar |
1357
- | `POST` | `/agentmemory/import` | JSON'dan içeri aktar |
1358
- | `POST` | `/agentmemory/graph/query` | Bilgi grafı sorgusu |
1359
- | `POST` | `/agentmemory/team/share` | Takımla paylaş |
1360
- | `GET` | `/agentmemory/audit` | Denetim izi |
1361
-
1362
- Tam endpoint listesi: [`src/triggers/api.ts`](../src/triggers/api.ts)
1363
-
1364
- </details>
1365
-
1366
- ---
1367
-
1368
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1369
-
1370
- ```bash
1371
- npm run dev # Hot reload
1372
- npm run build # Production build
1373
- npm test # 950+ test
1374
- npm run test:integration # API testleri (çalışan servisler gerektirir)
1375
- ```
1376
-
1377
- **Ön koşullar:** Node.js >= 20, [iii-engine](https://iii.dev/docs) veya Docker
1378
-
1379
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1380
-
1381
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.zh-CN.md DELETED
@@ -1,1378 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — 为 AI 编码代理提供持久化记忆" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- 让你的编码代理记住一切。不再重复解释。
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- 为 Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode 以及任何 MCP 客户端提供持久化记忆。
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- 简体中文 |
16
- <a href="README.zh-TW.md">繁體中文</a> |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>这份 gist 以置信度评分、生命周期管理、知识图谱和混合搜索扩展了 Karpathy 的 LLM Wiki 模式:agentmemory 就是其实现。</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">安装</a> &bull;
73
- <a href="#quick-start">快速开始</a> &bull;
74
- <a href="#benchmarks">基准测试</a> &bull;
75
- <a href="#vs-competitors">对比竞品</a> &bull;
76
- <a href="#works-with-every-agent">代理</a> &bull;
77
- <a href="#how-it-works">工作原理</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">查看器</a> &bull;
80
- <a href="#iii-console">iii 控制台</a> &bull;
81
- <a href="#powered-by-iii">由 iii 驱动</a> &bull;
82
- <a href="#configuration">配置</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## 安装
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # 一次安装 — 全局可用 `agentmemory` 命令
92
- # 如果在 macOS/Linux 的系统 Node 上遇到 EACCES,请重试:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # 在 :3111 启动记忆服务器
95
- agentmemory demo # 注入示例会话并验证召回
96
- agentmemory connect claude-code # 连接你的代理(也支持: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- 或通过 `npx`(无需安装):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- 提醒 — npx 会按版本缓存。如果裸 `npx @agentmemory/agentmemory` 命令运行的是旧版本,强制使用最新版 `npx -y @agentmemory/agentmemory@latest`,或一次性清除缓存 `rm -rf ~/.npm/_npx`(macOS/Linux;Windows 上删除 `%LOCALAPPDATA%\npm-cache\_npx`)。从 v0.9.16+ 起,首次 npx 运行会内联提示你全局安装,这样之后裸 `agentmemory` 命令在任何地方都能用。
106
-
107
- 完整选项见下方[快速开始](#quick-start)。各代理具体接入见[支持所有代理](#works-with-every-agent)。
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
-
113
- agentmemory 兼容任何支持 hooks、MCP 或 REST API 的代理。所有代理共享同一个记忆服务器。
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>原生插件 + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>原生插件 + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>原生插件 + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>原生插件 + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>原生插件 + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>原生 Memory trait 后端</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP 服务器</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP 服务器</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + 插件</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP 服务器</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP 服务器</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP 服务器</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP 服务器</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP 服务器</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP 服务器</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>兼容<strong>任何</strong>使用 MCP 或 HTTP 的代理。一个服务器,所有代理共享记忆。</sub>
204
- </p>
205
-
206
- ---
207
-
208
- 你每次会话都在重复解释同样的架构。你反复发现同样的 bug。你重复教同样的偏好。内建的记忆(CLAUDE.md、.cursorrules)上限是 200 行而且会过时。agentmemory 解决了这个问题。它在后台静默捕获代理的行为,将其压缩为可搜索的记忆,并在下次会话开始时注入正确的上下文。一条命令。跨代理工作。
209
-
210
- **改变了什么:** 会话 1 你设置了 JWT 鉴权。会话 2 你要求限流。代理已经知道你的鉴权使用 `src/middleware/auth.ts` 中的 jose 中间件,测试覆盖了 token 校验,你选择 jose 而非 jsonwebtoken 是为了 Edge 兼容性。无需重新解释。无需复制粘贴。代理就是*知道*。
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0 新功能** — 落地页 [agent-memory.dev](https://agent-memory.dev) 上线,文件系统连接器(`@agentmemory/fs-watcher`),独立 MCP 现在代理至正在运行的服务器,使 hooks 和查看器保持一致,审计策略在所有删除路径上得到统一,健康状态在小型 Node 进程上不再误报 `memory_critical`。完整变更见 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)。
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### 检索准确率
227
-
228
- **coding-agent-life-v1** (内部语料库,沙盒可复现)
229
-
230
- | 适配器 | P@5 | R@5 | Top-5 命中率 | p50 延迟 |
231
- |---|---|---|---|---|
232
- | **agentmemory 混合** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep 基线 | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100% Top-5 命中率。在同一输入下,精度比 grep 基线高 **2.2×**。完整按类型分解:[`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
-
237
- **LongMemEval-S** (ICLR 2025,500 个问题)
238
-
239
- | 系统 | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | 仅 BM25 回退 | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Token 节省
248
-
249
- | 方法 | Token/年 | 成本/年 |
250
- |---|---|---|
251
- | 粘贴全部上下文 | 19.5M+ | 不可能(超出窗口) |
252
- | LLM 摘要 | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + 本地嵌入 | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > 嵌入模型:`all-MiniLM-L6-v2` (本地、免费、无需 API key)。完整报告:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。竞品对比:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 对比 mem0、Letta、Khoj、claude-mem、Hippo。
261
-
262
- **本地复现:** [`eval/README.md`](../eval/README.md) — 适配器可插拔的 harness,支持 LongMemEval `_s`(公开 500 问)+ `coding-agent-life-v1`(内部 15 会话语料)。Grep / 向量 / agentmemory 适配器并排打分,NDJSON 输出,公开记分卡发布于 [`docs/benchmarks/`](../docs/benchmarks/)。
263
-
264
- **搭配 [codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything) 和 [Graphify](https://github.com/safishamsi/graphify) 使用。** 代码图索引、多代理构建流水线,以及跨文档 / PDF / 图像 / 视频的更广泛知识图谱。agentmemory 记住工作内容;这三个项目点亮上下文层的其余部分。组合配方和问题路由表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">内建 (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>类型</strong></td>
280
- <td>记忆引擎 + MCP 服务器</td>
281
- <td>记忆层 API</td>
282
- <td>完整代理运行时</td>
283
- <td>静态文件</td>
284
- </tr>
285
- <tr>
286
- <td><strong>检索 R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>自动捕获</strong></td>
294
- <td>12 hooks (零人工)</td>
295
- <td>手动调用 <code>add()</code></td>
296
- <td>代理自编辑</td>
297
- <td>手动编辑</td>
298
- </tr>
299
- <tr>
300
- <td><strong>搜索</strong></td>
301
- <td>BM25 + 向量 + 图 (RRF 融合)</td>
302
- <td>向量 + 图</td>
303
- <td>向量 (归档)</td>
304
- <td>将所有内容加载到上下文</td>
305
- </tr>
306
- <tr>
307
- <td><strong>多代理</strong></td>
308
- <td>MCP + REST + 租约 + 信号</td>
309
- <td>API (无协调)</td>
310
- <td>仅在 Letta 运行时内部</td>
311
- <td>每代理一个文件</td>
312
- </tr>
313
- <tr>
314
- <td><strong>框架锁定</strong></td>
315
- <td>无 (任何 MCP 客户端)</td>
316
- <td>无</td>
317
- <td>高 (必须使用 Letta)</td>
318
- <td>每代理格式</td>
319
- </tr>
320
- <tr>
321
- <td><strong>外部依赖</strong></td>
322
- <td>无 (SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + 向量数据库</td>
325
- <td>无</td>
326
- </tr>
327
- <tr>
328
- <td><strong>记忆生命周期</strong></td>
329
- <td>4 层整合 + 衰减 + 自动遗忘</td>
330
- <td>被动提取</td>
331
- <td>代理管理</td>
332
- <td>手动清理</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Token 效率</strong></td>
336
- <td>~1,900 tokens/会话 ($10/年)</td>
337
- <td>依集成方式不同</td>
338
- <td>核心记忆位于上下文</td>
339
- <td>240 条观测达 22K+ tokens</td>
340
- </tr>
341
- <tr>
342
- <td><strong>实时查看器</strong></td>
343
- <td>是 (端口 3113)</td>
344
- <td>云端仪表板</td>
345
- <td>云端仪表板</td>
346
- <td>无</td>
347
- </tr>
348
- <tr>
349
- <td><strong>自托管</strong></td>
350
- <td>是 (默认)</td>
351
- <td>可选</td>
352
- <td>可选</td>
353
- <td>是</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
-
361
- 兼容性:此版本面向稳定的 `iii-sdk` `^0.11.0` 和 iii-engine v0.11.x。
362
-
363
- ### 30 秒体验
364
-
365
- ```bash
366
- # 终端 1:启动服务器
367
- npx @agentmemory/agentmemory
368
-
369
- # 终端 2:注入示例数据并查看召回
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` 会注入 3 个真实会话(JWT 鉴权、N+1 查询修复、限流)并对它们执行语义搜索。你将看到搜索「数据库性能优化」时找到「N+1 查询修复」 — 关键词匹配做不到这一点。
374
-
375
- 打开 `http://localhost:3113` 即时观察记忆的构建过程。
376
-
377
- ### 推荐:全局安装
378
-
379
- `npx` 按版本缓存。如果你上周运行过 `npx @agentmemory/agentmemory@0.9.14`,裸 `npx @agentmemory/agentmemory` 命令可能会从 `~/.npm/_npx/` 提供过期的 0.9.14 而非最新版本。安装一次后,裸 `agentmemory` 命令处处可用:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # 如果在 macOS/Linux 的系统 Node 上遇到 EACCES,请重试:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # 启动服务器(等同于 npx 形式)
386
- agentmemory stop # 停止
387
- agentmemory remove # 卸载所有创建的内容
388
- agentmemory connect claude-code # 连接一个代理
389
- agentmemory doctor # 交互式诊断 + 修复提示
390
- ```
391
-
392
- 从 v0.9.16 开始,首次 npx 运行会内联提示你全局安装 — 回答一次 `Y` 即可。如果你跳过,可使用以下任一方式获取最新版:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # 强制从 npm 拉取最新(跨平台)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # 仅 macOS/Linux (POSIX shell)
397
- ```
398
-
399
- 在 Windows / PowerShell 上,等价的缓存清除命令是 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — 上面的 `npx -y ...@latest` 形式是跨平台选项。
400
-
401
- ### 会话回放
402
-
403
- agentmemory 记录的每个会话都可回放。打开查看器,选择 **Replay** 标签,在时间线上拖动:提示词、工具调用、工具结果和响应都作为离散事件呈现,支持播放/暂停、速度控制(0.5×–4×)和键盘快捷键(空格切换,箭头单步)。
404
-
405
- 已有旧的 Claude Code JSONL 记录想导入?
406
-
407
- ```bash
408
- # 导入默认 ~/.claude/projects 下的全部内容
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # 或导入单个文件
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- 导入的会话与原生会话一起出现在 Replay 选择器中。底层每个条目都通过 `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` 这些 iii 函数路由 — 没有侧通道服务器。
416
-
417
- ### 升级 / 维护
418
-
419
- 当你确实想更新本地运行时时,使用维护命令:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- 警告:此命令会变更当前工作空间/运行时。它可能更新 JavaScript 依赖,可能运行 `cargo install iii-engine --force`,也可能拉取 Docker 镜像。
426
-
427
- 实现细节见 `src/cli.ts`(参考 `src/cli.ts:544-595` 附近的 `runUpgrade`)。
428
-
429
- ### Claude Code(一段话,直接粘贴)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code 不安装插件(MCP-standalone 路径)
436
-
437
- 如果你直接通过 `~/.claude.json` 连接 agentmemory 的 MCP 服务器而不使用 `/plugin install`,Claude Code 永远不会解析 `${CLAUDE_PLUGIN_ROOT}`,你必须把 hook 脚本指向 `~/.claude/settings.json` 中的绝对路径。这些路径通常会嵌入 agentmemory 版本号(例如 `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`),因此下次升级会静默破坏所有 hooks([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
-
439
- 变通方法:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- 这会将同样的 hook 命令合并到 `~/.claude/settings.json`,绝对路径解析到当前安装的 `@agentmemory/agentmemory` 包的 `plugin/` 目录。升级 agentmemory 后重新运行该命令以刷新路径。同一文件中的用户条目会被保留;只替换之前的 agentmemory 条目。仍然推荐使用 `/plugin install` 路径。
446
-
447
- 对于远程或受保护的部署,启动 Claude Code 时设置 `AGENTMEMORY_URL` 和 `AGENTMEMORY_SECRET`。插件会将两个值传递给其捆绑的 MCP 服务器;当 `AGENTMEMORY_URL` 为空时,MCP shim 默认使用 `http://localhost:3111`。
448
-
449
- ### Codex CLI(Codex 插件平台)
450
-
451
- ```bash
452
- # 1. 在单独终端启动记忆服务器
453
- npx @agentmemory/agentmemory
454
-
455
- # 2. 注册 agentmemory 市场并安装插件
456
- codex plugin marketplace add rohitg00/agentmemory
457
- codex plugin add agentmemory@agentmemory
458
- ```
459
-
460
- Codex 插件与 Claude Code 插件同源,来自相同的 `plugin/` 目录。它注册:
461
-
462
- - `@agentmemory/mcp` 作为 MCP 服务器(当 `AGENTMEMORY_URL` 指向运行中的 agentmemory 服务器时,代理全部 51 个工具;若服务器不可达,本地回退至 7 个工具)
463
- - 6 个生命周期 hooks:`SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
- - 4 个 skills:`/recall`、`/remember`、`/session-history`、`/forget`
465
-
466
- Codex 的 hook 引擎会将 `CLAUDE_PLUGIN_ROOT` 注入 hook 子进程(参见 [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)),因此同样的 hook 脚本在两个宿主中都能工作,无需重复实现。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 事件仅 Claude Code 支持,Codex 未注册这些。
467
-
468
- #### Codex Desktop:插件 hooks 当前无响应(有变通方法)
469
-
470
- `CodexHooks` 和 `PluginHooks` 在 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) 中都已稳定且默认启用,但 Codex Desktop 当前不会派发插件本地的 `hooks.json`([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP 工具仍能工作;只是生命周期观测缺失。
471
-
472
- 在上游修复落地前,将同样的 hook 命令镜像到全局 `~/.codex/hooks.json`:
473
-
474
- ```bash
475
- agentmemory connect codex --with-hooks
476
- ```
477
-
478
- 这会在 `~/.codex/hooks.json` 添加一个幂等块,引用捆绑脚本的绝对路径(用户级作用域下无需 `${CLAUDE_PLUGIN_ROOT}` 展开)。升级 agentmemory 后重新运行同一命令以刷新路径。同一文件中的用户条目会被保留;只替换之前的 agentmemory 条目。
479
-
480
- <details>
481
- <summary><b>OpenClaw(粘贴此提示)</b></summary>
482
-
483
- ```text
484
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
-
486
- {
487
- "mcpServers": {
488
- "agentmemory": {
489
- "command": "npx",
490
- "args": ["-y", "@agentmemory/mcp"],
491
- "env": {
492
- "AGENTMEMORY_URL": "http://localhost:3111"
493
- }
494
- }
495
- }
496
- }
497
-
498
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
- ```
500
-
501
- 完整指南:[`integrations/openclaw/`](../integrations/openclaw/)
502
-
503
- </details>
504
-
505
- <details>
506
- <summary><b>Hermes Agent(粘贴此提示)</b></summary>
507
-
508
- ```text
509
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
-
511
- mcp_servers:
512
- agentmemory:
513
- command: npx
514
- args: ["-y", "@agentmemory/mcp"]
515
-
516
- memory:
517
- provider: agentmemory
518
-
519
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
- ```
521
-
522
- 完整指南:[`integrations/hermes/`](../integrations/hermes/)
523
-
524
- </details>
525
-
526
- ### 其他代理
527
-
528
- 启动记忆服务器:`npx @agentmemory/agentmemory`
529
-
530
- 在使用 `mcpServers` 结构的每个宿主(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)中,agentmemory 条目是**相同的 MCP 服务器块**:
531
-
532
- ```json
533
- "agentmemory": {
534
- "command": "npx",
535
- "args": ["-y", "@agentmemory/mcp"],
536
- "env": {
537
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
- }
540
- }
541
- ```
542
-
543
- **将此条目合并到宿主配置文件的现有 `mcpServers` 对象中** — 不要替换整个文件。如果文件已经有其他服务器,把 `agentmemory` 作为另一个 key 加在它们旁边。如果完全缺少 `mcpServers`,把整块粘贴到 `{ "mcpServers": { ... } }` 里。`${VAR}` 占位符会在 MCP 服务器启动时从 shell 继承 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` — 未设置的变量传空字符串,shim 回退到 `http://localhost:3111`。一个接好的条目同时覆盖本地和远程(k8s / 反代)部署。
544
-
545
- | 代理 | 配置文件 | 备注 |
546
- |---|---|---|
547
- | **Cursor** | `~/.cursor/mcp.json` | 合并到 `mcpServers`。网站上也提供一键深链。 |
548
- | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | 合并到 `mcpServers`。编辑后重启 Claude Desktop。 |
549
- | **Cline / Roo Code / Kilo Code** | Cline MCP 设置 (设置 UI → MCP Servers → Edit) | 同样的 `mcpServers` 块。 |
550
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同样的 `mcpServers` 块。 |
551
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自动合并)。 |
552
- | **OpenClaw** | OpenClaw MCP 配置 | 同样的 `mcpServers` 块,或使用更深的[记忆插件](../integrations/openclaw/)。 |
553
- | **Codex CLI (仅 MCP)** | `.codex/config.toml` | TOML 形式:`codex mcp add agentmemory -- npx -y @agentmemory/mcp`,或手动添加 `[mcp_servers.agentmemory]`。 |
554
- | **Codex CLI (完整插件)** | Codex 插件市场 | `codex plugin marketplace add rohitg00/agentmemory` 然后 `codex plugin add agentmemory@agentmemory`。注册 MCP + 6 个生命周期 hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 个 skills。在 Codex Desktop 上,直到 [openai/codex#16430](https://github.com/openai/codex/issues/16430) 落地之前,还要运行 `agentmemory connect codex --with-hooks` — 那里的插件 hooks 当前无响应。 |
555
- | **OpenCode (仅 MCP)** | `opencode.json` | 不同结构 — 顶层 `mcp` key,command 是数组:`{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
- | **OpenCode (完整插件)** | `plugin/opencode/` | 22 个自动捕获 hooks,覆盖会话生命周期、消息、工具、错误。两个斜杠命令(`/recall`、`/remember`)。将 `plugin/opencode/` 复制到你的 OpenCode 工作空间并把插件条目添加到 `opencode.json`。完整 hook 表和差异分析见 [`plugin/opencode/README.md`](../plugin/opencode/README.md)。 |
557
- | **pi** | `~/.pi/agent/extensions/agentmemory` | 复制 [`integrations/pi`](../integrations/pi/) 并重启 pi。 |
558
- | **Hermes Agent** | `~/.hermes/config.yaml` | 使用更深的[记忆提供者插件](../integrations/hermes/),设置 `memory.provider: agentmemory`。 |
559
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` 会写入标准的 `mcpServers` 块。Hook 负载与 Claude Code 字段兼容,因此现有的 12 hook 脚本无需修改即可工作 — 通过同一 `settings.json` 的 `hooks` 段连接它们。 |
560
- | **Antigravity** (替换 Gemini CLI) | `mcp_config.json`(在 Antigravity 的 User 目录中) | `agentmemory connect antigravity` 会写入标准的 `mcpServers` 块。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。在 2026-06-18 Gemini CLI 停服后使用。 |
561
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` 写入用户级配置。工作空间覆盖放在你的代码旁的 `.kiro/settings/mcp.json` 中。 |
562
- | **Goose** | Goose MCP 设置 UI | 同样的 `mcpServers` 块。 |
563
- | **Aider** | n/a | 直接调用 REST API:`curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
- | **任何代理 (32+)** | n/a | `npx skillkit install agentmemory` 自动检测宿主并合并。 |
565
-
566
- **沙盒化的 MCP 客户端**(Flatpak / Snap / 受限容器)无法访问宿主的 `localhost`:还要在 `env` 块中设置 `"AGENTMEMORY_FORCE_PROXY": "1"`,并把 `AGENTMEMORY_URL` 指向���盒确实能到达的路由(例如你的 LAN IP)。诊断步骤见 [#234](https://github.com/rohitg00/agentmemory/issues/234)。
567
-
568
- ### 程序化访问(Python / Rust / Node)
569
-
570
- agentmemory 将其核心操作注册为 iii 函数(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)。任何拥有 iii SDK 的语言都可以通过 `ws://localhost:49134` 直接调用它们 — 无需为每种语言准备单独的 REST 客户端。
571
-
572
- ```bash
573
- pip install iii-sdk # Python
574
- cargo add iii-sdk # Rust
575
- npm install iii-sdk # Node
576
- ```
577
-
578
- ```python
579
- from iii import register_worker
580
-
581
- iii = register_worker("ws://localhost:49134")
582
- iii.connect()
583
-
584
- iii.trigger({
585
- "function_id": "mem::smart-search",
586
- "payload": {"project": "demo", "query": "how do tokens refresh"},
587
- })
588
- ```
589
-
590
- 完整示例:[`examples/python/`](../examples/python/)(快速开始 + 观测/召回流程)。`:3111` 上的 REST 对没有 iii 运行时的宿主仍然可用。
591
-
592
- ### 从源码构建
593
-
594
- ```bash
595
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
- npm install && npm run build && npm start
597
- ```
598
-
599
- 如果已经安装 `iii`,这会以本地 `iii-engine` 启动 agentmemory;如果 Docker 可用,则回退到 Docker Compose。REST、流和查看器默认绑定到 `127.0.0.1`。
600
-
601
- 手动安装 `iii-engine`。**agentmemory 当前将 `iii-engine` 固定在 `v0.11.2`** — `v0.11.6` 引入了新的「通过 `iii worker add` 沙盒化一切」模型,agentmemory 尚未为此重构。重构落地后即解除固定。如果你已经手动迁移到沙盒模型,可用 `AGENTMEMORY_III_VERSION=<version>` 覆盖。
602
-
603
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
- - **macOS x64:** 把 `aarch64-apple-darwin` 换成 `x86_64-apple-darwin`
605
- - **Linux x64:** 换成 `x86_64-unknown-linux-gnu`
606
- - **Linux arm64:** 换成 `aarch64-unknown-linux-gnu`
607
- - **Windows:** 从 [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) 下载 `iii-x86_64-pc-windows-msvc.zip`,提取 `iii.exe`,加入 PATH
608
-
609
- 或使用 Docker(捆绑的 `docker-compose.yml` 会拉取 `iiidev/iii:0.11.2`)。完整文档:[iii.dev/docs](https://iii.dev/docs)。
610
-
611
- ### Windows
612
-
613
- agentmemory 可在 Windows 10/11 运行,但仅 Node.js 包不够 — 你还需要 `iii-engine` 运行时(一个独立的原生二进制)作为后台进程。官方上游安装器是 `sh` 脚本,目前没有 PowerShell 安装器或 scoop/winget 包,因此 Windows 用户有两条路径:
614
-
615
- **选项 A — 预构建 Windows 二进制(推荐):**
616
-
617
- ```powershell
618
- # 1. 在浏览器打开 https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2
619
- # (我们固定在 v0.11.2,直到 agentmemory 为 v0.11.6+ 引擎要求的
620
- # 新沙盒模型完成重构)
621
- # 2. 下载 iii-x86_64-pc-windows-msvc.zip
622
- # (如果是 ARM 机器则下载 iii-aarch64-pc-windows-msvc.zip)
623
- # 3. 把 iii.exe 解压到 PATH 上的某处,或放在:
624
- # %USERPROFILE%\.local\bin\iii.exe
625
- # (agentmemory 会自动检查该位置)
626
- # 4. 验证:
627
- iii --version
628
- # 应输出:0.11.2
629
-
630
- # 5. 然后照常运行 agentmemory:
631
- npx -y @agentmemory/agentmemory
632
- ```
633
-
634
- **选项 B — Docker Desktop:**
635
-
636
- ```powershell
637
- # 1. 安装 Docker Desktop for Windows
638
- # 2. 启动 Docker Desktop 并确保引擎运行中
639
- # 3. 运行 agentmemory — 它会自动启动捆绑的 compose 文件:
640
- npx -y @agentmemory/agentmemory
641
- ```
642
-
643
- **选项 C — 仅独立 MCP(无引擎):** 如果你只需要 MCP 工具供代理使用,不需要 REST API、查看器或定时任务,则完全跳过引擎:
644
-
645
- ```powershell
646
- npx -y @agentmemory/agentmemory mcp
647
- # 或通过 shim 包:
648
- npx -y @agentmemory/mcp
649
- ```
650
-
651
- **Windows 诊断:** 如果 `npx @agentmemory/agentmemory` 失败,加 `--verbose` 重新运行以看到实际的引擎 stderr。常见失败模式:
652
-
653
- | 症状 | 修复 |
654
- |---|---|
655
- | `iii-engine process started` 然后 `did not become ready within 15s` | 引擎启动崩溃 — 用 `--verbose` 重新运行,检查 stderr |
656
- | `Could not start iii-engine` | `iii.exe` 和 Docker 都未安装。见上面选项 A 或 B |
657
- | 端口冲突 | `netstat -ano \| findstr :3111` 查看占用,然后 kill 或用 `--port <N>` |
658
- | Docker 已安装但仍跳过回退 | 确保 Docker Desktop 确实在运行(系统托盘图标) |
659
-
660
- > 注意:没有 `cargo install iii-engine` — `iii` 未发布到 crates.io。唯一受支持的安装方式是上面的预构建二进制、上游 `sh` 安装脚本(仅 macOS/Linux)和 Docker 镜像。
661
-
662
- ---
663
-
664
- <h2 id="deploy">部署</h2>
665
-
666
- 托管主机的一键模板。每个模板都附带自包含的
667
- Dockerfile,从 npm 拉取 `@agentmemory/agentmemory` 并从官方
668
- `iiidev/iii` Docker Hub 镜像复制 iii 引擎二进制 — 无需
669
- 预构建 agentmemory 镜像。持久存储挂载在
670
- `/data`;首次启动 entrypoint 用面向部署调优的配置
671
- 覆盖 npm 捆绑的 iii 配置(原配置绑定 `127.0.0.1`),
672
- 让其绑定 `0.0.0.0` 并使用绝对 `/data` 路径,生成
673
- HMAC secret,然后通过 `gosu` 从 `root` 降权到 `node`
674
- 再 exec agentmemory CLI。
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- Render 的一键部署按钮要求仓库根有 `render.yaml`,我们刻意保持根目录整洁。使用 [`deploy/render/`](../deploy/render/README.md) 中文档化的 Render Blueprint 流程,手动指向仓库内的蓝图。
682
-
683
- 完整设置细节(HMAC 捕获、查看器 SSH 隧道、轮换、备份、
684
- 成本下限)见 [`deploy/`](../deploy/README.md):
685
-
686
- - [`deploy/fly`](../deploy/fly/README.md) — 单机搭配
687
- `auto_stop_machines = "stop"`;空闲时最便宜。
688
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby 套餐固定费用,
689
- 卷在仪表板中配置。
690
- - [`deploy/render`](../deploy/render/README.md) — Blueprint 流程,
691
- 付费套餐自动磁盘快照。
692
- - [`deploy/coolify`](../deploy/coolify/README.md) — 通过 [Coolify](https://coolify.io/self-hosted)
693
- 在你自己的 VPS 上自托管;同样的 Docker
694
- Compose 栈,主机和数据都归你所有。
695
-
696
- 只发布端口 `3111`。`3113` 上的查看器在容器内仍绑定到
697
- loopback — 每个模板的 README 都文档化了到达它的
698
- SSH 隧道模式。
699
-
700
- ---
701
-
702
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
703
-
704
- 每个编码代理在会话结束时都会忘记一切。你每次会话的前 5 分钟都浪费在重新解释技术栈上。agentmemory 在后台运行,完全消除这一点。
705
-
706
- ```text
707
- Session 1: "Add auth to the API"
708
- Agent writes code, runs tests, fixes bugs
709
- agentmemory silently captures every tool use
710
- Session ends -> observations compressed into structured memory
711
-
712
- Session 2: "Now add rate limiting"
713
- Agent already knows:
714
- - Auth uses JWT middleware in src/middleware/auth.ts
715
- - Tests in test/auth.test.ts cover token validation
716
- - You chose jose over jsonwebtoken for Edge compatibility
717
- Zero re-explaining. Starts working immediately.
718
- ```
719
-
720
- ### 对比内建代理记忆
721
-
722
- 每个 AI 编码代理都自带内建记忆 — Claude Code 有 `MEMORY.md`,Cursor 有 notepad,Cline 有 memory bank。这些像便利贴。agentmemory 是便利贴背后的可搜索数据库。
723
-
724
- | | 内建 (CLAUDE.md) | agentmemory |
725
- |---|---|---|
726
- | 规模 | 200 行上限 | 无限 |
727
- | 搜索 | 把所有内容加载到上下文 | BM25 + 向量 + 图 (仅 top-K) |
728
- | Token 成本 | 240 条观测达 22K+ | ~1,900 tokens(少 92%) |
729
- | 跨代理 | 每代理一个文件 | MCP + REST(任何代理) |
730
- | 协调 | 无 | 租约、信号、动作、例程 |
731
- | 可观测性 | 手动读文件 | 端口 3113 实时查看器 |
732
-
733
- ---
734
-
735
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
736
-
737
- ### 记忆流水线
738
-
739
- ```text
740
- PostToolUse hook fires
741
- -> SHA-256 dedup (5min window)
742
- -> Privacy filter (strip secrets, API keys)
743
- -> Store raw observation
744
- -> LLM compress -> structured facts + concepts + narrative
745
- -> Vector embedding (6 providers + local)
746
- -> Index in BM25 + vector
747
-
748
- Stop / SessionEnd hook fires
749
- -> Summarize session
750
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
751
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
752
-
753
- SessionStart hook fires
754
- -> Load project profile (top concepts, files, patterns)
755
- -> Hybrid search (BM25 + vector + graph)
756
- -> Token budget (default: 2000 tokens)
757
- -> Inject into conversation
758
- ```
759
-
760
- ### 4 层记忆整合
761
-
762
- 灵感来自人脑处理记忆的方式 — 与睡眠时的记忆整合并无不同。
763
-
764
- | 层级 | 内容 | 类比 |
765
- |------|------|---------|
766
- | **Working(工作记忆)** | 来自工具使用的原始观测 | 短期记忆 |
767
- | **Episodic(情景记忆)** | 压缩后的会话摘要 | 「发生了什么」 |
768
- | **Semantic(语义记忆)** | 提取的事实与模式 | 「我知道什么」 |
769
- | **Procedural(程序记忆)** | 工作流与决策模式 | 「怎么做」 |
770
-
771
- 记忆随时间衰减(Ebbinghaus 曲线)。频繁访问的记忆会强化。陈旧记忆会自动清除。矛盾会被检测并解决。
772
-
773
- ### 捕获了什么
774
-
775
- | Hook | 捕获内容 |
776
- |------|----------|
777
- | `SessionStart` | 项目路径、会话 ID |
778
- | `UserPromptSubmit` | 用户提示词(隐私过滤) |
779
- | `PreToolUse` | 文件访问模式 + 富化上下文 |
780
- | `PostToolUse` | 工具名、���入、输出 |
781
- | `PostToolUseFailure` | 错误上下文 |
782
- | `PreCompact` | 在压缩前重新注入记忆 |
783
- | `SubagentStart/Stop` | 子代理生命周期 |
784
- | `Stop` | 会话结束摘要 |
785
- | `SessionEnd` | 会话完成标记 |
786
-
787
- ### 关键能力
788
-
789
- | 能力 | 描述 |
790
- |---|---|
791
- | **自动捕获** | 每次工具使用都通过 hooks 记录 — 零人工 |
792
- | **语义搜索** | BM25 + 向量 + 知识图谱,RRF 融合 |
793
- | **记忆演化** | 版本控制、覆盖关系、关系图 |
794
- | **自动遗忘** | TTL 过期、矛盾检测、重要性驱逐 |
795
- | **隐私优先** | API key、secret、`<private>` 标签存储前被剥离 |
796
- | **自愈** | 熔断器、提供者回退链、健康监控 |
797
- | **Claude 桥接** | 与 MEMORY.md 双向同步 |
798
- | **知识图谱** | 实体抽取 + BFS 遍历 |
799
- | **团队记忆** | 团队成员之间的命名空间共享 + 私有 |
800
- | **引用溯源** | 任意记忆追溯到源观测 |
801
- | **Git 快照** | 记忆状态的版本、回滚、diff |
802
-
803
- ---
804
-
805
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
806
-
807
- 三路检索结合三种信号:
808
-
809
- | 流 | 作用 | 何时启用 |
810
- |---|---|---|
811
- | **BM25** | 词干化关键词匹配 + 同义词扩展 | 始终启用 |
812
- | **Vector(向量)** | 稠密嵌入上的余弦相似度 | 配置了嵌入提供者 |
813
- | **Graph(图)** | 通过实体匹配进行知识图谱遍历 | 查询中检测到实体 |
814
-
815
- 通过 Reciprocal Rank Fusion (RRF, k=60) 融合,并按会话多样化(每会话最多 3 个结果)。
816
-
817
- BM25 开箱即用支持希腊语、西里尔语、希伯来语、阿拉伯语和带音标的拉丁文分词。对于中文/日语/韩语记忆,安装可选分词器(`npm install @node-rs/jieba tiny-segmenter`)以把 CJK 串切分为词级 token;不安装的话,agentmemory 会软回退到整串分词并在 stderr 打印一次性提示。
818
-
819
- ### 嵌入提供者
820
-
821
- agentmemory 自动检测你的提供者。为获得最佳效果,安装本地嵌入(免费):
822
-
823
- ```bash
824
- npm install @xenova/transformers
825
- ```
826
-
827
- | 提供者 | 模型 | 成本 | 备注 |
828
- |---|---|---|---|
829
- | **本地 (推荐)** | `all-MiniLM-L6-v2` | 免费 | 离线,比仅 BM25 召回率高 +8pp |
830
- | Gemini | `gemini-embedding-001` | 免费层 | 100+ 语言,768/1536/3072 维 (MRL),2048-token 输入。替换 `text-embedding-004`([已弃用,2026 年 1 月 14 日下线](https://ai.google.dev/gemini-api/docs/deprecations)) |
831
- | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高质量 |
832
- | Voyage AI | `voyage-code-3` | 付费 | 针对代码优化 |
833
- | Cohere | `embed-english-v3.0` | 免费试用 | 通用 |
834
- | OpenRouter | 任意模型 | 视而定 | 多模型代理 |
835
-
836
- ---
837
-
838
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
839
-
840
- 53 个工具、6 个资源、3 个提示词、4 个 skills — 任何代理可用的最全面 MCP 记忆工具包。
841
-
842
- > **MCP shim 对比完整服务器:** 已发布的 `@agentmemory/mcp` 包是一个薄 shim。**只有当它能通过 `AGENTMEMORY_URL` 连通运行中的 agentmemory 服务器**(代理模式)时,才暴露完整的 51 工具表面。在没有可达服务器的情况下,shim 回退到 7 工具的本地集合(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)。`AGENTMEMORY_TOOLS=core|all` 环境变量是*服务器端*标志 — 在 shim 的 `env` 块中设置无效。如果在 Cursor / OpenCode / Gemini CLI 中只看到 7 个工具,启动 `npx @agentmemory/agentmemory`(或 Docker 栈)并设置 `AGENTMEMORY_URL=http://localhost:3111`。
843
-
844
- ### 51 个工具
845
-
846
- <details>
847
- <summary>核心工具(始终可用)</summary>
848
-
849
- | 工具 | 描述 |
850
- |------|-------------|
851
- | `memory_recall` | 搜索过去的观测 |
852
- | `memory_compress_file` | 在保留结构的同时压缩 markdown 文件 |
853
- | `memory_save` | 保存洞察、决策或模式 |
854
- | `memory_patterns` | 检测反复出现的模式 |
855
- | `memory_smart_search` | 混合语义 + 关键词搜索 |
856
- | `memory_file_history` | 关于特定文件的过去观测 |
857
- | `memory_sessions` | 列出最近的会话 |
858
- | `memory_timeline` | 按时间排列的观测 |
859
- | `memory_profile` | 项目档案(概念、文件、模式) |
860
- | `memory_export` | 导出所有记忆数据 |
861
- | `memory_relations` | 查询关系图 |
862
-
863
- </details>
864
-
865
- <details>
866
- <summary>扩展工具(总 51 — 设置 AGENTMEMORY_TOOLS=all)</summary>
867
-
868
- | 工具 | 描述 |
869
- |------|-------------|
870
- | `memory_patterns` | 检测反复出现的模式 |
871
- | `memory_timeline` | 按时间排列的观测 |
872
- | `memory_relations` | 查询关系图 |
873
- | `memory_graph_query` | 知识图谱遍历 |
874
- | `memory_consolidate` | 运行 4 层整合 |
875
- | `memory_claude_bridge_sync` | 与 MEMORY.md 同步 |
876
- | `memory_team_share` | 与团队成员共享 |
877
- | `memory_team_feed` | ��近共享条目 |
878
- | `memory_audit` | 操作审计轨迹 |
879
- | `memory_governance_delete` | 带审计轨迹的删除 |
880
- | `memory_snapshot_create` | Git 版本快照 |
881
- | `memory_action_create` | 创建带依赖的工作项 |
882
- | `memory_action_update` | 更新动作状态 |
883
- | `memory_frontier` | 按优先级排序的未阻塞动作 |
884
- | `memory_next` | 单个最重要的下一动作 |
885
- | `memory_lease` | 独占动作租约(多代理) |
886
- | `memory_routine_run` | 实例化工作流例程 |
887
- | `memory_signal_send` | 代理间消息 |
888
- | `memory_signal_read` | 带回执读取消息 |
889
- | `memory_checkpoint` | 外部条件门 |
890
- | `memory_mesh_sync` | 实例间 P2P 同步 |
891
- | `memory_sentinel_create` | 事件驱动监视器 |
892
- | `memory_sentinel_trigger` | 外部触发哨兵 |
893
- | `memory_sketch_create` | 临时动作图 |
894
- | `memory_sketch_promote` | 提升为永久 |
895
- | `memory_crystallize` | 紧凑化动作链 |
896
- | `memory_diagnose` | 健康检查 |
897
- | `memory_heal` | 自动修复卡住的状态 |
898
- | `memory_facet_tag` | 维度:值 标签 |
899
- | `memory_facet_query` | 按 facet 标签查询 |
900
- | `memory_verify` | 追溯来源 |
901
-
902
- </details>
903
-
904
- ### 6 个资源 · 3 个提示词 · 4 个 Skills
905
-
906
- | 类型 | 名称 | 描述 |
907
- |------|------|-------------|
908
- | Resource | `agentmemory://status` | 健康、会话数、记忆数 |
909
- | Resource | `agentmemory://project/{name}/profile` | 项目级智能 |
910
- | Resource | `agentmemory://memories/latest` | 最新 10 条活跃记忆 |
911
- | Resource | `agentmemory://graph/stats` | 知识图谱统计 |
912
- | Prompt | `recall_context` | 搜索并返回上下文消息 |
913
- | Prompt | `session_handoff` | 代理之间的交接数据 |
914
- | Prompt | `detect_patterns` | 分析反复出现的模式 |
915
- | Skill | `/recall` | 搜索记忆 |
916
- | Skill | `/remember` | 保存到长期记忆 |
917
- | Skill | `/session-history` | 最近的会话摘要 |
918
- | Skill | `/forget` | 删除观测/会话 |
919
-
920
- ### 独立 MCP
921
-
922
- 无需完整服务器即可运行 — 适用于任何 MCP 客户端。以下两种都可以:
923
-
924
- ```bash
925
- npx -y @agentmemory/agentmemory mcp # 规范命令(始终可用)
926
- npx -y @agentmemory/mcp # shim 包别名
927
- ```
928
-
929
- 或添加到你的代理的 MCP 配置:
930
-
931
- 大多数代理(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
932
- ```json
933
- {
934
- "mcpServers": {
935
- "agentmemory": {
936
- "command": "npx",
937
- "args": ["-y", "@agentmemory/mcp"],
938
- "env": {
939
- "AGENTMEMORY_URL": "http://localhost:3111"
940
- }
941
- }
942
- }
943
- }
944
- ```
945
-
946
- 把 `agentmemory` 条目合并到你的宿主现有的 `mcpServers` 对象中,而非替换文件。对于无法访问宿主 `localhost` 的沙盒客户端,在 env 块中添加 `"AGENTMEMORY_FORCE_PROXY": "1"`,并将 `AGENTMEMORY_URL` 设为沙盒能到达的路由。
947
-
948
- OpenCode (`opencode.json`):
949
- ```json
950
- {
951
- "mcp": {
952
- "agentmemory": {
953
- "type": "local",
954
- "command": ["npx", "-y", "@agentmemory/mcp"],
955
- "enabled": true
956
- }
957
- },
958
- "plugin": ["./plugins/agentmemory-capture.ts"]
959
- }
960
- ```
961
-
962
- 从仓库复制插件文件:
963
- ```bash
964
- mkdir -p ~/.config/opencode/plugins
965
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
966
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
967
- ```
968
-
969
- ---
970
-
971
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
972
-
973
- 在端口 `3113` 自动启动。实时观测流、会话浏览器、记忆浏览器、知识图谱可视化和健康仪表板。
974
-
975
- ```bash
976
- open http://localhost:3113
977
- ```
978
-
979
- 查看器服务器默认绑定 `127.0.0.1`。REST 提供的 `/agentmemory/viewer` 端点遵循正常的 `AGENTMEMORY_SECRET` bearer-token 规则。CSP 头使用每响应 script nonce 并禁用内联处理器属性(`script-src-attr 'none'`)。
980
-
981
- ---
982
-
983
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
984
-
985
- `:3113` 上的查看器展示你的代理**记住了什么**。[iii 控制台](https://iii.dev/docs/console) 展示你的代理**做了什么** — 每个记忆操作都是 OpenTelemetry trace,每个 KV 条目都可编辑,每个函数都可调用,每个流都可挂载。同一记忆的两个窗口:一个面向产品,一个面向引擎。
986
-
987
- 观察一次 `memory_smart_search` 触发,在瀑布图中看到 BM25 扫描 → 嵌入查找 → RRF 融合 → 重排器。在 KV 浏览器中编辑卡住的整合计时器。用调整后的负载重放一个 `PostToolUse` hook。固定 WebSocket 流,实时观察观测落地。
988
-
989
- agentmemory 免费提供这一切,因为每个函数、触发器、状态作用域、流都是 iii 原语 — 没有定制,没有需要插桩的地方。
990
-
991
- <p align="center">
992
- <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
993
- <br/>
994
- <em>Workers 页面:每个已连接的 worker — 包括 agentmemory 本身 — 显示 PID、函数数、运行时和最后在线时间。</em>
995
- </p>
996
-
997
- **已经装好了。** 控制台随 `iii` 一同发布 — 无需单独安装器。
998
-
999
- **与 agentmemory 并行启动:**
1000
-
1001
- ```bash
1002
- # agentmemory 查看器占用端口 3113,所以在 3114 运行控制台。
1003
- # 引擎 REST (3111)、WebSocket (3112)、bridge (49134) 默认值与 agentmemory 匹配。
1004
- iii console --port 3114
1005
- ```
1006
-
1007
- 然后打开 `http://localhost:3114`。加 `--enable-flow` 开启实验性架构图页面。
1008
-
1009
- 仅在你移动了引擎端点时才覆盖:
1010
-
1011
- ```bash
1012
- iii console --port 3114 \
1013
- --engine-port 3111 \
1014
- --ws-port 3112 \
1015
- --bridge-port 49134
1016
- ```
1017
-
1018
- **控制台能做什么:**
1019
-
1020
- | 页面 | 用途 |
1021
- |------|-----------|
1022
- | **Workers** | 查看每个已连接 worker 及其实时指标 — 包括 agentmemory worker 本身。 |
1023
- | **Functions** | 直接用 JSON 负载调用 agentmemory 的任何函数 — 测试 `memory.recall`、`memory.consolidate`、`graph.query` 无需接入客户端。 |
1024
- | **Triggers** | 重放 HTTP、cron、事件和状态触发器 — 手动触发整合 cron、重试 HTTP 路由、发出状态变化。 |
1025
- | **States** | 完整 CRUD 的 KV 浏览器 — 会话、记忆槽位、生命周期计时器、嵌入索引 — 就地编辑值。 |
1026
- | **Streams** | 记忆写入、hook 事件和观测更新流经 iii 流时的实时 WebSocket 监视器。 |
1027
- | **Queues** | 持久队列主题 + 死信管理。重放或丢弃失败的嵌入/压缩任务。 |
1028
- | **Traces** | OpenTelemetry 瀑布/火焰/服务分解视图。按 `trace_id` 过滤,精确查看单次 `memory.search` 产生了哪些函数、DB 调用和嵌入请求。 |
1029
- | **Logs** | 结构化 OTEL 日志,过滤并与 trace/span ID 关联。 |
1030
- | **Config** | 运行时配置 — 看到引擎正在使用的 workers、提供者和端口。 |
1031
- | **Flow** | (可选,`--enable-flow`) 每个 worker、触发器和流的交互式架构图。 |
1032
-
1033
- <p align="center">
1034
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1035
- <br/>
1036
- <em>Traces:每个记忆操作的瀑布/火焰/服务分解。</em>
1037
- </p>
1038
-
1039
- **Traces 已开启:**
1040
-
1041
- `iii-config.yaml` 出厂启用 `iii-observability` worker(`exporter: memory`、`sampling_ratio: 1.0`、指标 + 日志)。无需额外配置 — agentmemory 启动那一刻,每个记忆操作都会发出一个 trace span 和一个控制台可读的结构化日志。
1042
-
1043
- 如果你想改为导出到 Jaeger/Honeycomb/Grafana Tempo,把 `exporter: memory` 改为 `exporter: otlp` 并按 iii 的可观测性文档设置收集器端点。
1044
-
1045
- > **提醒:** 控制台本身未强制鉴权 — 保持其绑定 `127.0.0.1`(默认)并永远不要对外暴露。
1046
-
1047
- ---
1048
-
1049
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1050
-
1051
- agentmemory **本身就是一个运行中的 [iii](https://iii.dev) 实例**。函数、触发器、KV 状态、流、OTEL traces — 全部都是 iii 原语。你没有安装 Postgres、Redis、Express、pm2 或 Prometheus,因为 iii 替代了它们。
1052
-
1053
- 这意味着多一条命令就能为 agentmemory 增加一整套新能力。
1054
-
1055
- ### 一条命令扩展 agentmemory
1056
-
1057
- ```bash
1058
- iii worker add iii-pubsub # 把记忆写入扇出到每个连接的实例
1059
- iii worker add iii-cron # 定时整合、衰减扫描、快照轮换
1060
- iii worker add iii-queue # 嵌入 + 压缩任务的持久重试
1061
- iii worker add iii-observability # 每个记忆操作的 OTEL traces(默认开启)
1062
- iii worker add iii-sandbox # 在隔离 microVM 内运行召回到的代码
1063
- iii worker add iii-database # 切换 SQL 后端的状态适配器
1064
- iii worker add mcp # 在 agentmemory 的 MCP 旁开通用 MCP 宿主
1065
- ```
1066
-
1067
- 每个 `iii worker add` 都会把新的函数和触发器注册到 agentmemory 正在运行的同一引擎中。查看器和控制台立即接收 — 无需重载、无需新集成、无需新容器。
1068
-
1069
- | `iii worker add` | 在 agentmemory 上获得的额外能力 |
1070
- |---|---|
1071
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 多实例记忆:每次 `remember` 扇出,每次 `search` 读取并集 |
1072
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 定时生命周期 — 夜间整合、周快照、按固定时钟衰减 |
1073
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 持久重试:失败的嵌入 + 压缩任务在重启后存活,无观测丢失 |
1074
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 每个函数的 OTEL traces、指标、日志 — 从第一天起就接入 `iii-config.yaml` |
1075
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` 出来的代码在一次性 VM 中运行,不在你的 shell 中 |
1076
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 当默认的内存 KV 不够用时,SQL 后端状态适配器 |
1077
- | [`mcp`](https://workers.iii.dev/workers/mcp) | 在 agentmemory 的旁边架设额外 MCP 服务器,共享同一引擎 |
1078
-
1079
- 完整注册表:[workers.iii.dev](https://workers.iii.dev)。那里的每个 worker 都通过 agentmemory 所用的同样原语组合 — 而你已经拥有的 agentmemory 本身就是其中之一。
1080
-
1081
- ### iii 替代了什么
1082
-
1083
- | 传统栈 | agentmemory 使用 |
1084
- |---|---|
1085
- | Express.js / Fastify | iii HTTP Triggers |
1086
- | SQLite / Postgres + pgvector | iii KV State + 内存向量索引 |
1087
- | SSE / Socket.io | iii Streams (WebSocket) |
1088
- | pm2 / systemd | iii engine worker 监管 |
1089
- | Prometheus / Grafana | iii OTEL + 健康监控 |
1090
- | 自定义插件系统 | `iii worker add <name>` |
1091
-
1092
- **118 个源文件 · ~21,800 行代码 · 950+ 测试 · 123 个函数 · 34 个 KV 作用域** — 全部基于三种原语。没有 `agentmemory plugin install`。插件系统就是 iii 本身。
1093
-
1094
- ---
1095
-
1096
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1097
-
1098
- ### LLM 提供者
1099
-
1100
- agentmemory 从你的环境自动检测。默认情况下,除非你配置提供者或显式启用 Claude 订阅回退,否则不会发起 LLM 调用。
1101
-
1102
- | 提供者 | 配置 | 备注 |
1103
- |----------|--------|-------|
1104
- | **No-op(默认)** | 无需配置 | LLM 驱动的 compress/summarize 被禁用。合成 BM25 压缩 + 召回仍可用。如果你以前依赖 Claude 订阅回退,请见下面的 `AGENTMEMORY_ALLOW_AGENT_SDK`。 |
1105
- | Anthropic API | `ANTHROPIC_API_KEY` | 按 token 计费 |
1106
- | MiniMax | `MINIMAX_API_KEY` | Anthropic 兼容 |
1107
- | Gemini | `GEMINI_API_KEY` | 同时启用嵌入 |
1108
- | OpenRouter | `OPENROUTER_API_KEY` | 任意模型 |
1109
- | Claude 订阅回退 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 仅按需启用。会派生 `@anthropic-ai/claude-agent-sdk` 会话 — 曾导致无限 Stop-hook 递归(#149 后续)故不再默认。 |
1110
-
1111
- ### 成本感知的模型选择
1112
-
1113
- 后台压缩在每次观测时运行,模型选择会显著影响月度支出。捕获的工作负载数据:635 次请求 / 888K tokens / 35 小时活跃使用,基于 2026-05-23 OpenRouter 定价对三个模型评测。
1114
-
1115
- | 等级 | 模型 | 输入 / 1M | 输出 / 1M | 35 小时捕获工作负载成本 | 备注 |
1116
- |------|-------|------------|-------------|---------------------------|-------|
1117
- | 推荐 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 压缩 + 摘要质量稳定,比 Sonnet 便宜 ~10×。 |
1118
- | 推荐 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 略旧但仍胜任仅压缩工作负载。 |
1119
- | 推荐 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 如果你的会话多为代码,代码推理能力强。 |
1120
- | 高级 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 质量高但对长期后台工作来说成本昂贵。 |
1121
- | 高级 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | 与 Sonnet 同档。 |
1122
- | 避免 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推理级模型;用于压缩属于巨额超支。 |
1123
-
1124
- 当 `OPENROUTER_MODEL` 匹配高级层模式时,agentmemory 会打印运行时警告。在做出知情选择后,设置 `AGENTMEMORY_SUPPRESS_COST_WARNING=1` 来消音。
1125
-
1126
- 记忆工作的质量-成本权衡:压缩是质量门槛相对宽松的摘要任务(代理重新阅读摘要,而非用户)。DeepSeek-V4-Pro / Qwen3-Coder 在该任务上与 Sonnet 误差极小,而成本约低 10×。把高级层模型留给你直接阅读的查询。
1127
-
1128
- 来源:[OpenRouter Sonnet 4.6 定价](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek 定价说明](https://api-docs.deepseek.com/quick_start/pricing/)。
1129
-
1130
- ### 多代理记忆(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1131
-
1132
- 在多个角色共享一台 agentmemory 服务器的多代理设置中(architect / developer / reviewer / researcher / support-agent),`AGENT_ID` 给每次写入打上发起角色的标签。`AGENTMEMORY_AGENT_SCOPE` 控制召回是否按该标签过滤。
1133
-
1134
- ```env
1135
- TEAM_ID=company
1136
- USER_ID=engineering-team
1137
- AGENT_ID=architect
1138
- AGENTMEMORY_AGENT_SCOPE=isolated # 可选;默认 "shared"
1139
- ```
1140
-
1141
- 两种模式:
1142
-
1143
- | 模式 | 标记写入 | 过滤召回 | 何时使用 |
1144
- |------|------------|---------------|-------------|
1145
- | `shared`(默认) | 是 | 否 | 跨代理共享上下文且带审计轨迹。Architect 能看到 developer 记下了什么,但每条记录都标明发言者。 |
1146
- | `isolated` | 是 | 是 | 严格隔离。Architect 永远不会看到 developer 的观测/记忆/会话。 |
1147
-
1148
- 设置 `AGENT_ID` 后会被标记的内容:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。角色从 `api::session::start` → `mem::observe` → `mem::compress` → KV 流转。
1149
-
1150
- isolated 模式下被过滤的内容:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。每个端点都接受 `?agentId=<role>` 来按请求覆盖,以及 `?agentId=*` 来完全跳过环境作用域。`/memories` 还接受 `?includeOrphans=true` 来浮现 `agentId` 为 undefined 的预-AGENT_ID 记忆。
1151
-
1152
- SDK / REST 层的按调用覆盖:每个修改端点(`/session/start`、`/remember`)都接受请求体中的 `agentId` 字段,胜过环境变量。对于在一个服务器进程中路由多角色的运行时很有用。
1153
-
1154
- 当 `AGENT_ID` 未设置时,记忆保持无作用域(遗留行为,无标签、无过滤)。
1155
-
1156
- ### 端口
1157
-
1158
- agentmemory + iii-engine 默认绑定四个端口。如果重启失败并显示 `port in use`,这张表告诉你该查找什么进程。
1159
-
1160
- | 端口 | 进程 | 用途 | 环境覆盖 |
1161
- |------|---------|---------|--------------|
1162
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1163
- | `3112` | iii-engine | 内部流 worker(由 agentmemory + 查看器消费) | `III_STREAMS_PORT` |
1164
- | `3113` | agentmemory | 实时查看器(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1165
- | `49134` | iii-engine | WebSocket — workers 在此注册,OTel 遥测在此流过 | `III_ENGINE_URL`(完整 URL,默认 `ws://localhost:49134`) |
1166
-
1167
- 崩溃后端口仍被占用时的陈旧进程清理:
1168
-
1169
- ```bash
1170
- # macOS / Linux — 查找每个端口上的进程并杀掉
1171
- lsof -i :3111,3112,3113,49134
1172
- pkill -f agentmemory || true
1173
- pkill -f 'iii ' || true
1174
-
1175
- # Windows
1176
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1177
- taskkill /F /PID <pid>
1178
- ```
1179
-
1180
- `agentmemory stop` 在优雅关闭时干净地回收 worker 和 engine pidfile(#640、#474)。上面的手动清理仅针对崩溃后两个 pidfile 都未留下的情况。
1181
-
1182
- ### 配置文件
1183
-
1184
- 把 agentmemory 运行时配置放到 `~/.agentmemory/.env`,而不是在每个 shell 中 export 变量。如果查看器显示像 `export ANTHROPIC_API_KEY=...` 这样的设置提示,把它复制到该文件中作为 `ANTHROPIC_API_KEY=...`(去掉 `export` 前缀),然后重启 agentmemory。
1185
-
1186
- 进程环境变量仍然有效,优先级高于文件中的值。
1187
-
1188
- 在 Windows 上,同一文件位于 `%USERPROFILE%\.agentmemory\.env`:
1189
-
1190
- ```powershell
1191
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1192
- notepad $HOME\.agentmemory\.env
1193
- ```
1194
-
1195
- 要用 Claude Code Pro/Max 订阅而非 API key 测试,显式启用:
1196
-
1197
- ```env
1198
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1199
- AGENTMEMORY_AUTO_COMPRESS=true
1200
- ```
1201
-
1202
- 如果想开启图或整合特性,在同一文件中打开:
1203
-
1204
- ```env
1205
- GRAPH_EXTRACTION_ENABLED=true
1206
- CONSOLIDATION_ENABLED=true
1207
- ```
1208
-
1209
- ### 环境变量
1210
-
1211
- 创建 `~/.agentmemory/.env`:
1212
-
1213
- ```env
1214
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1215
- # ANTHROPIC_API_KEY=sk-ant-...
1216
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1217
- # GEMINI_API_KEY=...
1218
- # OPENROUTER_API_KEY=...
1219
- # MINIMAX_API_KEY=...
1220
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1221
- # # OpenAI LLM provider (here) AND the OpenAI
1222
- # # embedding provider (further below). Set
1223
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1224
- # # to embeddings only.
1225
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1226
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1227
- # # Auto-detected from `.openai.azure.com` hostname; uses
1228
- # # api-key header + api-version query param.
1229
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1230
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1231
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1232
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1233
- # # for back-compat with v0.9.17. New configs should
1234
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1235
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1236
- # # Honored only by OpenAI's reasoning models (o1, o3,
1237
- # # gpt-*-reasoning) and providers that mirror that
1238
- # # schema (Ollama Cloud thinking models). Standard
1239
- # # chat models reject this field with 400. Set to
1240
- # # "none" for thinking models that return reasoning
1241
- # # but no content.
1242
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1243
- # # for LLM (useful if you only want OpenAI for embeddings)
1244
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1245
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1246
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1247
-
1248
- # Embedding provider (auto-detected, or override)
1249
- # EMBEDDING_PROVIDER=local
1250
- # VOYAGE_API_KEY=...
1251
- # OPENAI_API_KEY=sk-...
1252
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1253
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1254
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1255
-
1256
- # Outbound LLM / embedding timeout
1257
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1258
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1259
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1260
- # embedding). For the OpenAI LLM path, the
1261
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1262
- # takes precedence when set, for back-compat
1263
- # with v0.9.17.
1264
- # Increase for slow networks or large batch calls;
1265
- # decrease to fail-fast on rate-limit holds.
1266
-
1267
- # Search tuning
1268
- # BM25_WEIGHT=0.4
1269
- # VECTOR_WEIGHT=0.6
1270
- # TOKEN_BUDGET=2000
1271
-
1272
- # Auth
1273
- # AGENTMEMORY_SECRET=your-secret
1274
-
1275
- # Ports (defaults: 3111 API, 3113 viewer)
1276
- # III_REST_PORT=3111
1277
-
1278
- # Features
1279
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1280
- # every PostToolUse hook calls your
1281
- # LLM provider to compress the
1282
- # observation — expect significant
1283
- # token spend on active sessions.
1284
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1285
- # memory slots — persona,
1286
- # user_preferences, tool_guidelines,
1287
- # project_context, guidance,
1288
- # pending_items, session_patterns,
1289
- # self_notes. Size-limited; agent
1290
- # edits via memory_slot_* tools.
1291
- # Pinned slots addressable for
1292
- # SessionStart injection.
1293
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1294
- # Stop hook fires mem::slot-reflect:
1295
- # scans recent observations, auto-
1296
- # appends TODOs to pending_items,
1297
- # counts patterns in
1298
- # session_patterns, records touched
1299
- # files in project_context. Fire-
1300
- # and-forget; does not block.
1301
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1302
- # - SessionStart may inject ~1-2K
1303
- # chars of project context into
1304
- # the first turn of each session
1305
- # (this is what actually reaches
1306
- # the model — Claude Code treats
1307
- # SessionStart stdout as context)
1308
- # - PreToolUse fires /agentmemory/enrich
1309
- # on every file-touching tool call
1310
- # (resource cleanup, not a token
1311
- # fix — PreToolUse stdout is debug
1312
- # log only per Claude Code docs)
1313
- # Observations are still captured via
1314
- # PostToolUse regardless of this flag.
1315
- # GRAPH_EXTRACTION_ENABLED=false
1316
- # CONSOLIDATION_ENABLED=true
1317
- # LESSON_DECAY_ENABLED=true
1318
- # OBSIDIAN_AUTO_EXPORT=false
1319
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1320
- # CLAUDE_MEMORY_BRIDGE=false
1321
- # SNAPSHOT_ENABLED=false
1322
-
1323
- # Team
1324
- # TEAM_ID=
1325
- # USER_ID=
1326
- # TEAM_MODE=private
1327
-
1328
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1329
- # AGENTMEMORY_TOOLS=core
1330
- ```
1331
-
1332
- ---
1333
-
1334
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1335
-
1336
- 端口 `3111` 上的 124 个端点。REST API 默认绑定 `127.0.0.1`。当 `AGENTMEMORY_SECRET` 已设置时,受保护端点需要 `Authorization: Bearer <secret>`,网状同步端点要求两端都设置 `AGENTMEMORY_SECRET`。
1337
-
1338
- <details>
1339
- <summary>关键端点</summary>
1340
-
1341
- | 方法 | 路径 | 描述 |
1342
- |--------|------|-------------|
1343
- | `GET` | `/agentmemory/health` | 健康检查(始终公开) |
1344
- | `POST` | `/agentmemory/session/start` | 开始会话 + 获取上下文 |
1345
- | `POST` | `/agentmemory/session/end` | 结束会话 |
1346
- | `POST` | `/agentmemory/observe` | 捕获观测 |
1347
- | `POST` | `/agentmemory/smart-search` | 混合搜索 |
1348
- | `POST` | `/agentmemory/context` | 生成上下文 |
1349
- | `POST` | `/agentmemory/remember` | 保存到长期记忆 |
1350
- | `POST` | `/agentmemory/forget` | 删除观测 |
1351
- | `POST` | `/agentmemory/enrich` | 文件上下文 + 记忆 + bugs |
1352
- | `GET` | `/agentmemory/profile` | 项目档案 |
1353
- | `GET` | `/agentmemory/export` | 导出所有数据 |
1354
- | `POST` | `/agentmemory/import` | 从 JSON 导入 |
1355
- | `POST` | `/agentmemory/graph/query` | 知识图谱查询 |
1356
- | `POST` | `/agentmemory/team/share` | 与团队共享 |
1357
- | `GET` | `/agentmemory/audit` | 审计轨迹 |
1358
-
1359
- 完整端点列表:[`src/triggers/api.ts`](../src/triggers/api.ts)
1360
-
1361
- </details>
1362
-
1363
- ---
1364
-
1365
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1366
-
1367
- ```bash
1368
- npm run dev # 热重载
1369
- npm run build # 生产构建
1370
- npm test # 950+ 测试
1371
- npm run test:integration # API 测试(需要服务运行中)
1372
- ```
1373
-
1374
- **先决条件:** Node.js >= 20、[iii-engine](https://iii.dev/docs) 或 Docker
1375
-
1376
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1377
-
1378
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
READMEs/README.zh-TW.md DELETED
@@ -1,1378 +0,0 @@
1
- <p align="center">
2
- <img src="../assets/banner.png" alt="agentmemory — 為 AI 編碼代理提供持久化記憶" width="720" />
3
- </p>
4
-
5
- <p align="center">
6
- <strong>
7
- 讓你的編碼代理記住一切。不再重複解釋。
8
- Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
- </strong><br/>
10
- 為 Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode 以及任何 MCP 用戶端提供持久化記憶。
11
- </p>
12
-
13
- <p align="center">
14
- <a href="../README.md">English</a> |
15
- <a href="README.zh-CN.md">简体中文</a> |
16
- 繁體中文 |
17
- <a href="README.ja-JP.md">日本語</a> |
18
- <a href="README.ko-KR.md">한국어</a> |
19
- <a href="README.es-ES.md">Español</a> |
20
- <a href="README.tr-TR.md">Türkçe</a> |
21
- <a href="README.ru-RU.md">Русский</a> |
22
- <a href="README.hi-IN.md">हिन्दी</a> |
23
- <a href="README.pt-BR.md">Português</a> |
24
- <a href="README.fr-FR.md">Français</a> |
25
- <a href="README.de-DE.md">Deutsch</a>
26
- </p>
27
-
28
- <p align="center">
29
- <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
- </p>
31
-
32
- <p align="center">
33
- <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
- <picture>
35
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
- </picture>
39
- </a>
40
- </p>
41
-
42
- <p align="center">
43
- <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
- </p>
45
-
46
- <p align="center">
47
- <em>這份 gist 以信心評分、生命週期管理、知識圖譜和混合搜尋擴展了 Karpathy 的 LLM Wiki 模式:agentmemory 就是其實作。</em>
48
- </p>
49
-
50
- <p align="center">
51
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
- <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
- <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
- <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
- <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
- </p>
57
-
58
- <p align="center">
59
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
- <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
- </p>
66
-
67
- <p align="center">
68
- <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
- </p>
70
-
71
- <p align="center">
72
- <a href="#install">安裝</a> &bull;
73
- <a href="#quick-start">快速開始</a> &bull;
74
- <a href="#benchmarks">基準測試</a> &bull;
75
- <a href="#vs-competitors">對比競品</a> &bull;
76
- <a href="#works-with-every-agent">代理</a> &bull;
77
- <a href="#how-it-works">運作原理</a> &bull;
78
- <a href="#mcp-server">MCP</a> &bull;
79
- <a href="#real-time-viewer">檢視器</a> &bull;
80
- <a href="#iii-console">iii 主控台</a> &bull;
81
- <a href="#powered-by-iii">由 iii 驅動</a> &bull;
82
- <a href="#configuration">設定</a> &bull;
83
- <a href="#api">API</a>
84
- </p>
85
-
86
- ---
87
-
88
- ## 安裝
89
-
90
- ```bash
91
- npm install -g @agentmemory/agentmemory # 一次安裝 — 全域可用 `agentmemory` 指令
92
- # 如果在 macOS/Linux 的系統 Node 上遇到 EACCES,請重試:
93
- # sudo npm install -g @agentmemory/agentmemory
94
- agentmemory # 在 :3111 啟動記憶伺服器
95
- agentmemory demo # 注入範例會話並驗證召回
96
- agentmemory connect claude-code # 連接你的代理(也支援: codex, cursor, gemini-cli, ...)
97
- ```
98
-
99
- 或透過 `npx`(無需安裝):
100
-
101
- ```bash
102
- npx @agentmemory/agentmemory
103
- ```
104
-
105
- 提醒 — npx 會依版本快取。若裸 `npx @agentmemory/agentmemory` 指令執行的是舊版,強制使用最新版 `npx -y @agentmemory/agentmemory@latest`,或一次性清除快取 `rm -rf ~/.npm/_npx`(macOS/Linux;Windows 上刪除 `%LOCALAPPDATA%\npm-cache\_npx`)。從 v0.9.16+ 起,首次 npx 執行會以行內方式提示你全域安裝,之後裸 `agentmemory` 指令在任何地方都能用。
106
-
107
- 完整選項見下方[快速開始](#quick-start)。各代理具體接入見[支援所有代理](#works-with-every-agent)。
108
-
109
- ---
110
-
111
- <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
-
113
- agentmemory 相容任何支援 hooks、MCP 或 REST API 的代理。所有代理共享同一個記憶伺服器。
114
-
115
- <table>
116
- <tr>
117
- <td align="center" width="12.5%">
118
- <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
- <strong>Claude Code</strong><br/>
120
- <sub>原生外掛 + 12 hooks + MCP</sub>
121
- </td>
122
- <td align="center" width="12.5%">
123
- <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
- <strong>Codex CLI</strong><br/>
125
- <sub>原生外掛 + 6 hooks + MCP</sub>
126
- </td>
127
- <td align="center" width="12.5%">
128
- <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
- <strong>OpenClaw</strong><br/>
130
- <sub>原生外掛 + MCP</sub>
131
- </td>
132
- <td align="center" width="12.5%">
133
- <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
- <strong>Hermes</strong><br/>
135
- <sub>原生外掛 + MCP</sub>
136
- </td>
137
- <td align="center" width="12.5%">
138
- <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
- <strong>pi</strong><br/>
140
- <sub>原生外掛 + MCP</sub>
141
- </td>
142
- <td align="center" width="12.5%">
143
- <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
- <strong>OpenHuman</strong><br/>
145
- <sub>原生 Memory trait 後端</sub>
146
- </td>
147
- <td align="center" width="12.5%">
148
- <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
- <strong>Cursor</strong><br/>
150
- <sub>MCP 伺服器</sub>
151
- </td>
152
- <td align="center" width="12.5%">
153
- <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
- <strong>Gemini CLI</strong><br/>
155
- <sub>MCP 伺服器</sub>
156
- </td>
157
- </tr>
158
- <tr>
159
- <td align="center" width="12.5%">
160
- <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
- <strong>OpenCode</strong><br/>
162
- <sub>22 hooks + MCP + 外掛</sub>
163
- </td>
164
- <td align="center" width="12.5%">
165
- <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
- <strong>Cline</strong><br/>
167
- <sub>MCP 伺服器</sub>
168
- </td>
169
- <td align="center" width="12.5%">
170
- <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
- <strong>Goose</strong><br/>
172
- <sub>MCP 伺服器</sub>
173
- </td>
174
- <td align="center" width="12.5%">
175
- <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
- <strong>Kilo Code</strong><br/>
177
- <sub>MCP 伺服器</sub>
178
- </td>
179
- <td align="center" width="12.5%">
180
- <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
- <strong>Aider</strong><br/>
182
- <sub>REST API</sub>
183
- </td>
184
- <td align="center" width="12.5%">
185
- <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
- <strong>Claude Desktop</strong><br/>
187
- <sub>MCP 伺服器</sub>
188
- </td>
189
- <td align="center" width="12.5%">
190
- <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
- <strong>Windsurf</strong><br/>
192
- <sub>MCP 伺服器</sub>
193
- </td>
194
- <td align="center" width="12.5%">
195
- <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
- <strong>Roo Code</strong><br/>
197
- <sub>MCP 伺服器</sub>
198
- </td>
199
- </tr>
200
- </table>
201
-
202
- <p align="center">
203
- <sub>相容<strong>任何</strong>使用 MCP 或 HTTP 的代理。一個伺服器,所有代理共享記憶。</sub>
204
- </p>
205
-
206
- ---
207
-
208
- 你每次會話都在重複解釋同樣的架構。你反覆發現同樣的 bug。你重複教同樣的偏好。內建的記憶(CLAUDE.md、.cursorrules)上限是 200 行而且會過期。agentmemory 解決了這個問題。它在背景靜默捕捉代理的行為,將其壓縮為可搜尋的記憶,並在下次會話開始時注入正確的上下文。一條指令。跨代理工作。
209
-
210
- **改變了什麼:** 會話 1 你設定了 JWT 驗證。會話 2 你要求限流。代理已經知道你的驗證使用 `src/middleware/auth.ts` 中的 jose middleware,測試覆蓋了 token 驗證,你選擇 jose 而非 jsonwebtoken 是為了 Edge 相容性。無需重新解釋。無需複製貼上。代理就是*知道*。
211
-
212
- ```bash
213
- npx @agentmemory/agentmemory
214
- ```
215
-
216
- > **v0.9.0 新功能** — 著陸頁 [agent-memory.dev](https://agent-memory.dev) 上線,檔案系統連接器(`@agentmemory/fs-watcher`),獨立 MCP 現在代理至執行中的伺服器,使 hooks 和檢視器保持一致,稽核策略在所有刪除路徑上得到統一,健康狀態在小型 Node 行程上不再誤報 `memory_critical`。完整變更見 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)。
217
-
218
- ---
219
-
220
- <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
-
222
- <table>
223
- <tr>
224
- <td width="50%">
225
-
226
- ### 檢索準確率
227
-
228
- **coding-agent-life-v1** (內部語料庫,沙盒可重現)
229
-
230
- | 適配器 | P@5 | R@5 | Top-5 命中率 | p50 延遲 |
231
- |---|---|---|---|---|
232
- | **agentmemory 混合** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
- | grep 基線 | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
-
235
- 100% Top-5 命中率。在相同輸入下,精確度比 grep 基線高 **2.2×**。完整依類型分解:[`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
-
237
- **LongMemEval-S** (ICLR 2025,500 個問題)
238
-
239
- | 系統 | R@5 | R@10 | MRR |
240
- |---|---|---|---|
241
- | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
- | 僅 BM25 回退 | 86.2% | 94.6% | 71.5% |
243
-
244
- </td>
245
- <td width="50%">
246
-
247
- ### Token 節省
248
-
249
- | 方法 | Token/年 | 成本/年 |
250
- |---|---|---|
251
- | 貼上完整上下文 | 19.5M+ | 不可能(超出窗口) |
252
- | LLM 摘要 | ~650K | ~$500 |
253
- | **agentmemory** | **~170K** | **~$10** |
254
- | agentmemory + 本地嵌入 | ~170K | **$0** |
255
-
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- > 嵌入模型:`all-MiniLM-L6-v2`(本地、免費、無需 API key)。完整報告:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。競品比較:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 比較 mem0、Letta、Khoj、claude-mem、Hippo。
261
-
262
- **在地重現:** [`eval/README.md`](../eval/README.md) — 適配器可插拔的 harness,支援 LongMemEval `_s`(公開 500 問)+ `coding-agent-life-v1`(內部 15 會話語料)。Grep / 向量 / agentmemory 適配器並排計分,NDJSON 輸出,公開計分卡發布於 [`docs/benchmarks/`](../docs/benchmarks/)。
263
-
264
- **搭配 [codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything) 和 [Graphify](https://github.com/safishamsi/graphify) 使用。** 程式碼圖索引、多代理建置流水線,以及跨文件 / PDF / 圖片 / 影片的更廣泛知識圖譜。agentmemory 記住工作內容;這三個專案點亮上下文層其餘部分。組合配方與問題路由表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
-
266
- ---
267
-
268
- <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
-
270
- <table>
271
- <tr>
272
- <th width="20%"></th>
273
- <th width="20%">agentmemory</th>
274
- <th width="20%">mem0 (53K ⭐)</th>
275
- <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
- <th width="20%">內建 (CLAUDE.md)</th>
277
- </tr>
278
- <tr>
279
- <td><strong>類型</strong></td>
280
- <td>記憶引擎 + MCP 伺服器</td>
281
- <td>記憶層 API</td>
282
- <td>完整代理執行階段</td>
283
- <td>靜態檔案</td>
284
- </tr>
285
- <tr>
286
- <td><strong>檢索 R@5</strong></td>
287
- <td><strong>95.2%</strong></td>
288
- <td>68.5% (LoCoMo)</td>
289
- <td>83.2% (LoCoMo)</td>
290
- <td>N/A (grep)</td>
291
- </tr>
292
- <tr>
293
- <td><strong>自動捕捉</strong></td>
294
- <td>12 hooks(零人工)</td>
295
- <td>手動呼叫 <code>add()</code></td>
296
- <td>代理自編輯</td>
297
- <td>手動編輯</td>
298
- </tr>
299
- <tr>
300
- <td><strong>搜尋</strong></td>
301
- <td>BM25 + 向量 + 圖(RRF 融合)</td>
302
- <td>向量 + 圖</td>
303
- <td>向量(歸檔)</td>
304
- <td>把所有內容載入上下文</td>
305
- </tr>
306
- <tr>
307
- <td><strong>多代理</strong></td>
308
- <td>MCP + REST + 租約 + 訊號</td>
309
- <td>API(無協調)</td>
310
- <td>僅在 Letta 執行階段內部</td>
311
- <td>每個代理一個檔案</td>
312
- </tr>
313
- <tr>
314
- <td><strong>框架鎖定</strong></td>
315
- <td>無(任何 MCP 用戶端)</td>
316
- <td>無</td>
317
- <td>高(必須使用 Letta)</td>
318
- <td>每個代理格式</td>
319
- </tr>
320
- <tr>
321
- <td><strong>外部相依</strong></td>
322
- <td>無(SQLite + iii-engine)</td>
323
- <td>Qdrant / pgvector</td>
324
- <td>Postgres + 向量資料庫</td>
325
- <td>無</td>
326
- </tr>
327
- <tr>
328
- <td><strong>記憶生命週期</strong></td>
329
- <td>4 層整合 + 衰減 + 自動遺忘</td>
330
- <td>被動擷取</td>
331
- <td>代理管理</td>
332
- <td>手動清理</td>
333
- </tr>
334
- <tr>
335
- <td><strong>Token 效率</strong></td>
336
- <td>~1,900 tokens/會話 ($10/年)</td>
337
- <td>依整合方式不同</td>
338
- <td>核心記憶位於上下文</td>
339
- <td>240 條觀測達 22K+ tokens</td>
340
- </tr>
341
- <tr>
342
- <td><strong>即時檢視器</strong></td>
343
- <td>是(連接埠 3113)</td>
344
- <td>雲端儀表板</td>
345
- <td>雲端儀表板</td>
346
- <td>無</td>
347
- </tr>
348
- <tr>
349
- <td><strong>自架</strong></td>
350
- <td>是(預設)</td>
351
- <td>選用</td>
352
- <td>選用</td>
353
- <td>是</td>
354
- </tr>
355
- </table>
356
-
357
- ---
358
-
359
- <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
-
361
- 相容性:此版本面向穩定的 `iii-sdk` `^0.11.0` 和 iii-engine v0.11.x。
362
-
363
- ### 30 秒體驗
364
-
365
- ```bash
366
- # 終端 1:啟動伺服器
367
- npx @agentmemory/agentmemory
368
-
369
- # 終端 2:注入範例資料並查看召回
370
- npx @agentmemory/agentmemory demo
371
- ```
372
-
373
- `demo` 會注入 3 個真實會話(JWT 驗證、N+1 查詢修正、限流)並對它們執行語義搜尋。你將看到搜尋「資料庫效能最佳化」時找到「N+1 查詢修正」 — 關鍵字比對做不到這一點。
374
-
375
- 打開 `http://localhost:3113` 即時觀察記憶的建構過程。
376
-
377
- ### 推薦:全域安裝
378
-
379
- `npx` 依版本快取。若你上週執行過 `npx @agentmemory/agentmemory@0.9.14`,裸 `npx @agentmemory/agentmemory` 指令可能會從 `~/.npm/_npx/` 提供過期的 0.9.14 而非最新版。安裝一次後,裸 `agentmemory` 指令處處可用:
380
-
381
- ```bash
382
- npm install -g @agentmemory/agentmemory
383
- # 如果在 macOS/Linux 的系統 Node 上遇到 EACCES,請重試:
384
- # sudo npm install -g @agentmemory/agentmemory
385
- agentmemory # 啟動伺服器(等同 npx 形式)
386
- agentmemory stop # 停止
387
- agentmemory remove # 解除安裝所有建立的內容
388
- agentmemory connect claude-code # 連接一個代理
389
- agentmemory doctor # 互動式診斷 + 修復提示
390
- ```
391
-
392
- 從 v0.9.16 開始,首次 npx 執行會以行內方式提示你全域安裝 — 回答一次 `Y` 即可。若你跳過,可使用以下任一方式取得最新版本:
393
-
394
- ```bash
395
- npx -y @agentmemory/agentmemory@latest # 強制從 npm 拉取最新(跨平台)
396
- rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # 僅 macOS/Linux (POSIX shell)
397
- ```
398
-
399
- 在 Windows / PowerShell 上,等價的快取清除指令是 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — 上面的 `npx -y ...@latest` 形式是跨平台選項。
400
-
401
- ### 會話重播
402
-
403
- agentmemory 紀錄的每個會話都可重播。打開檢視器,選擇 **Replay** 標籤,在時間軸上拖動:提示、工具呼叫、工具結果和回應都以離散事件呈現,支援播放/暫停、速度控制(0.5×–4×)和鍵盤快捷鍵(空白鍵切換,方向鍵單步)。
404
-
405
- 已有舊的 Claude Code JSONL 紀錄想匯入?
406
-
407
- ```bash
408
- # 匯入預設 ~/.claude/projects 下的全部內容
409
- npx @agentmemory/agentmemory import-jsonl
410
-
411
- # 或匯入單一檔案
412
- npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
- ```
414
-
415
- 匯入的會話與原生會話一同出現在 Replay 選擇器中。底層每個條目都透過 `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` 這些 iii 函式路由 — 沒有側通道伺服器。
416
-
417
- ### 升級 / 維護
418
-
419
- 當你確實想更新本地執行階段時,使用維護指令:
420
-
421
- ```bash
422
- npx @agentmemory/agentmemory upgrade
423
- ```
424
-
425
- 警告:此指令會變更目前工作區/執行階段。它可能更新 JavaScript 相依、可能執行 `cargo install iii-engine --force`、也可能拉取 Docker 鏡像。
426
-
427
- 實作細節見 `src/cli.ts`(參考 `src/cli.ts:544-595` 附近的 `runUpgrade`)。
428
-
429
- ### Claude Code(一段話,直接貼上)
430
-
431
- ```text
432
- Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
- ```
434
-
435
- #### Claude Code 不安裝外掛(MCP-standalone 路徑)
436
-
437
- 若你直接透過 `~/.claude.json` 連接 agentmemory 的 MCP 伺服器而非使用 `/plugin install`,Claude Code 永遠不會解析 `${CLAUDE_PLUGIN_ROOT}`,你必須把 hook 腳本指向 `~/.claude/settings.json` 中的絕對路徑。這些路徑通常會嵌入 agentmemory 版本號(例如 `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`),因此下次升級會靜默破壞所有 hooks([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
-
439
- 變通方法:
440
-
441
- ```bash
442
- agentmemory connect claude-code --with-hooks
443
- ```
444
-
445
- 這會把同樣的 hook 指令合併到 `~/.claude/settings.json`,絕對路徑解析到目前安裝的 `@agentmemory/agentmemory` 套件的 `plugin/` 目錄。升級 agentmemory 後重新執行該指令以重新整理路徑。同一檔案中的使用者條目會被保留;只取代之前的 agentmemory 條目。仍然推薦使用 `/plugin install` 路徑。
446
-
447
- 對於遠端或受保護的部署,啟動 Claude Code 時設定 `AGENTMEMORY_URL` 和 `AGENTMEMORY_SECRET`。外掛會把這兩個值傳遞給其捆綁的 MCP 伺服器;當 `AGENTMEMORY_URL` 為空時,MCP shim 預設使用 `http://localhost:3111`。
448
-
449
- ### Codex CLI(Codex 外掛平台)
450
-
451
- ```bash
452
- # 1. 在另一個終端啟動記憶伺服器
453
- npx @agentmemory/agentmemory
454
-
455
- # 2. 註冊 agentmemory 市集並安裝外掛
456
- codex plugin marketplace add rohitg00/agentmemory
457
- codex plugin add agentmemory@agentmemory
458
- ```
459
-
460
- Codex 外掛與 Claude Code 外掛同源,來自相同的 `plugin/` 目錄。它註冊:
461
-
462
- - `@agentmemory/mcp` 作為 MCP 伺服器(當 `AGENTMEMORY_URL` 指向執行中的 agentmemory 伺服器時,代理全部 51 個工具;若伺服器不可達,本地回退至 7 個工具)
463
- - 6 個生命週期 hooks:`SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
- - 4 個 skills:`/recall`、`/remember`、`/session-history`、`/forget`
465
-
466
- Codex 的 hook 引擎會把 `CLAUDE_PLUGIN_ROOT` 注入 hook 子行程(參見 [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)),因此同樣的 hook 腳本在兩個宿主中都能運作,無需重複實作。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 事件僅 Claude Code 支援,Codex 未註冊這些。
467
-
468
- #### Codex Desktop:外掛 hooks 目前沒有回應(有變通方法)
469
-
470
- `CodexHooks` 和 `PluginHooks` 在 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) 中都已穩定且預設啟用,但 Codex Desktop 目前不會派發外掛本地的 `hooks.json`([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP 工具仍能運作;只是生命週期觀測缺失。
471
-
472
- 在上游修正落地前,把同樣的 hook 指令鏡像到全域 `~/.codex/hooks.json`:
473
-
474
- ```bash
475
- agentmemory connect codex --with-hooks
476
- ```
477
-
478
- 這會在 `~/.codex/hooks.json` 新增一個冪等區塊,引用捆綁腳本的絕對路徑(在使用者範圍下無需 `${CLAUDE_PLUGIN_ROOT}` 展開)。升級 agentmemory 後重新執行同一指令以重新整理路徑。同一檔案中的使用者條目會被保留;只取代之前的 agentmemory 條目。
479
-
480
- <details>
481
- <summary><b>OpenClaw(貼上此提示)</b></summary>
482
-
483
- ```text
484
- Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
-
486
- {
487
- "mcpServers": {
488
- "agentmemory": {
489
- "command": "npx",
490
- "args": ["-y", "@agentmemory/mcp"],
491
- "env": {
492
- "AGENTMEMORY_URL": "http://localhost:3111"
493
- }
494
- }
495
- }
496
- }
497
-
498
- Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
- ```
500
-
501
- 完整指南:[`integrations/openclaw/`](../integrations/openclaw/)
502
-
503
- </details>
504
-
505
- <details>
506
- <summary><b>Hermes Agent(貼上此提示)</b></summary>
507
-
508
- ```text
509
- Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
-
511
- mcp_servers:
512
- agentmemory:
513
- command: npx
514
- args: ["-y", "@agentmemory/mcp"]
515
-
516
- memory:
517
- provider: agentmemory
518
-
519
- Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
- ```
521
-
522
- 完整指南:[`integrations/hermes/`](../integrations/hermes/)
523
-
524
- </details>
525
-
526
- ### 其他代理
527
-
528
- 啟動記憶伺服器:`npx @agentmemory/agentmemory`
529
-
530
- 在使用 `mcpServers` 結構的每個宿主(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)中,agentmemory 條目是**相同的 MCP 伺服器區塊**:
531
-
532
- ```json
533
- "agentmemory": {
534
- "command": "npx",
535
- "args": ["-y", "@agentmemory/mcp"],
536
- "env": {
537
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
- }
540
- }
541
- ```
542
-
543
- **把此條目合併到宿主設定檔現有的 `mcpServers` 物件中** — 不要取代整個檔案。若檔案已有其他伺服器,把 `agentmemory` 作為另一個 key 加在它們旁邊。若完全缺少 `mcpServers`,把整個區塊貼到 `{ "mcpServers": { ... } }` 裡。`${VAR}` 佔位符會在 MCP 伺服器啟動時從 shell 繼承 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` — 未設定的變數傳空字串,shim 回退到 `http://localhost:3111`。一個接好的條目同時涵蓋本地和遠端(k8s / 反向代理)部署。
544
-
545
- | 代理 | 設定檔 | 備註 |
546
- |---|---|---|
547
- | **Cursor** | `~/.cursor/mcp.json` | 合併到 `mcpServers`。網站上也提供一鍵深層連結。 |
548
- | **Claude Desktop** | `claude_desktop_config.json`(Application Support) | 合併到 `mcpServers`。編輯後重新啟動 Claude Desktop。 |
549
- | **Cline / Roo Code / Kilo Code** | Cline MCP 設定(設定 UI → MCP Servers → Edit) | 同樣的 `mcpServers` 區塊。 |
550
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同樣的 `mcpServers` 區塊。 |
551
- | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自動合併)。 |
552
- | **OpenClaw** | OpenClaw MCP 設定 | 同樣的 `mcpServers` 區塊,或使用更深的[記憶外掛](../integrations/openclaw/)。 |
553
- | **Codex CLI(僅 MCP)** | `.codex/config.toml` | TOML 形式:`codex mcp add agentmemory -- npx -y @agentmemory/mcp`,或手動新增 `[mcp_servers.agentmemory]`。 |
554
- | **Codex CLI(完整外掛)** | Codex 外掛市集 | `codex plugin marketplace add rohitg00/agentmemory` 然後 `codex plugin add agentmemory@agentmemory`。註冊 MCP + 6 個生命週期 hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 個 skills。在 Codex Desktop 上,直到 [openai/codex#16430](https://github.com/openai/codex/issues/16430) 落地之前,還要執行 `agentmemory connect codex --with-hooks` — 那裡的外掛 hooks 目前沒有回應。 |
555
- | **OpenCode(僅 MCP)** | `opencode.json` | 不同結構 — 頂層 `mcp` key,command 是陣列:`{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
- | **OpenCode(完整外掛)** | `plugin/opencode/` | 22 個自動捕捉 hooks,涵蓋會話生命週期、訊息、工具、錯誤。兩個斜線指令(`/recall`、`/remember`)。把 `plugin/opencode/` 複製到你的 OpenCode 工作區並把外掛條目新增到 `opencode.json`。完整 hook 表與差異分析見 [`plugin/opencode/README.md`](../plugin/opencode/README.md)。 |
557
- | **pi** | `~/.pi/agent/extensions/agentmemory` | 複製 [`integrations/pi`](../integrations/pi/) 並重啟 pi。 |
558
- | **Hermes Agent** | `~/.hermes/config.yaml` | 使用更深的[記憶提供者外掛](../integrations/hermes/),設定 `memory.provider: agentmemory`。 |
559
- | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` 會寫入標準的 `mcpServers` 區塊。Hook 負載與 Claude Code 欄位相容,因此既有的 12 hook 腳本無需修改即可運作 — 透過同一 `settings.json` 的 `hooks` 區段連接它們。 |
560
- | **Antigravity**(取代 Gemini CLI) | `mcp_config.json`(在 Antigravity 的 User 目錄中) | `agentmemory connect antigravity` 會寫入標準的 `mcpServers` 區塊。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。在 2026-06-18 Gemini CLI 停止服務後使用。 |
561
- | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` 寫入使用者層級設定。工作區覆寫放在你的程式碼旁的 `.kiro/settings/mcp.json` 中。 |
562
- | **Goose** | Goose MCP 設定 UI | 同樣的 `mcpServers` 區塊。 |
563
- | **Aider** | n/a | 直接呼叫 REST API:`curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
- | **任何代理(32+)** | n/a | `npx skillkit install agentmemory` 自動偵測宿主並合併。 |
565
-
566
- **沙箱化的 MCP 用戶端**(Flatpak / Snap / 受限容器)無法存取宿主的 `localhost`:還要在 `env` 區塊���設定 `"AGENTMEMORY_FORCE_PROXY": "1"`,並把 `AGENTMEMORY_URL` 指向沙箱確實能到達的路由(例如你的 LAN IP)。診斷步驟見 [#234](https://github.com/rohitg00/agentmemory/issues/234)。
567
-
568
- ### 程式化存取(Python / Rust / Node)
569
-
570
- agentmemory 把核心操作註冊為 iii 函式(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)。任何擁有 iii SDK 的語言都可以透過 `ws://localhost:49134` 直接呼叫它們 — 無需為每種語言準備獨立的 REST 用戶端。
571
-
572
- ```bash
573
- pip install iii-sdk # Python
574
- cargo add iii-sdk # Rust
575
- npm install iii-sdk # Node
576
- ```
577
-
578
- ```python
579
- from iii import register_worker
580
-
581
- iii = register_worker("ws://localhost:49134")
582
- iii.connect()
583
-
584
- iii.trigger({
585
- "function_id": "mem::smart-search",
586
- "payload": {"project": "demo", "query": "how do tokens refresh"},
587
- })
588
- ```
589
-
590
- 完整範例:[`examples/python/`](../examples/python/)(快速開始 + 觀測/召回流程)。`:3111` 上的 REST 對沒有 iii 執行階段的宿主仍可用。
591
-
592
- ### 從原始碼建置
593
-
594
- ```bash
595
- git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
- npm install && npm run build && npm start
597
- ```
598
-
599
- 若 `iii` 已安裝,這會以本地 `iii-engine` 啟動 agentmemory;若 Docker 可用,則回退到 Docker Compose。REST、串流和檢視器預設繫結到 `127.0.0.1`。
600
-
601
- 手動安裝 `iii-engine`。**agentmemory 目前把 `iii-engine` 釘在 `v0.11.2`** — `v0.11.6` 引入了新的「透過 `iii worker add` 沙盒化一切」模型,agentmemory 尚未為此重構。重構落地後即解除釘版。若你已手動遷移到沙盒模型,可用 `AGENTMEMORY_III_VERSION=<version>` 覆寫。
602
-
603
- - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
- - **macOS x64:** 把 `aarch64-apple-darwin` 換成 `x86_64-apple-darwin`
605
- - **Linux x64:** 換成 `x86_64-unknown-linux-gnu`
606
- - **Linux arm64:** 換成 `aarch64-unknown-linux-gnu`
607
- - **Windows:** 從 [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) 下載 `iii-x86_64-pc-windows-msvc.zip`,擷取 `iii.exe`,加入 PATH
608
-
609
- 或使用 Docker(捆綁的 `docker-compose.yml` 會拉取 `iiidev/iii:0.11.2`)。完整文件:[iii.dev/docs](https://iii.dev/docs)。
610
-
611
- ### Windows
612
-
613
- agentmemory 可在 Windows 10/11 執行,但僅 Node.js 套件不夠 — 你還需要 `iii-engine` 執行階段(一個獨立的原生二進位)作為背景行程。官方上游安裝器是 `sh` 指令稿,目前沒有 PowerShell 安裝器或 scoop/winget 套件,因此 Windows 使用者有兩條路徑:
614
-
615
- **選項 A — 預建 Windows 二進位(推薦):**
616
-
617
- ```powershell
618
- # 1. 在瀏覽器打開 https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2
619
- # (我們釘在 v0.11.2,直到 agentmemory 為 v0.11.6+ 引擎需求的
620
- # 新沙盒模型完成重構)
621
- # 2. 下載 iii-x86_64-pc-windows-msvc.zip
622
- # (若是 ARM 機器則下載 iii-aarch64-pc-windows-msvc.zip)
623
- # 3. 把 iii.exe 解壓到 PATH 上的某處,或放在:
624
- # %USERPROFILE%\.local\bin\iii.exe
625
- # (agentmemory 會自動檢查該位置)
626
- # 4. 驗證:
627
- iii --version
628
- # 應輸出:0.11.2
629
-
630
- # 5. 然後照常執行 agentmemory:
631
- npx -y @agentmemory/agentmemory
632
- ```
633
-
634
- **選項 B — Docker Desktop:**
635
-
636
- ```powershell
637
- # 1. 安裝 Docker Desktop for Windows
638
- # 2. 啟動 Docker Desktop 並確保引擎執行中
639
- # 3. 執行 agentmemory — 它會自動啟動捆綁的 compose 檔:
640
- npx -y @agentmemory/agentmemory
641
- ```
642
-
643
- **選項 C — 僅獨立 MCP(無引擎):** 若你只需要 MCP 工具供代理使用,不需要 REST API、檢視器或定時工作,則完全跳過引擎:
644
-
645
- ```powershell
646
- npx -y @agentmemory/agentmemory mcp
647
- # 或透過 shim 套件:
648
- npx -y @agentmemory/mcp
649
- ```
650
-
651
- **Windows 診斷:** 若 `npx @agentmemory/agentmemory` 失敗,加 `--verbose` 重新執行以看到實際的引擎 stderr。常見失敗模式:
652
-
653
- | 症狀 | 修正 |
654
- |---|---|
655
- | `iii-engine process started` 然後 `did not become ready within 15s` | 引擎啟動當機 — 用 `--verbose` 重新執行,檢查 stderr |
656
- | `Could not start iii-engine` | `iii.exe` 和 Docker 都未安裝。見上面選項 A 或 B |
657
- | 連接埠衝突 | `netstat -ano \| findstr :3111` 查看佔用,然後 kill 或用 `--port <N>` |
658
- | Docker 已安裝但仍跳過回退 | 確保 Docker Desktop 確實在執行(系統匣圖示) |
659
-
660
- > 注意:沒有 `cargo install iii-engine` — `iii` 未發布到 crates.io。唯一受支援的安裝方式是上述預建二進位、上游 `sh` 安裝指令稿(僅 macOS/Linux)和 Docker 鏡像。
661
-
662
- ---
663
-
664
- <h2 id="deploy">部署</h2>
665
-
666
- 託管主機的一鍵範本。每個範本都附帶自含的
667
- Dockerfile,從 npm 拉取 `@agentmemory/agentmemory` 並從官方
668
- `iiidev/iii` Docker Hub 鏡像複製 iii 引擎二進位 — 無需
669
- 預建 agentmemory 鏡像。持久儲存掛載在
670
- `/data`;首次啟動 entrypoint 用面向部署調校的設定
671
- 覆寫 npm 捆綁的 iii ���定(原設定繫結 `127.0.0.1`),
672
- 讓其繫結 `0.0.0.0` 並使用絕對 `/data` 路徑,產生
673
- HMAC secret,然後透過 `gosu` 從 `root` 降權到 `node`
674
- 再 exec agentmemory CLI。
675
-
676
- <p>
677
- <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
- <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
- </p>
680
-
681
- Render 的一鍵部署按鈕要求倉庫根有 `render.yaml`,我們刻意保持根目錄整潔。使用 [`deploy/render/`](../deploy/render/README.md) 中文件化的 Render Blueprint 流程,手動指向倉庫內的藍圖。
682
-
683
- 完整設定細節(HMAC 擷取、檢視器 SSH 隧道、輪替、備份、
684
- 成本下限)見 [`deploy/`](../deploy/README.md):
685
-
686
- - [`deploy/fly`](../deploy/fly/README.md) — 單機搭配
687
- `auto_stop_machines = "stop"`;閒置時最便宜。
688
- - [`deploy/railway`](../deploy/railway/README.md) — Hobby 方案固定費,
689
- 磁碟區在儀表板中設定。
690
- - [`deploy/render`](../deploy/render/README.md) — Blueprint 流程,
691
- 付費方案自動磁碟快照。
692
- - [`deploy/coolify`](../deploy/coolify/README.md) — 透過 [Coolify](https://coolify.io/self-hosted)
693
- 在你自己的 VPS 上自架;同樣的 Docker
694
- Compose 堆疊,主機與資料都歸你所有。
695
-
696
- 僅發布連接埠 `3111`。`3113` 上的檢視器在容器內仍繫結到
697
- loopback — 每個範本的 README 都文件化了到達它的
698
- SSH 隧道模式。
699
-
700
- ---
701
-
702
- <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
703
-
704
- 每個編碼代理在會話結束時都會忘記一切。你每次會話的前 5 分鐘都浪費在重新解釋技術堆疊上。agentmemory 在背景執行,徹底消除這一點。
705
-
706
- ```text
707
- Session 1: "Add auth to the API"
708
- Agent writes code, runs tests, fixes bugs
709
- agentmemory silently captures every tool use
710
- Session ends -> observations compressed into structured memory
711
-
712
- Session 2: "Now add rate limiting"
713
- Agent already knows:
714
- - Auth uses JWT middleware in src/middleware/auth.ts
715
- - Tests in test/auth.test.ts cover token validation
716
- - You chose jose over jsonwebtoken for Edge compatibility
717
- Zero re-explaining. Starts working immediately.
718
- ```
719
-
720
- ### 對比內建代理記憶
721
-
722
- 每個 AI 編碼代理都自帶內建記憶 — Claude Code 有 `MEMORY.md`、Cursor 有 notepad、Cline 有 memory bank。這些像便利貼。agentmemory 是便利貼背後的可搜尋資料庫。
723
-
724
- | | 內建 (CLAUDE.md) | agentmemory |
725
- |---|---|---|
726
- | 規模 | 200 行上限 | 無限 |
727
- | 搜尋 | 把所有內容載入上下文 | BM25 + 向量 + 圖(僅 top-K) |
728
- | Token 成本 | 240 條觀測達 22K+ | ~1,900 tokens(少 92%) |
729
- | 跨代理 | 每個代理一個檔案 | MCP + REST(任何代理) |
730
- | 協調 | 無 | 租約、訊號、動作、例程 |
731
- | 可觀測性 | 手動讀檔 | 連接埠 3113 即時檢視器 |
732
-
733
- ---
734
-
735
- <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
736
-
737
- ### 記憶流水線
738
-
739
- ```text
740
- PostToolUse hook fires
741
- -> SHA-256 dedup (5min window)
742
- -> Privacy filter (strip secrets, API keys)
743
- -> Store raw observation
744
- -> LLM compress -> structured facts + concepts + narrative
745
- -> Vector embedding (6 providers + local)
746
- -> Index in BM25 + vector
747
-
748
- Stop / SessionEnd hook fires
749
- -> Summarize session
750
- -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
751
- -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
752
-
753
- SessionStart hook fires
754
- -> Load project profile (top concepts, files, patterns)
755
- -> Hybrid search (BM25 + vector + graph)
756
- -> Token budget (default: 2000 tokens)
757
- -> Inject into conversation
758
- ```
759
-
760
- ### 4 層記憶整合
761
-
762
- 靈感來自人腦處理記憶的方式 — 與睡眠時的記憶整合並無不同。
763
-
764
- | 層級 | 內容 | 類比 |
765
- |------|------|---------|
766
- | **Working(工作記憶)** | 來自工具使用的原始觀測 | 短期記憶 |
767
- | **Episodic(情節記憶)** | 壓縮後的會話摘要 | 「發生了什麼」 |
768
- | **Semantic(語意記憶)** | 擷取的事實與模式 | 「我知道什麼」 |
769
- | **Procedural(程序記憶)** | 工作流與決策模式 | 「怎麼做」 |
770
-
771
- 記憶隨時間衰減(Ebbinghaus 曲線)。頻繁存取的記憶會強化。陳舊記憶會自動清除。矛盾會被偵測並解決。
772
-
773
- ### 捕捉了什麼
774
-
775
- | Hook | 捕捉內容 |
776
- |------|----------|
777
- | `SessionStart` | 專案路徑、會話 ID |
778
- | `UserPromptSubmit` | 使用者提示(隱私過濾) |
779
- | `PreToolUse` | 檔案��取模式 + 富化上下文 |
780
- | `PostToolUse` | 工具名、輸入、輸出 |
781
- | `PostToolUseFailure` | 錯誤上下文 |
782
- | `PreCompact` | 在壓縮前重新注入記憶 |
783
- | `SubagentStart/Stop` | 子代理生命週期 |
784
- | `Stop` | 會話結束摘要 |
785
- | `SessionEnd` | 會話完成標記 |
786
-
787
- ### 關鍵能力
788
-
789
- | 能力 | 描述 |
790
- |---|---|
791
- | **自動捕捉** | 每次工具使用都透過 hooks 記錄 — 零人工 |
792
- | **語意搜尋** | BM25 + 向量 + 知識圖譜,RRF 融合 |
793
- | **記憶演化** | 版本控制、覆寫關係、關係圖 |
794
- | **自動遺忘** | TTL 過期、矛盾偵測、重要性驅逐 |
795
- | **隱私優先** | API key、secret、`<private>` 標籤儲存前被剝除 |
796
- | **自癒** | 熔斷器、提供者回退鏈、健康監控 |
797
- | **Claude 橋接** | 與 MEMORY.md 雙向同步 |
798
- | **知識圖譜** | 實體擷取 + BFS 走訪 |
799
- | **團隊記憶** | 團隊成員之間的命名空間共享 + 私有 |
800
- | **引用溯源** | 任意記憶追溯到來源觀測 |
801
- | **Git 快照** | 記憶狀態的版本、回滾、diff |
802
-
803
- ---
804
-
805
- <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
806
-
807
- 三路檢索結合三種訊號:
808
-
809
- | 流 | 功用 | 何時啟用 |
810
- |---|---|---|
811
- | **BM25** | 詞幹化關鍵字比對 + 同義詞擴展 | 始終啟用 |
812
- | **Vector(向量)** | 稠密嵌入上的餘弦相似度 | 已設定嵌入提供者 |
813
- | **Graph(圖)** | 透過實體比對進行知識圖譜走訪 | 查詢中偵測到實體 |
814
-
815
- 透過 Reciprocal Rank Fusion (RRF, k=60) 融合,並按會話多樣化(每個會話最多 3 個結果)。
816
-
817
- BM25 開箱即用支援希臘文、西里爾文、希伯來文、阿拉伯文和帶音標拉丁文的分詞。對於中文/日文/韓文記憶,安裝可選分詞器(`npm install @node-rs/jieba tiny-segmenter`)以把 CJK 串切分為詞級 token;若未安裝,agentmemory 會軟回退到整串分詞並在 stderr 印出一次性提示。
818
-
819
- ### 嵌入提供者
820
-
821
- agentmemory 自動偵測你的提供者。為獲得最佳效果,安裝本地嵌入(免費):
822
-
823
- ```bash
824
- npm install @xenova/transformers
825
- ```
826
-
827
- | 提供者 | 模型 | 成本 | 備註 |
828
- |---|---|---|---|
829
- | **本地(推薦)** | `all-MiniLM-L6-v2` | 免費 | 離線,比僅 BM25 召回率高 +8pp |
830
- | Gemini | `gemini-embedding-001` | 免費層 | 100+ 語言,768/1536/3072 維 (MRL),2048-token 輸入。取代 `text-embedding-004`([已棄用,2026 年 1 月 14 日下線](https://ai.google.dev/gemini-api/docs/deprecations)) |
831
- | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高品質 |
832
- | Voyage AI | `voyage-code-3` | 付費 | 針對程式碼最佳化 |
833
- | Cohere | `embed-english-v3.0` | 免費試用 | 通用 |
834
- | OpenRouter | 任意模型 | 視情況 | 多模型代理 |
835
-
836
- ---
837
-
838
- <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
839
-
840
- 53 個工具、6 個資源、3 個提示、4 個 skills — 任何代理可用的最全面 MCP 記憶工具組。
841
-
842
- > **MCP shim 對比完整伺服器:** 已發布的 `@agentmemory/mcp` 套件是一個薄 shim。**只有當它能透過 `AGENTMEMORY_URL` 連通執行中的 agentmemory 伺服器**(代理模式)時,才暴露完整的 51 工具表面。在沒有可達伺服器的情況下,shim 回退到 7 工具的本地集合(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)。`AGENTMEMORY_TOOLS=core|all` 環境變數是*伺服器端*旗標 — 在 shim 的 `env` 區塊中設定無效。若在 Cursor / OpenCode / Gemini CLI 中只看到 7 個工具,啟動 `npx @agentmemory/agentmemory`(或 Docker 堆疊)並設定 `AGENTMEMORY_URL=http://localhost:3111`。
843
-
844
- ### 51 個工具
845
-
846
- <details>
847
- <summary>核心工具(始終可用)</summary>
848
-
849
- | 工具 | 描述 |
850
- |------|-------------|
851
- | `memory_recall` | 搜尋過去的觀測 |
852
- | `memory_compress_file` | 在保留結構的同時壓縮 markdown 檔 |
853
- | `memory_save` | 儲存洞察、決策或模式 |
854
- | `memory_patterns` | 偵測反覆出現的模式 |
855
- | `memory_smart_search` | 混合語意 + 關鍵字搜尋 |
856
- | `memory_file_history` | 關於特定檔案的過去觀測 |
857
- | `memory_sessions` | 列出最近的會話 |
858
- | `memory_timeline` | 按時間排列的觀測 |
859
- | `memory_profile` | 專案檔案(概念、檔案、模式) |
860
- | `memory_export` | 匯出所有記憶資料 |
861
- | `memory_relations` | 查詢關係圖 |
862
-
863
- </details>
864
-
865
- <details>
866
- <summary>擴展工具(共 51 — 設定 AGENTMEMORY_TOOLS=all)</summary>
867
-
868
- | 工具 | 描述 |
869
- |------|-------------|
870
- | `memory_patterns` | 偵測反覆出現的模式 |
871
- | `memory_timeline` | 按時間排列的觀測 |
872
- | `memory_relations` | 查詢關係圖 |
873
- | `memory_graph_query` | 知識圖譜走訪 |
874
- | `memory_consolidate` | 執行 4 層整合 |
875
- | `memory_claude_bridge_sync` | 與 MEMORY.md 同步 |
876
- | `memory_team_share` | 與團隊成員共享 |
877
- | `memory_team_feed` | 最近共享條目 |
878
- | `memory_audit` | 操作稽核軌跡 |
879
- | `memory_governance_delete` | 帶稽核軌跡的刪除 |
880
- | `memory_snapshot_create` | Git 版本快照 |
881
- | `memory_action_create` | 建立帶相依性的工作項 |
882
- | `memory_action_update` | 更新動作狀態 |
883
- | `memory_frontier` | 依優先序排序的未阻塞動作 |
884
- | `memory_next` | 單一最重要的下一個動作 |
885
- | `memory_lease` | 獨佔動作租約(多代理) |
886
- | `memory_routine_run` | 實例化工作流例程 |
887
- | `memory_signal_send` | 代理之間的訊息 |
888
- | `memory_signal_read` | 帶回執讀取訊息 |
889
- | `memory_checkpoint` | 外部條件閘門 |
890
- | `memory_mesh_sync` | 實例之間 P2P 同步 |
891
- | `memory_sentinel_create` | 事件驅動監視器 |
892
- | `memory_sentinel_trigger` | 外部觸發哨兵 |
893
- | `memory_sketch_create` | 暫時動作圖 |
894
- | `memory_sketch_promote` | 提升為永久 |
895
- | `memory_crystallize` | 緊湊化動作鏈 |
896
- | `memory_diagnose` | 健康檢查 |
897
- | `memory_heal` | 自動修復卡住的狀態 |
898
- | `memory_facet_tag` | 維度:值 標籤 |
899
- | `memory_facet_query` | 依 facet 標籤查詢 |
900
- | `memory_verify` | 追溯來源 |
901
-
902
- </details>
903
-
904
- ### 6 個資源 · 3 個提示 · 4 個 Skills
905
-
906
- | 類型 | 名稱 | 描述 |
907
- |------|------|-------------|
908
- | Resource | `agentmemory://status` | 健康、會話數、記憶數 |
909
- | Resource | `agentmemory://project/{name}/profile` | 專案層級智慧 |
910
- | Resource | `agentmemory://memories/latest` | 最新 10 條活躍記憶 |
911
- | Resource | `agentmemory://graph/stats` | 知識圖譜統計 |
912
- | Prompt | `recall_context` | 搜尋並回傳上下文訊息 |
913
- | Prompt | `session_handoff` | 代理之間的交接資料 |
914
- | Prompt | `detect_patterns` | 分析反覆出現的模式 |
915
- | Skill | `/recall` | 搜尋記憶 |
916
- | Skill | `/remember` | 儲存到長期記憶 |
917
- | Skill | `/session-history` | 最近的會話摘要 |
918
- | Skill | `/forget` | 刪除觀測/會話 |
919
-
920
- ### 獨立 MCP
921
-
922
- 無需完整伺服器即可執行 — 適用於任何 MCP 用戶端。以下兩種都可以:
923
-
924
- ```bash
925
- npx -y @agentmemory/agentmemory mcp # 標準指令(始終可用)
926
- npx -y @agentmemory/mcp # shim 套件別名
927
- ```
928
-
929
- 或新增到你的代理的 MCP 設定:
930
-
931
- 大多數代理(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
932
- ```json
933
- {
934
- "mcpServers": {
935
- "agentmemory": {
936
- "command": "npx",
937
- "args": ["-y", "@agentmemory/mcp"],
938
- "env": {
939
- "AGENTMEMORY_URL": "http://localhost:3111"
940
- }
941
- }
942
- }
943
- }
944
- ```
945
-
946
- 把 `agentmemory` 條目合併到你的宿主既有的 `mcpServers` 物件中,而非取代檔案。對於無法存取宿主 `localhost` 的沙箱用戶端,在 env 區塊中加入 `"AGENTMEMORY_FORCE_PROXY": "1"`,並把 `AGENTMEMORY_URL` 設為沙箱能到達的路由。
947
-
948
- OpenCode (`opencode.json`):
949
- ```json
950
- {
951
- "mcp": {
952
- "agentmemory": {
953
- "type": "local",
954
- "command": ["npx", "-y", "@agentmemory/mcp"],
955
- "enabled": true
956
- }
957
- },
958
- "plugin": ["./plugins/agentmemory-capture.ts"]
959
- }
960
- ```
961
-
962
- 從倉庫複製外掛檔:
963
- ```bash
964
- mkdir -p ~/.config/opencode/plugins
965
- cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
966
- cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
967
- ```
968
-
969
- ---
970
-
971
- <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
972
-
973
- 在連接埠 `3113` 自動啟動。即時觀測流、會話瀏覽器、記憶瀏覽器、知識圖譜視覺化和健康儀表板。
974
-
975
- ```bash
976
- open http://localhost:3113
977
- ```
978
-
979
- 檢視器伺服器預設繫結 `127.0.0.1`。REST 提供的 `/agentmemory/viewer` 端點遵循正常的 `AGENTMEMORY_SECRET` bearer-token 規則。CSP 標頭使用每回應 script nonce 並停用行內處理常式屬性(`script-src-attr 'none'`)。
980
-
981
- ---
982
-
983
- <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
984
-
985
- `:3113` 上的檢視器展示你的代理**記住了什麼**。[iii 主控台](https://iii.dev/docs/console) 展示你的代理**做了什麼** — 每個記憶操作都是 OpenTelemetry trace,每個 KV 條目都可編輯,每個函式都可呼叫,每個串流都可掛載。同一記憶的兩個視窗:一個面向產品,一個面向引擎。
986
-
987
- 觀察一次 `memory_smart_search` 觸發,在瀑布圖中看到 BM25 掃描 → 嵌入查找 → RRF 融合 → 重新排序器。在 KV 瀏覽器中編輯卡住的整合計時器。用調整後的負載重播一個 `PostToolUse` hook。釘選 WebSocket 串流,即時觀察觀測落地。
988
-
989
- agentmemory 免費提供這一切,因為每個函式、觸發器、狀態範圍、串流都是 iii 原語 — 沒有自訂、沒有需要插樁的地方。
990
-
991
- <p align="center">
992
- <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
993
- <br/>
994
- <em>Workers 頁面:每個已連接 worker — 包括 agentmemory 本身 — 顯示 PID、函式數、執行階段和最後在線時間。</em>
995
- </p>
996
-
997
- **已經裝好了。** 主控台隨 `iii` 一同發布 — 無需獨立安裝器。
998
-
999
- **與 agentmemory 並行啟動:**
1000
-
1001
- ```bash
1002
- # agentmemory 檢視器佔用連接埠 3113,所以在 3114 執行主控台。
1003
- # 引擎 REST (3111)、WebSocket (3112)、bridge (49134) 預設值與 agentmemory 相符。
1004
- iii console --port 3114
1005
- ```
1006
-
1007
- 然後打開 `http://localhost:3114`。加 `--enable-flow` 開啟實驗性架構圖頁面。
1008
-
1009
- 僅在你已移動引擎端點時才覆寫:
1010
-
1011
- ```bash
1012
- iii console --port 3114 \
1013
- --engine-port 3111 \
1014
- --ws-port 3112 \
1015
- --bridge-port 49134
1016
- ```
1017
-
1018
- **主控台能做什麼:**
1019
-
1020
- | 頁面 | 用途 |
1021
- |------|-----------|
1022
- | **Workers** | 查看每個已連接 worker 及其即時指標 — 包括 agentmemory worker 本身。 |
1023
- | **Functions** | 直接以 JSON 負載呼叫 agentmemory 的任何函式 — 測試 `memory.recall`、`memory.consolidate`、`graph.query` 無需接入用戶端。 |
1024
- | **Triggers** | 重播 HTTP、cron、事件和狀態觸發器 — 手動觸發整合 cron、重試 HTTP 路由、發出狀態變更。 |
1025
- | **States** | 完整 CRUD 的 KV 瀏覽器 — 會話、記憶槽位、生命週期計時器、嵌入索引 — 就地編輯值。 |
1026
- | **Streams** | 記憶寫入、hook 事件和觀測更新流經 iii 串流時的即時 WebSocket 監視器。 |
1027
- | **Queues** | 持久佇列主題 + 死信管理。重播或捨棄失敗的嵌入/壓縮工作。 |
1028
- | **Traces** | OpenTelemetry 瀑布/火焰/服務分解視圖。按 `trace_id` 過濾,精確查看單次 `memory.search` 產生了哪些函式、DB 呼叫和嵌入請求。 |
1029
- | **Logs** | 結構化 OTEL 日誌,過濾並與 trace/span ID 關聯。 |
1030
- | **Config** | 執行階段設定 — 看到引擎正在使用的 workers、提供者和連接埠。 |
1031
- | **Flow** | (選用,`--enable-flow`)每個 worker、觸發器和串流的互動式架構圖。 |
1032
-
1033
- <p align="center">
1034
- <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1035
- <br/>
1036
- <em>Traces:每個記憶操作的瀑布/火焰/服務分解。</em>
1037
- </p>
1038
-
1039
- **Traces 已開啟:**
1040
-
1041
- `iii-config.yaml` 出廠啟用 `iii-observability` worker(`exporter: memory`、`sampling_ratio: 1.0`、指標 + 日誌)。無需額外設定 — agentmemory 啟動那一刻,每個記憶操作都會發出一個 trace span 和一個主控台可讀的結構化日誌。
1042
-
1043
- 若你想改為匯出到 Jaeger/Honeycomb/Grafana Tempo,把 `exporter: memory` 改為 `exporter: otlp` 並依 iii 的可觀測性文件設定收集器端點。
1044
-
1045
- > **提醒:** 主控台本身未強制驗證 — 保持其繫結 `127.0.0.1`(預設)並永遠不要對外暴露。
1046
-
1047
- ---
1048
-
1049
- <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1050
-
1051
- agentmemory **本身就是一個執行中的 [iii](https://iii.dev) 實例**。函式、觸發器、KV 狀態、串流、OTEL traces — 全部都是 iii 原語。你沒有安裝 Postgres、Redis、Express、pm2 或 Prometheus,因為 iii 取代了它們。
1052
-
1053
- 這代表多一條指令就能為 agentmemory 增加一整套新能力。
1054
-
1055
- ### 一條指令擴展 agentmemory
1056
-
1057
- ```bash
1058
- iii worker add iii-pubsub # 把記憶寫入扇出到每個連接的實例
1059
- iii worker add iii-cron # 排程整合、衰減掃描、快照輪替
1060
- iii worker add iii-queue # 嵌入 + 壓縮工作的持久重試
1061
- iii worker add iii-observability # 每個記憶操作的 OTEL traces(預設開啟)
1062
- iii worker add iii-sandbox # 在隔離 microVM 內執行召回到的程式碼
1063
- iii worker add iii-database # 切換 SQL 後端的狀態適配器
1064
- iii worker add mcp # 在 agentmemory 的 MCP 旁開設通用 MCP 宿主
1065
- ```
1066
-
1067
- 每個 `iii worker add` 都會把新的函式和觸發器註冊到 agentmemory 正在執行的同一引擎中。檢視器和主控台立即接收 — 無需重新載入、無需新整合、無需新容器。
1068
-
1069
- | `iii worker add` | 在 agentmemory 上獲得的額外能力 |
1070
- |---|---|
1071
- | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 多實例記憶:每次 `remember` 扇出,每次 `search` 讀取聯集 |
1072
- | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 排程生命週期 — 夜間整合、週快照、按固定時鐘衰減 |
1073
- | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 持久重試:失敗的嵌入 + 壓縮工作在重啟後存活,無觀測遺失 |
1074
- | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 每個函式的 OTEL traces、指標、日誌 — 從第一天起就接入 `iii-config.yaml` |
1075
- | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` 出來的程式碼在一次性 VM 中執行,不在你的 shell 中 |
1076
- | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 當預設的記憶體 KV 不夠用時,SQL 後端狀態適配器 |
1077
- | [`mcp`](https://workers.iii.dev/workers/mcp) | 在 agentmemory 的旁邊架設額外 MCP 伺服器,共享同一引擎 |
1078
-
1079
- 完整登錄表:[workers.iii.dev](https://workers.iii.dev)。那裡的每個 worker 都透過 agentmemory 所用的同樣原語組合 — 而你已經擁有的 agentmemory 本身就是其中之一。
1080
-
1081
- ### iii 取代了什麼
1082
-
1083
- | 傳統堆疊 | agentmemory 使用 |
1084
- |---|---|
1085
- | Express.js / Fastify | iii HTTP Triggers |
1086
- | SQLite / Postgres + pgvector | iii KV State + 記憶體向量索引 |
1087
- | SSE / Socket.io | iii Streams (WebSocket) |
1088
- | pm2 / systemd | iii engine worker 監管 |
1089
- | Prometheus / Grafana | iii OTEL + 健康監控 |
1090
- | 自訂外掛系統 | `iii worker add <name>` |
1091
-
1092
- **118 個原始檔 · ~21,800 行程式碼 · 950+ 測試 · 123 個函式 · 34 個 KV 範圍** — 全部基於三種原語。沒有 `agentmemory plugin install`。外掛系統就是 iii 本身。
1093
-
1094
- ---
1095
-
1096
- <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1097
-
1098
- ### LLM 提供者
1099
-
1100
- agentmemory 從你的環境自動偵測。預設情況下,除非你設定提供者或明確啟用 Claude 訂閱回退,否則不會發起 LLM 呼叫。
1101
-
1102
- | 提供者 | 設定 | 備註 |
1103
- |----------|--------|-------|
1104
- | **No-op(預設)** | 無需設定 | LLM 驅動的 compress/summarize 被停用。合成 BM25 壓縮 + 召回仍可用。若你以前依賴 Claude 訂閱回退,請見下面的 `AGENTMEMORY_ALLOW_AGENT_SDK`。 |
1105
- | Anthropic API | `ANTHROPIC_API_KEY` | 依 token 計費 |
1106
- | MiniMax | `MINIMAX_API_KEY` | Anthropic 相容 |
1107
- | Gemini | `GEMINI_API_KEY` | 同時啟用嵌入 |
1108
- | OpenRouter | `OPENROUTER_API_KEY` | 任意模型 |
1109
- | Claude 訂閱回退 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 僅按需啟用。會衍生 `@anthropic-ai/claude-agent-sdk` 會話 — 曾導致無限 Stop-hook 遞迴(#149 後續)故不再預設。 |
1110
-
1111
- ### 成本感知的模型選擇
1112
-
1113
- 背景壓縮在每次觀測時執行,模型選擇會顯著影響月支出。擷取的工作負載資料:635 次請求 / 888K tokens / 35 小時活躍使用,基於 2026-05-23 OpenRouter 定價對三個模型評測。
1114
-
1115
- | 等級 | 模型 | 輸入 / 1M | 輸出 / 1M | 35 小時擷取工作負載成本 | 備註 |
1116
- |------|-------|------------|-------------|---------------------------|-------|
1117
- | 推薦 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 壓縮 + 摘要品質穩定,比 Sonnet 便宜 ~10×。 |
1118
- | 推薦 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 略舊但仍勝任僅壓縮工作負載。 |
1119
- | 推薦 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 若你的會話多為程式碼,程式碼推理能力強。 |
1120
- | 高階 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 品質高但對長期背景工作來說成本昂貴。 |
1121
- | 高階 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | 與 Sonnet 同檔。 |
1122
- | 避免 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推理級模型;用於壓縮屬於巨額超支。 |
1123
-
1124
- 當 `OPENROUTER_MODEL` 比對高階層模式時,agentmemory 會印出執行階段警告。在做出知情選擇後,設定 `AGENTMEMORY_SUPPRESS_COST_WARNING=1` 來消音。
1125
-
1126
- 記憶工作的品質-成本權衡:壓縮是品質門檻相對寬鬆的摘要任務(代理重新閱讀摘要,而非使用者)。DeepSeek-V4-Pro / Qwen3-Coder 在該任務上與 Sonnet 誤差極小,而成本約低 10×。把高階層模型留給你直接閱讀的查詢。
1127
-
1128
- 來源:[OpenRouter Sonnet 4.6 定價](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek 定價說明](https://api-docs.deepseek.com/quick_start/pricing/)。
1129
-
1130
- ### 多代理記憶(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1131
-
1132
- 在多個角色共享一台 agentmemory 伺服器的多代理設置中(architect / developer / reviewer / researcher / support-agent),`AGENT_ID` 給每次寫入打上發起角色的標籤。`AGENTMEMORY_AGENT_SCOPE` 控制召回是否依該標籤過濾。
1133
-
1134
- ```env
1135
- TEAM_ID=company
1136
- USER_ID=engineering-team
1137
- AGENT_ID=architect
1138
- AGENTMEMORY_AGENT_SCOPE=isolated # 選填;預設 "shared"
1139
- ```
1140
-
1141
- 兩種模式:
1142
-
1143
- | 模式 | 標記寫入 | 過濾召回 | 何時使用 |
1144
- |------|------------|---------------|-------------|
1145
- | `shared`(預設) | 是 | 否 | 跨代理共享上下文且帶稽核軌跡。Architect 能看到 developer 記下了什麼,但每條記錄都標明發言者。 |
1146
- | `isolated` | 是 | 是 | 嚴格隔離。Architect 永遠不會看到 developer 的觀測/記憶/會話。 |
1147
-
1148
- 設定 `AGENT_ID` 後會被標記的內容:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。角色從 `api::session::start` → `mem::observe` → `mem::compress` → KV 流轉。
1149
-
1150
- isolated 模式下被過濾的內容:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。每個端點都接受 `?agentId=<role>` 來依請求覆寫,以及 `?agentId=*` 來完全跳過環境範圍。`/memories` 還接受 `?includeOrphans=true` 來浮現 `agentId` 為 undefined 的 pre-AGENT_ID 記憶。
1151
-
1152
- SDK / REST 層的依呼叫覆寫:每個變更端點(`/session/start`、`/remember`)都接受請求體中的 `agentId` 欄位,勝過環境變數。對於在一個伺服器行程中路由多角色的執行階段很有用。
1153
-
1154
- 當 `AGENT_ID` 未設定時,記憶保持無範圍(舊行為,無標籤、無過濾)。
1155
-
1156
- ### 連接埠
1157
-
1158
- agentmemory + iii-engine 預設繫結四個連接埠。若重啟失敗並顯示 `port in use`,這張表告訴你該查找什麼行程。
1159
-
1160
- | 連接埠 | 行程 | 用途 | 環境覆寫 |
1161
- |------|---------|---------|--------------|
1162
- | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1163
- | `3112` | iii-engine | 內部串流 worker(由 agentmemory + 檢視器消費) | `III_STREAMS_PORT` |
1164
- | `3113` | agentmemory | 即時檢視器(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1165
- | `49134` | iii-engine | WebSocket — workers 在此註冊,OTel 遙測在此流過 | `III_ENGINE_URL`(完整 URL,預設 `ws://localhost:49134`) |
1166
-
1167
- 當機後連接埠仍被佔用時的陳舊行程清理:
1168
-
1169
- ```bash
1170
- # macOS / Linux — 找出每個連接埠上的行程並 kill 掉
1171
- lsof -i :3111,3112,3113,49134
1172
- pkill -f agentmemory || true
1173
- pkill -f 'iii ' || true
1174
-
1175
- # Windows
1176
- netstat -ano | findstr ":3111 :3112 :3113 :49134"
1177
- taskkill /F /PID <pid>
1178
- ```
1179
-
1180
- `agentmemory stop` 在優雅關閉時乾淨地回收 worker 和 engine pidfile(#640、#474)。上述手動清理僅針對當機後兩個 pidfile 都未留下的情況。
1181
-
1182
- ### 設定檔
1183
-
1184
- 把 agentmemory 執行階段設定放到 `~/.agentmemory/.env`,而非在每個 shell 中 export 變數。若檢視器顯示像 `export ANTHROPIC_API_KEY=...` 這樣的設定提示,把它複製到該檔案作為 `ANTHROPIC_API_KEY=...`(去掉 `export` 前綴),然後重啟 agentmemory。
1185
-
1186
- 行程環境變數仍然有效,優先序高於檔案中的值。
1187
-
1188
- 在 Windows 上,同一檔案位於 `%USERPROFILE%\.agentmemory\.env`:
1189
-
1190
- ```powershell
1191
- New-Item -ItemType Directory -Force $HOME\.agentmemory
1192
- notepad $HOME\.agentmemory\.env
1193
- ```
1194
-
1195
- 要用 Claude Code Pro/Max 訂閱而非 API key 測試,明確啟用:
1196
-
1197
- ```env
1198
- AGENTMEMORY_ALLOW_AGENT_SDK=true
1199
- AGENTMEMORY_AUTO_COMPRESS=true
1200
- ```
1201
-
1202
- 若想開啟圖或整合特性,在同一檔案中打開:
1203
-
1204
- ```env
1205
- GRAPH_EXTRACTION_ENABLED=true
1206
- CONSOLIDATION_ENABLED=true
1207
- ```
1208
-
1209
- ### 環境變數
1210
-
1211
- 建立 `~/.agentmemory/.env`:
1212
-
1213
- ```env
1214
- # LLM provider (pick one — default is the no-op provider: no LLM calls)
1215
- # ANTHROPIC_API_KEY=sk-ant-...
1216
- # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1217
- # GEMINI_API_KEY=...
1218
- # OPENROUTER_API_KEY=...
1219
- # MINIMAX_API_KEY=...
1220
- # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1221
- # # OpenAI LLM provider (here) AND the OpenAI
1222
- # # embedding provider (further below). Set
1223
- # # OPENAI_API_KEY_FOR_LLM=false to scope it
1224
- # # to embeddings only.
1225
- # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1226
- # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1227
- # # Auto-detected from `.openai.azure.com` hostname; uses
1228
- # # api-key header + api-version query param.
1229
- # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1230
- # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1231
- # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1232
- # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1233
- # # for back-compat with v0.9.17. New configs should
1234
- # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1235
- # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1236
- # # Honored only by OpenAI's reasoning models (o1, o3,
1237
- # # gpt-*-reasoning) and providers that mirror that
1238
- # # schema (Ollama Cloud thinking models). Standard
1239
- # # chat models reject this field with 400. Set to
1240
- # # "none" for thinking models that return reasoning
1241
- # # but no content.
1242
- # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1243
- # # for LLM (useful if you only want OpenAI for embeddings)
1244
- # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1245
- # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1246
- # AGENTMEMORY_ALLOW_AGENT_SDK=true
1247
-
1248
- # Embedding provider (auto-detected, or override)
1249
- # EMBEDDING_PROVIDER=local
1250
- # VOYAGE_API_KEY=...
1251
- # OPENAI_API_KEY=sk-...
1252
- # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1253
- # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1254
- # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1255
-
1256
- # Outbound LLM / embedding timeout
1257
- # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1258
- # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1259
- # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1260
- # embedding). For the OpenAI LLM path, the
1261
- # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1262
- # takes precedence when set, for back-compat
1263
- # with v0.9.17.
1264
- # Increase for slow networks or large batch calls;
1265
- # decrease to fail-fast on rate-limit holds.
1266
-
1267
- # Search tuning
1268
- # BM25_WEIGHT=0.4
1269
- # VECTOR_WEIGHT=0.6
1270
- # TOKEN_BUDGET=2000
1271
-
1272
- # Auth
1273
- # AGENTMEMORY_SECRET=your-secret
1274
-
1275
- # Ports (defaults: 3111 API, 3113 viewer)
1276
- # III_REST_PORT=3111
1277
-
1278
- # Features
1279
- # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1280
- # every PostToolUse hook calls your
1281
- # LLM provider to compress the
1282
- # observation — expect significant
1283
- # token spend on active sessions.
1284
- # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1285
- # memory slots — persona,
1286
- # user_preferences, tool_guidelines,
1287
- # project_context, guidance,
1288
- # pending_items, session_patterns,
1289
- # self_notes. Size-limited; agent
1290
- # edits via memory_slot_* tools.
1291
- # Pinned slots addressable for
1292
- # SessionStart injection.
1293
- # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1294
- # Stop hook fires mem::slot-reflect:
1295
- # scans recent observations, auto-
1296
- # appends TODOs to pending_items,
1297
- # counts patterns in
1298
- # session_patterns, records touched
1299
- # files in project_context. Fire-
1300
- # and-forget; does not block.
1301
- # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1302
- # - SessionStart may inject ~1-2K
1303
- # chars of project context into
1304
- # the first turn of each session
1305
- # (this is what actually reaches
1306
- # the model — Claude Code treats
1307
- # SessionStart stdout as context)
1308
- # - PreToolUse fires /agentmemory/enrich
1309
- # on every file-touching tool call
1310
- # (resource cleanup, not a token
1311
- # fix — PreToolUse stdout is debug
1312
- # log only per Claude Code docs)
1313
- # Observations are still captured via
1314
- # PostToolUse regardless of this flag.
1315
- # GRAPH_EXTRACTION_ENABLED=false
1316
- # CONSOLIDATION_ENABLED=true
1317
- # LESSON_DECAY_ENABLED=true
1318
- # OBSIDIAN_AUTO_EXPORT=false
1319
- # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1320
- # CLAUDE_MEMORY_BRIDGE=false
1321
- # SNAPSHOT_ENABLED=false
1322
-
1323
- # Team
1324
- # TEAM_ID=
1325
- # USER_ID=
1326
- # TEAM_MODE=private
1327
-
1328
- # Tool visibility: "core" (8 tools) or "all" (51 tools)
1329
- # AGENTMEMORY_TOOLS=core
1330
- ```
1331
-
1332
- ---
1333
-
1334
- <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1335
-
1336
- 連接埠 `3111` 上的 124 個端點。REST API 預設繫結 `127.0.0.1`。當 `AGENTMEMORY_SECRET` 已設定時,受保護端點需要 `Authorization: Bearer <secret>`,網狀同步端點要求兩端都設定 `AGENTMEMORY_SECRET`。
1337
-
1338
- <details>
1339
- <summary>關鍵端點</summary>
1340
-
1341
- | 方法 | 路徑 | 描述 |
1342
- |--------|------|-------------|
1343
- | `GET` | `/agentmemory/health` | 健康檢查(始終公開) |
1344
- | `POST` | `/agentmemory/session/start` | 開始會話 + 取得上下文 |
1345
- | `POST` | `/agentmemory/session/end` | 結束會話 |
1346
- | `POST` | `/agentmemory/observe` | 擷取觀測 |
1347
- | `POST` | `/agentmemory/smart-search` | 混合搜尋 |
1348
- | `POST` | `/agentmemory/context` | 產生上下文 |
1349
- | `POST` | `/agentmemory/remember` | 儲存到長期記憶 |
1350
- | `POST` | `/agentmemory/forget` | 刪除觀測 |
1351
- | `POST` | `/agentmemory/enrich` | 檔案上下文 + 記憶 + bugs |
1352
- | `GET` | `/agentmemory/profile` | 專案檔案 |
1353
- | `GET` | `/agentmemory/export` | 匯出所有資料 |
1354
- | `POST` | `/agentmemory/import` | 從 JSON 匯入 |
1355
- | `POST` | `/agentmemory/graph/query` | 知識圖譜查詢 |
1356
- | `POST` | `/agentmemory/team/share` | 與團隊共享 |
1357
- | `GET` | `/agentmemory/audit` | 稽核軌跡 |
1358
-
1359
- 完整端點列表:[`src/triggers/api.ts`](../src/triggers/api.ts)
1360
-
1361
- </details>
1362
-
1363
- ---
1364
-
1365
- <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1366
-
1367
- ```bash
1368
- npm run dev # 熱重新載入
1369
- npm run build # 生產建置
1370
- npm test # 950+ 測試
1371
- npm run test:integration # API 測試(需要服務執行中)
1372
- ```
1373
-
1374
- **先決條件:** Node.js >= 20、[iii-engine](https://iii.dev/docs) 或 Docker
1375
-
1376
- <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1377
-
1378
- [Apache-2.0](../LICENSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ROADMAP.md DELETED
@@ -1,66 +0,0 @@
1
- # Roadmap
2
-
3
- This is agentmemory-python's public roadmap. Items shift as priorities change.
4
-
5
- - **Shipped** — in main
6
- - **Active** — has an open PR
7
- - **Planned** — accepted, not started
8
- - **Candidate** — under consideration
9
-
10
- ---
11
-
12
- ## Phase 1 — Foundation (done)
13
-
14
- - [x] Python + Flask server replacing Node.js / iii-engine
15
- - [x] SQLite WAL backend replacing Dolt SQL
16
- - [x] Audit log replacing Dolt git versioning
17
- - [x] BM25 search with Porter stemmer
18
- - [x] Gemini 768-dim vector search + hybrid RRF fusion
19
- - [x] 16-tool MCP endpoint
20
- - [x] WebSocket live stream
21
- - [x] Built-in HTML viewer (Dashboard, Sessions, Memories, Graph, Timeline, Lessons, Slots, Replay)
22
- - [x] Knowledge graph visualization — folder nodes with unique colors, force-directed layout
23
- - [x] 4-tier memory consolidation (Working → Episodic → Semantic → Procedural)
24
- - [x] Lessons system with confidence decay
25
- - [x] HuggingFace Space deployment with sync fingerprinting
26
- - [x] Dolt → SQLite one-time migration (7502 rows, 19.6MB)
27
-
28
- ---
29
-
30
- ## Phase 2 — Reliability
31
-
32
- ### Active
33
-
34
- - [ ] **Pytest test coverage** for `src/functions.py` core operations (observe, remember, search, context)
35
- - [ ] **Graph edge label bug** — labels overlap at default zoom on dense graphs
36
-
37
- ### Planned
38
-
39
- - [ ] **Additional embedding providers** — OpenAI `text-embedding-3-small`, local `sentence-transformers`
40
- - [ ] **Hook scripts** — prebuilt bash/PowerShell hook scripts for Claude Code, Cursor, Codex CLI pointing at `http://localhost:3111`
41
- - [ ] **Memory export/import** — JSON round-trip so users can migrate between instances
42
- - [ ] **Health endpoint** (`/agentmemory/health`) — richer than `/livez`, includes index sizes, sync status, last backup time
43
- - [ ] **Graceful shutdown** — flush BM25/vector index to DB before exit on SIGTERM
44
-
45
- ---
46
-
47
- ## Phase 3 — Breadth
48
-
49
- ### Candidate
50
-
51
- - **Additional LLM providers** — OpenRouter, Ollama (local), Cohere for compression and consolidation
52
- - **MCP tool parity** — expand from 16 to 30+ tools to match the most-used subset of the Node.js 53-tool surface
53
- - **GitHub Actions hook** — observe CI runs as memory events
54
- - **Slack / Discord connector** — ingest messages as observations
55
- - **Multi-agent shared memory** — namespace isolation for team use; agents share a pool with per-agent write attribution
56
- - **RBAC** — role-based access control for shared deployments
57
- - **Benchmark harness** — reproduce the LongMemEval-S R@5 metric on the Python stack
58
- - **pip package** — `pip install agentmemory` with a `agentmemory` CLI entrypoint
59
-
60
- ---
61
-
62
- ## Non-goals
63
-
64
- - Full parity with the 128-endpoint / 53-tool Node.js surface — the Python version targets simplicity and HF deployment, not feature count
65
- - iii-engine worker model — the Python version intentionally avoids the iii runtime
66
- - Dolt git-versioned history — the audit log satisfies the write-tracking requirement without the complexity
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SECURITY.md DELETED
@@ -1,85 +0,0 @@
1
- # Security Policy
2
-
3
- ## Reporting a vulnerability
4
-
5
- **Do not open a public GitHub issue for a suspected vulnerability.**
6
-
7
- Use one of:
8
-
9
- - **GitHub Security Advisories (preferred)** — private report form at <https://github.com/rohitg00/agentmemory/security/advisories/new>. GitHub routes the report to the Maintainers, assigns a GHSA identifier, and keeps you in a private thread until the fix ships. All sensitive details (stack traces, credentials, exploit payloads) stay end-to-end within GitHub's security infrastructure — use this channel whenever possible.
10
- - **Encrypted email (fallback)** — if GitHub is unavailable or the issue cannot be described in the GHSA form, send an encrypted message to `ghumare64@gmail.com` with subject `agentmemory security`. Encrypt with the Maintainer public keys published at <https://github.com/rohitg00.gpg> (PGP) and <https://github.com/rohitg00.keys> (SSH for verification); attach your own public key so we can reply encrypted. Plaintext email is accepted only as a last resort — prefer GHSA.
11
-
12
- Include, at minimum:
13
-
14
- - agentmemory version (`npm view @agentmemory/agentmemory version` against your install).
15
- - The affected surface — REST endpoint, MCP tool, hook, CLI flag, or filesystem layout.
16
- - A minimal reproduction — prefer one curl invocation or one MCP tool call plus the environment state required.
17
- - Impact, in your own words.
18
-
19
- ## What we do with it
20
-
21
- 1. **Acknowledge** within 72 hours (target: 24).
22
- 2. **Triage** — confirm reproduction, assign a severity using CVSS 3.1, and give you a rough timeline.
23
- 3. **Fix** in a private branch. Draft a GitHub Security Advisory with the patched version, CWE, CVSS vector, affected versions, and attribution to you (unless you prefer anonymity).
24
- 4. **Coordinate disclosure** — we agree a disclosure date with you. Default window is 30 days from acknowledgment for straightforward vulnerabilities, up to 90 days for ones that need a deep refactor.
25
- 5. **Publish** — release the patched version on npm, publish the advisory, update `CHANGELOG.md` under a `### Security` section for the release, notify downstream scanners.
26
-
27
- ## Supported versions
28
-
29
- | Version | Security fixes? |
30
- |-|-|
31
- | Latest minor (currently `0.9.x`) | Yes |
32
- | Previous minor (currently `0.8.x`) | Critical / High severity only, for 90 days after a new minor is released |
33
- | Older | No |
34
-
35
- At v1.0 this policy switches to a stated LTS window per the roadmap.
36
-
37
- ## Scope
38
-
39
- In scope:
40
-
41
- - The `@agentmemory/agentmemory` server (REST + MCP surface, hook handlers, state store).
42
- - The `@agentmemory/mcp` standalone MCP server.
43
- - The `@agentmemory/fs-watcher` connector.
44
- - First-party integrations under `integrations/` (`hermes/`, `openclaw/`, `filesystem-watcher/`).
45
- - The Claude Code plugin under `plugin/`.
46
-
47
- Out of scope:
48
-
49
- - Third-party MCP clients consuming agentmemory — report to those projects.
50
- - `iii-sdk` upstream — report to the iii project.
51
- - The marketing site under `website/` unless the issue affects user security (XSS against visitors, credential leak in build output).
52
-
53
- ## Supply-chain stance
54
-
55
- agentmemory ships pre-built artifacts in the npm tarball — `dist/` is bundled at publish time, not built from `node_modules` at install time. The package's runtime dependency tree is intentionally small (6 production deps: `@anthropic-ai/sdk`, `@anthropic-ai/claude-agent-sdk`, `@clack/prompts`, `dotenv`, `iii-sdk`, `zod`) plus an optional set guarded behind `optionalDependencies` for embeddings.
56
-
57
- **No lockfile is committed** (#540). The reasoning:
58
-
59
- - The npm tarball ships pre-built `dist/` — fresh installs don't compile from source, so no lockfile is consulted at the user's install step.
60
- - The lockfile only affects contributor-local builds. Pinning it would shift the supply-chain attack surface from "what npm resolves today" to "what was resolved when the lockfile was last regenerated," which is a different tradeoff, not strictly better.
61
- - We use SemVer ranges (`^x.y.z`) on the published deps so security patches reach users without a re-release.
62
-
63
- If you ship agentmemory inside a hardened pipeline that requires reproducible installs, the recommended path is:
64
-
65
- 1. `npm install --legacy-peer-deps` against the published tarball in a controlled environment.
66
- 2. `npm shrinkwrap` to produce a versioned `npm-shrinkwrap.json` that travels with your deployment.
67
- 3. Audit `node_modules/` once at that point and republish internally.
68
-
69
- CI runs `npm install --package-lock-only --legacy-peer-deps --no-audit --no-fund` then `npm ci` against that generated lockfile, so every test job builds against a fully resolved tree. The lockfile is regenerated on each CI run rather than checked in, which keeps the published tarball aligned with whatever SemVer-compatible patch level was current at release time.
70
-
71
- Supply-chain monitoring we already do:
72
-
73
- - Dependabot opens PRs for every minor/patch bump on the production dep list (visible in the open PRs).
74
- - Every PR runs the full test suite on ubuntu-latest + macos-latest, Node 20 + 22, before any merge.
75
- - `optionalDependencies` (`@xenova/transformers`, `onnxruntime-node`, etc.) are guarded by `try { await import("...") } catch` so a missing or compromised optional dep cannot break the core runtime path.
76
-
77
- If you find a malicious package in our dep tree, file via the GHSA flow at the top of this document — that's the fastest path to a fixed release on npm.
78
-
79
- ## Past advisories
80
-
81
- See the [`.github/security-advisories/`](./.github/security-advisories) directory for advisory drafts. Published advisories (with assigned GHSA IDs) live at <https://github.com/rohitg00/agentmemory/security/advisories>.
82
-
83
- ## Safe harbor
84
-
85
- Good-faith research, reported privately, does not get legal heat from the project. Research targeting third-party deployments of agentmemory is not covered — that's between you and the deployer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SPIKE.md DELETED
@@ -1,578 +0,0 @@
1
- # Feature Spike: Small Improvements for Agent Cache User Experience
2
-
3
- **Date:** 2026-07-16
4
- **Priority:** Low risk, high value additions to current architecture
5
- **Tech Stack Impact:** None — all fit within Flask/SQLite model
6
-
7
- ---
8
-
9
- ## Table of Contents
10
- 1. [Current State Analysis](#current-state-analysis)
11
- 2. [Feature Opportunities](#feature-opportunities)
12
- 3. [Recommendation Priority](#recommendation-priority)
13
-
14
- ---
15
-
16
- ## Current State Analysis
17
-
18
- ### What agentcache-python Already Has
19
-
20
- **Core Features Implemented:**
21
- - REST API (Flask framework on port 3111)
22
- - WebSocket streaming (`/stream/mem-live/viewer`)
23
- - Hybrid search: BM25 keyword + vector embeddings (Gemini/OpenAI/SentenceTransformer)
24
- - Folder-based memory model: `(folder_path, agent_id)` scoping
25
- - Knowledge graph construction via `folder_graph_build()`
26
- - MCP tools for agent integration (13+ tools)
27
- - Security redactions in observations (`strip_private_data()`)
28
- - Token budget limits during context compilation
29
- - Background workers for index maintenance
30
-
31
- **Key Functions:**
32
- | Function | Purpose | File |
33
- |----------|---------|------|
34
- | `folder_observe()` | Ingest observations with scoping | `functions.py` |
35
- | `folder_search()` | BM25 + vector hybrid search | `search.py` |
36
- | `folder_timeline()` | Chronological activity feed | `functions.py` |
37
- | `folder_graph_build()` | Build knowledge graph nodes/edges | `functions.py` |
38
- | `remember()/forget()` | Global memory management | `functions.py` |
39
- | `context()` | Compile contextual blocks with token limits | `functions.py` |
40
- | `export_data()` | v2 JSON export format | `functions.py` |
41
-
42
- **Key Tests:**
43
- - `test_observe_core.py` — Observation validation and redaction
44
- - `test_folder_observe.py` — Folder-scoped ingestion
45
- - `test_search.py` — BM25/vector search logic
46
- - `test_context.py` — Context compilation with token budgets
47
- - `test_graph.py` — Knowledge graph construction
48
-
49
- ---
50
-
51
- ## Feature Opportunities
52
-
53
- ### 🎯 Feature 1: Observation Prioritization / Weighting
54
-
55
- **Why Add This?**
56
- Users naturally write observations with different levels of importance. Currently all observations are weighted equally in search results. The search uses RRF (Reciprocal Rank Fusion) which already applies weights, but there's no user-controlled way to emphasize important observations.
57
-
58
- **What to Implement:**
59
- ```python
60
- def folder_observe(kv, payload, priority=0): # 0-100 scale
61
-
62
- # Store in metadata:
63
- obs["priority"] = priority
64
-
65
- return {
66
- "observationId": fobs_{hash}_{rand},
67
- "priority": priority, # Added field
68
- ...
69
- }
70
- ```
71
-
72
- **Changes Required:**
73
- - Add `priority` field to observation payload validation (new required/optional check)
74
- - Modify search weighting in `HybridSearch._rank()` to include observation priority:
75
- ```python
76
- # Current RRF: rank_weight = 1 / len(relevant_docs)
77
- # New RRF: combined_weight = (bm25_score + vector_score) * obs_priority / 100
78
- ```
79
-
80
- **User Experience:**
81
- When a user writes an observation, they can optionally mark it as high-priority:
82
- ```python
83
- # Tag this as critical issue - show prominently in search results
84
- folder_observe(
85
- kv, {
86
- "folderPath": "/home/user/project/src/auth",
87
- "agentId": "my-ai-agent",
88
- "text": "JWT rotation breaks production auth endpoints",
89
- "timestamp": now(),
90
- "priority": 90 # Highest importance
91
- }
92
- )
93
- ```
94
-
95
- Search results for "jwt auth break" automatically rank this observation higher than lower-priority memories.
96
-
97
- **Implementation Complexity:** **15 minutes**
98
- - Add one field to observation validation schema
99
- - Modify RRF weighting formula (single math operation change)
100
- - Update tests to verify priority affects ranking
101
-
102
- ---
103
-
104
- ### 🎯 Feature 2: Observation Source Tracking
105
-
106
- **Why Add This?**
107
- Users write observations from different contexts (code files, documentation, terminal logs). Knowing which file context an observation came from helps detect when user re-wrote same code after learning a lesson, and aids in identifying relevant follow-up actions.
108
-
109
- **What to Implement:**
110
- ```python
111
- def folder_observe(kv, payload, source_file=None): # e.g., "src/auth.py"
112
-
113
- obs["sourceFile"] = source_file or None
114
-
115
- return {
116
- "observationId": fobs_{hash}_{rand},
117
- "sourceFile": source_file, # New field
118
- "text": "...",
119
- ...
120
- }
121
- ```
122
-
123
- **Changes Required:**
124
- - Add `source_file` to observation payload validation (optional string)
125
- - Store as additional JSON field in KV value column
126
- - Update timeline query to optionally show source files
127
- - Update search results to surface source file info
128
-
129
- **User Experience:**
130
- Search: "What did I learn about JWT?"
131
- Results:
132
- ```json
133
- {
134
- "id": "fobs_abc123",
135
- "text": "JWT needs refresh tokens for rotation",
136
- "sourceFile": "src/auth.py",
137
- "timestamp": "2026-07-15T10:30:00Z"
138
- }
139
- ```
140
-
141
- The source file field tracks which files were being developed when lessons were learned. Helps detect when user re-implements same pattern after reading a tutorial, or helps identify which modules need updates based on recent observations.
142
-
143
- **Implementation Complexity:** **15 minutes**
144
- - Add one optional field to observation schema
145
- - Store in existing KV structure (no new table/column needed)
146
- - Update `folder_timeline()` to surface source file info when requested
147
-
148
- ---
149
-
150
- ### 🎯 Feature 3: Folder-Level Statistics Endpoint
151
-
152
- **Why Add This?**
153
- Users need quick stats on individual folders without going to the dashboard UI. The current `/health` endpoint only returns global aggregate across all folders. Users often want: "How many observations do I have in my frontend folder?" answered via simple API call.
154
-
155
- **What to Implement:**
156
- ```python
157
- # src/agentcache/routes/folder_stats.py or append to existing routes
158
-
159
- @app.route('/folder/stats/<path:folder_path>')
160
- def folder_stats(folder_path):
161
- kv = StateKV() # Get current DB instance
162
-
163
- # Count observations for this folder
164
- obs_count = 0
165
- try:
166
- from agentcache.functions import KV
167
- scope = KV.folder_obs(folder_path, os.getenv("AGENT_ID", "default"))
168
- rows = kv.db.execute(
169
- "SELECT COUNT(*) FROM kv_store WHERE scope = ?",
170
- [scope]
171
- ).fetchone()
172
- obs_count = rows[0] if rows else 0
173
- except:
174
- pass
175
-
176
- # Get last observation timestamp
177
- last_obs_ts = None
178
- try:
179
- rows = kv.db.execute(
180
- "SELECT MAX(ts) FROM kv_store WHERE scope = ?",
181
- [scope]
182
- ).fetchone()
183
- last_obs_ts = rows[0] if rows else None
184
- except:
185
- pass
186
-
187
- return {
188
- "folderPath": folder_path,
189
- "observationCount": obs_count,
190
- "memoryCount": 123, # Get from memories scope separately
191
- "lastObsTimestamp": last_obs_ts.isoformat() if last_obs_ts else None,
192
- "foldersKnownToThisAgent": ["home/user/projectX", ...] # Also include this context
193
- }
194
- ```
195
-
196
- **User Experience:**
197
- REST API call returns folder stats instantly:
198
- ```bash
199
- curl http://localhost:3111/folder/stats/home/user/my-project
200
- # Returns:
201
- {
202
- "folderPath": "home/user/my-project",
203
- "observationCount": 42,
204
- "memoryCount": 5,
205
- "lastObsTimestamp": "2026-07-15T14:23:00Z",
206
- "foldersKnownToThisAgent": ["home/user/my-project"]
207
- }
208
- ```
209
-
210
- **Implementation Complexity:** **10 minutes**
211
- - Create new endpoint following existing Flask pattern (like `/health`)
212
- - Query existing KV methods for observation and memory counts
213
- - Return simple JSON response
214
-
215
- **Note:** This requires importing `StateKV` instance in new route file, which means either creating a module-scoped singleton per folder or passing the current `kv` from `app.py` via Flask's application context.
216
-
217
- ---
218
-
219
- ### 🎯 Feature 4: Observation Expiration / TTL (Time-To-Live)
220
-
221
- **Why Add This?**
222
- Temporal observations become outdated over time. Example: "Error on port 3000" observation becomes irrelevant after user changes their app to use port 8080. Currently all observations persist indefinitely. With TTL, expired observations can auto-remove from search results or be marked as "expired".
223
-
224
- **What to Implement:**
225
- ```python
226
- def folder_observe(kv, payload, ttl_seconds=None):
227
-
228
- # Store observation with expiration timestamp
229
- obs["expiryTs"] = ts + ttl_seconds if ttl_seconds else None
230
-
231
- return {
232
- "observationId": fobs_{hash}_{rand},
233
- "ttl": ttl_seconds or null, # New field
234
- ...
235
- }
236
- ```
237
-
238
- **Changes Required:**
239
- - Add `ttl_seconds` to observation payload validation (optional)
240
- - Store as additional timestamp field in KV value column
241
- - Modify `folder_timeline()` to filter out expired observations by default
242
- - Optional: Add background worker that sweeps/expunges expired observations
243
-
244
- **User Experience:**
245
- ```python
246
- # Observation expires after 24 hours
247
- folder_observe(
248
- kv, {
249
- "folderPath": "/home/user/app/src/server",
250
- "agentId": "my-agent",
251
- "text": "Default port is 3000 for development",
252
- "timestamp": now(),
253
- "ttl": 86400 # 24 hours
254
- }
255
- )
256
-
257
- # Timeline query automatically excludes expired observations
258
- timeline(kv, folder_path="/home/user/app/src/server")
259
- ```
260
-
261
- Returns timeline without "port 3000" observation after 24 hours. Users can also check for specific expiry status on an observation with additional endpoint `/folder/observation/status/<id>`.
262
-
263
- **Implementation Complexity:** **25 minutes**
264
- - Add TTL field to observation payload validation
265
- - Store as extra JSON field in KV (existing table schema)
266
- - Modify `folder_timeline()` query to include optional TTL filter:
267
- ```python
268
- ts > now() - ttl_seconds if ttl_seconds else None AND expiryTs > ts
269
- ```
270
- - Update search results to exclude expired observations
271
- - Optional: Background worker sweeps for cleanup (simpler version doesn't need this)
272
-
273
- **Risk:** Medium — requires changes to timeline query logic which users expect returns chronological activity. Must ensure backward compatibility with existing payloads that don't include TTL field (use `None` default).
274
-
275
- ---
276
-
277
- ### 🎯 Feature 5: Memory Version History
278
-
279
- **Why Add This?**
280
- Long-term memories evolve. Currently `remember()` just overwrites the old memory. Users might accidentally overwrite important information or can't undo an incorrect memory. With versioning, each remember creates a new version tracked sequentially.
281
-
282
- **What to Implement:**
283
- ```python
284
- def remember(kv, data, skip_versioning=False):
285
-
286
- # Check existing memories for this content
287
- existing_memories = kv.get(KV.memories, "mem_abc123")
288
-
289
- if not skip_versioning and existing_memories:
290
- # Append version suffix to old content (preserve as text)
291
- current_content = json.loads(existing_memories["value"])
292
- current_content["_version"] = len(current_content.get("_versions", [])) + 1
293
- current_content["_createdTs"] = existing_memories["ts"]
294
-
295
- # Store in new version field
296
- versions = current_content.get("_versions", [])
297
- current_content["_versions"].append({
298
- "content": current_content["content"],
299
- "version": len(versions),
300
- "ts": now(),
301
- ...
302
- })
303
-
304
- return {
305
- "memoryId": new_id,
306
- "versions": [...], # New field: list of version history
307
- ...
308
- }
309
- ```
310
-
311
- **Changes Required:**
312
- - Modify `remember()` to check for existing content match in KV memories
313
- - Append new version as JSON object to version history array
314
- - Store version number and timestamp for each version change
315
- - Optionally expose version history endpoint for viewing past versions
316
-
317
- **User Experience:**
318
- When a user calls:
319
- ```python
320
- remember(
321
- kv, {
322
- "content": "JWT authentication uses bearer token in Authorization header",
323
- "concepts": ["jwt", "auth"],
324
- ...
325
- }
326
- )
327
- ```
328
-
329
- The response includes version history showing how this memory has evolved over time. Later, if the user discovers more context:
330
- ```python
331
- remember(
332
- kv, {
333
- "content": "JWT authentication uses Bearer token and JWT_SECRET key in Authorization header",
334
- ...
335
- }
336
- )
337
- ```
338
-
339
- They can review past versions to see the evolution or optionally revert to earlier version by storing it again.
340
-
341
- **Implementation Complexity:** **20 minutes**
342
- - Modify `remember()` to detect duplicate content (hash match on content field)
343
- - Store version history as JSON array in KV value column (existing table schema, just more data)
344
- - Optionally create endpoint `/memory/version/<id>` for viewing history
345
- - Update tests to verify version history is stored correctly
346
-
347
- **Risk:** Low — simple append operation to existing data structure. No schema migration needed since we're adding fields to existing JSON values. Backward compatible since previous versions without `_versions` field just get overwritten (which may be surprising behavior, but acceptable for safety).
348
-
349
- ---
350
-
351
- ### 🎯 Feature 6: Search Result Citation with Source Links
352
-
353
- **Why Add This?**
354
- When a memory is returned from search, users can see where the original observation came from and what code context had it observed. This helps understand which files are most relevant to certain topics and provides better "view in context" capability for follow-up actions.
355
-
356
- **What to Implement:**
357
- ```python
358
- def folder_observe(kv, payload):
359
- # Store source file info
360
- if payload.get("sourceFile"):
361
- obs["sourceFile"] = payload["sourceFile"]
362
- obs["lineNumber"] = payload.get("lineNumber") or None
363
-
364
- return {
365
- "observationId": fobs_{hash}_{rand},
366
- "sourceFile": "src/auth.py", # New field: where this came from
367
- ...
368
- }
369
- ```
370
-
371
- **Search Result Enhancement:**
372
- Modify search result response format:
373
- ```python
374
- def folder_search(kv, query, limit, folder_path, agent_id):
375
-
376
- results = [
377
- {
378
- "id": obs_id,
379
- "text": "...",
380
- "folderPath": "/home/user/project",
381
- "score": 0.85, # Original BM25 score or vector similarity
382
- "sourceFile": "src/auth.py", # NEW: where this came from
383
- "timestamp": ts.isoformat(),
384
- ...
385
- }
386
- ]
387
- ```
388
-
389
- **User Experience:**
390
- Search query: "JWT authentication"
391
- Results now show source file links:
392
- ```json
393
- [
394
- {
395
- "id": "fobs_abc123",
396
- "text": "JWT needs refresh tokens for token rotation",
397
- "sourceFile": "src/auth.py", // Click link to see code context!
398
- "score": 0.92,
399
- ...
400
- },
401
- {
402
- "id": "fobs_def456",
403
- "text": "Using 'jwt' import from auth package",
404
- "sourceFile": "src/main.py", // Another file
405
- "score": 0.78,
406
- ...
407
- }
408
- ]
409
- ```
410
-
411
- **Implementation Complexity:** **20 minutes**
412
- - Add `source_file` field to observation schema (same as Feature 2)
413
- - Update search result formatting in `folder_search()` to include source file info from observations
414
- - Optionally: Show which files are most-relevant based on sources of highest-scoring memories
415
-
416
- **Risk:** Low — just need to read the new field from observations and format it in search results. No complex data structure change needed.
417
-
418
- ---
419
-
420
- ### 🎯 Feature 7: Memory Impact / Related Memories Endpoint
421
-
422
- **Why Add This?**
423
- When a user remembers something important, they might want to know which other memories relate semantically or contextually. Currently all memories exist independently with no explicit linking mechanism. Adding semantic similarity scores helps users understand how new memories connect to existing knowledge and spot conflicts.
424
-
425
- **What to Implement:**
426
- ```python
427
- def memory_related(kv, memory_id):
428
-
429
- # Get original memory content from KV
430
- original_memory = kv.get(KV.memories, memory_id)
431
- original_content = json.loads(original_memory["value"])
432
-
433
- # Search for semantically similar memories
434
- search_results = hybrid_search.search(
435
- query=original_content["content"],
436
- limit=5, # Return top 5 related memories
437
- filter_scope=[KV.memories], # Only search within memories scope
438
- )
439
-
440
- # Score by similarity + rank in results list
441
- return {
442
- "memoryId": memory_id,
443
- "relatedMemories": [
444
- {
445
- "id": "mem_abc123",
446
- "score": 0.92, # Semantic similarity score (0-1)
447
- "reason": "Same concepts: JWT, authentication",
448
- ...
449
- },
450
- ...
451
- ]
452
- }
453
- ```
454
-
455
- **User Experience:**
456
- Request: `/agentcache/memories/related/mem_xyz123`
457
- Response shows how this memory connects to existing knowledge:
458
- ```json
459
- {
460
- "memoryId": "mem_xyz123",
461
- "relatedMemories": [
462
- {
463
- "id": "mem_abc456",
464
- "score": 0.94,
465
- "reason": "Same concepts (JWT) and file context (src/auth.py)",
466
- "content": "JWT uses Bearer token format in Authorization header"
467
- },
468
- {
469
- "id": "mem_def789",
470
- "score": 0.78,
471
- "reason": "Related to auth module but different concepts",
472
- "content": "Using Express.js for REST API development"
473
- }
474
- ],
475
- ...
476
- }
477
- ```
478
-
479
- **Implementation Complexity:** **30 minutes**
480
- - Use existing `HybridSearch.search()` method with original memory content as query
481
- - Score by rank in results (1st highest = most related) + cosine similarity score
482
- - Format response as JSON with reason descriptions generated from concept extraction
483
- - Create new endpoint that takes memory ID and returns related items
484
-
485
- **Risk:** Medium — requires leveraging existing search infrastructure. Must ensure the semantic search is fast enough (< 50ms response time). Also need to handle empty or non-existent memories gracefully (return helpful error).
486
-
487
- ---
488
-
489
- ## Recommendation Priority
490
-
491
- As a user who relies on this tool daily for code context and observation management, here's my prioritization based on "bang for buck" — quick implementation with high utility:
492
-
493
- ### **Priority 1 (Implement First): Observation Weighting**
494
-
495
- **Why #1:** Fastest to implement (~10 min), highest immediate value
496
- - Let me tag observations as priority 90-100 and have them surface prominently in search results
497
- - No new data structures needed; just add one number to the existing weighting formula
498
- - Users already write some observations as "important issues" but they're weighted same as trivial notes
499
-
500
- **Implementation:**
501
- ```python
502
- # New payload validation
503
- def folder_observe(kv, payload, priority=0):
504
- # Validate priority is 0-100 range
505
- if not (0 <= priority <= 100):
506
- raise ValueError("priority must be between 0 and 100")
507
- ```
508
-
509
- **Time:** ~10 min
510
- **Risk:** None — modifies existing RRF function slightly
511
-
512
- ---
513
-
514
- ### **Priority 2: Folder Statistics Endpoint**
515
-
516
- **Why #2:** Simplest implementation with high utility for daily users
517
- - Users constantly need this info but it's not easily available via API calls
518
- - Just needs a few more lines of code following Flask pattern
519
- - Query existing data without any schema changes
520
-
521
- **Implementation:**
522
- ```python
523
- @app.route('/folder/stats/<path:folder_path>')
524
- def folder_stats():
525
- # ~5 min implementation
526
- ```
527
-
528
- **Time:** ~5 min
529
- **Risk:** None — new endpoint, minimal queries
530
-
531
- ---
532
-
533
- ### **Priority 3: Observation Source Tracking**
534
-
535
- **Why #3:** Low risk, very useful for detecting patterns
536
- - Track which files user has observed about certain topics helps detect learning cycles
537
- - One extra field in KV value dict — no schema changes
538
- - Helps spot when user re-implements same code after reading tutorial
539
-
540
- **Implementation:**
541
- ```python
542
- def folder_observe(kv, payload, source_file=None):
543
- # ~10 min implementation
544
- ```
545
-
546
- **Time:** ~15 min
547
- **Risk:** Low — one optional field addition
548
-
549
- ---
550
-
551
- ### **Priority 4: Memory Version History**
552
-
553
- **Why #4:** Good safety feature, relatively simple to implement
554
- - Prevents accidental data loss
555
- - Version history array in JSON value column is trivial to add
556
- - Users love being able to see evolution of memories they've written
557
-
558
- **Implementation:**
559
- ```python
560
- def remember(kv, data):
561
- # ~15 min implementation
562
- ```
563
-
564
- **Time:** ~20 min
565
- **Risk:** Low — append operation, no schema changes
566
-
567
- ---
568
-
569
- ## Summary
570
-
571
- | Feature | Est. Time | Risk Level | User Impact |
572
- |---------|-----------|------------|-------------|
573
- | Observation Weighting | 10 min | None | High (control over search ranking) |
574
- | Folder Stats Endpoint | 5 min | None | High (quick stats access) |
575
- | Source Tracking | 15 min | Low | Medium (detect patterns) |
576
- | Memory Versioning | 20 min | Low | Medium (safety feature) |
577
-
578
- All four fit seamlessly into existing Flask/SQLite architecture without requiring any architectural changes or new dependencies. They leverage current infrastructure and enhance the user experience incrementally.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
UBIQUITOUS_LANGUAGE.md DELETED
@@ -1,166 +0,0 @@
1
- # Ubiquitous Language — agentcache
2
-
3
- > This glossary defines the canonical terms used in agentcache's domain model.
4
- > Use these exact names in code, docs, PR descriptions, ticket titles, and conversations.
5
- > "Aliases to avoid" lists terms found in the codebase or tickets that should be replaced.
6
- > Last updated: July 2026 — incorporates architecture review, ubiquitous language session, and ticket breakdown.
7
- >
8
- > **Architecture improvement tickets:** `.scratch/arch-improvements/issues/`
9
-
10
- ---
11
-
12
- ## Core Memory Model
13
-
14
- | Term | Definition | Aliases to avoid |
15
- |------|------------|-----------------|
16
- | **Observation** | A single captured event from an agent's execution — one tool call, one prompt, one file edit — scoped to a Folder Pair. The atomic unit of Working Memory. | `log`, `event`, `entry`, `raw_observation`, `hook event` |
17
- | **Memory** | A manually saved, long-term insight, decision, or pattern — not derived from a single tool call but from deliberate agent reflection. | `long-term memory`, `global memory`, `insight`, `fact` (when used alone) |
18
- | **Lesson** | A reusable learning with a confidence score that decays over time; strengthened when the same pattern recurs. | `learning`, `tip`, `rule` |
19
- | **Slot** | A named, pinned piece of context — manually set or auto-populated — injected into every session start. | `pinned slot`, `memory slot`, `context slot` |
20
- | **Folder Pair** | The primary scope key: the combination of a `folderPath` and an `agentId` that uniquely identifies one agent's memory for one project directory. | `(folder, agent)`, `folder-agent pair`, `scope key`, `session` (when used to mean this) |
21
- | **Folder Metadata** | Aggregate statistics for a Folder Pair: observation count, last updated timestamp, and optional summary. | `folder meta`, `FolderMeta` |
22
-
23
- ---
24
-
25
- ## Memory Tiers (Consolidation Pipeline)
26
-
27
- | Term | Definition | Aliases to avoid |
28
- |------|------------|-----------------|
29
- | **Working Memory** | The live, unprocessed stream of Observations for a Folder Pair — raw and ephemeral. | `raw observations`, `session logs` |
30
- | **Episodic Memory** | A compressed summary of a group of Observations for a Folder Pair, produced by the Consolidation pipeline. | `session summary`, `compressed episode`, `narrative` |
31
- | **Semantic Memory** | Stable factual knowledge extracted from multiple Episodic Memories by the Consolidation pipeline. | `fact`, `knowledge`, `semantic fact` |
32
- | **Procedural Memory** | A reusable workflow or decision pattern extracted from repeated cross-session patterns. | `procedure`, `workflow memory`, `pattern` (when used alone) |
33
- | **Consolidation** | The LLM-driven pipeline that compresses Working Memory → Episodic → Semantic → Procedural. Triggered manually or by the auto-forget sweep. | `crystallize`, `compress`, `summarize` |
34
-
35
- ---
36
-
37
- ## Agents & Identity
38
-
39
- | Term | Definition | Aliases to avoid |
40
- |------|------------|-----------------|
41
- | **Agent** | An AI coding assistant (Claude, Kiro, Cursor, Cline, etc.) that writes Observations and reads Memory. | `client`, `AI`, `bot` |
42
- | **Agent ID** | A string identity for one agent instance, used as the second key in a Folder Pair. | `agentId`, `agent_id`, `agent name` |
43
- | **Agent Scope** | The isolation boundary for an Agent's data — either `shared` (sees all agents' data) or `isolated` (sees only its own). | `scope isolation`, `agent namespace` |
44
- | **MCP Client** | Any tool (Cursor, Claude Desktop, Kiro) that communicates with agentcache using the Model Context Protocol. | `plugin`, `integration`, `agent client` |
45
-
46
- ---
47
-
48
- ## Search & Retrieval
49
-
50
- | Term | Definition | Aliases to avoid |
51
- |------|------------|-----------------|
52
- | **Recall** | A keyword-based search over Observations and Memories using the BM25 index. | `search`, `lookup`, `query` (when BM25 is implied) |
53
- | **Smart Search** | A hybrid search combining BM25 keyword matching and vector cosine similarity, fused by Reciprocal Rank Fusion (RRF). | `semantic search`, `hybrid search`, `vector search` |
54
- | **Folder Search** | A Recall or Smart Search scoped to one or more Folder Pairs. | `scoped search`, `project search` |
55
- | **Timeline** | A chronological, filterable feed of Observations for a Folder Pair. | `activity feed`, `history`, `replay feed` |
56
- | **Context Compilation** | The process of assembling Slots, Lessons, recent Episodic Memories, and a Profile into a single text block for agent injection at session start. | `context injection`, `context window prep`, `compile_context` |
57
-
58
- ---
59
-
60
- ## Lifecycle & Maintenance
61
-
62
- | Term | Definition | Aliases to avoid |
63
- |------|------------|-----------------|
64
- | **Auto-Forget** | A background sweep that evicts Observations past their TTL or above the per-Folder-Pair cap, optionally running Consolidation before eviction. | `auto_forget`, `TTL sweep`, `pruning`, `cleanup` |
65
- | **Deduplication** | Removal of Observations whose text fingerprint (SHA-256) matches an existing Observation in the same Folder Pair. | `dedup`, `duplicate removal` |
66
- | **Privacy Scrub** | The process of stripping secrets, tokens, and API keys from Observation text before storage, using a regex-based policy. | `redaction`, `sanitization`, `strip_private_data` |
67
- | **Index Rebuild** | A background process that reprocesses all stored Observations and Memories into a fresh BM25 and vector index. | `reindex`, `rebuild_index`, `warm-up` |
68
- | **Audit Entry** | An append-only record of every write operation, stored in the audit log with agent ID and timestamp. | `audit log`, `commit`, `version` (legacy Dolt term — avoid) |
69
-
70
- ---
71
-
72
- ## Knowledge Graph
73
-
74
- | Term | Definition | Aliases to avoid |
75
- |------|------------|-----------------|
76
- | **Relation** | A directed edge in the Knowledge Graph between two concepts, files, or Folder Pairs. | `graph edge`, `link`, `connection` |
77
- | **Knowledge Graph** | The set of Relations extracted from Observations, used to augment search retrieval with structural codebase topology. | `graph`, `concept graph`, `project graph` |
78
- | **Graph Extraction** | The LLM-driven process that reads Observations and produces Relations for the Knowledge Graph. | `graph build`, `relation extraction` |
79
-
80
- ---
81
-
82
- ## Architecture & Module Structure
83
-
84
- These terms describe the codebase's structural concepts, used in tickets, PRs, and architecture discussions.
85
-
86
- | Term | Definition | Aliases to avoid |
87
- |------|------------|-----------------|
88
- | **AppContext** | A single injectable dataclass that packages all runtime state (`kv`, `bm25`, `vector`, `embedder`, `broadcast`) — the replacement for module-level globals. Constructed once in `create_app()` and passed explicitly to every function that needs it. | `globals`, `module state`, `app state` |
89
- | **Deep Module** | A module with a narrow public interface that hides substantial implementation — the opposite of a shallow wrapper. The goal of every split in the god-module refactor. | `service`, `component`, `helper` |
90
- | **Adapter Seam** | The interface point where one concrete implementation can be swapped for another (e.g. `BaseVectorIndex` allows `InMemoryVectorIndex` to be replaced by an HNSW adapter). A seam becomes real once two concrete adapters exist. | `interface`, `abstraction layer`, `plugin point` |
91
- | **Expand–Contract** | The two-phase refactor pattern used for wide changes: first *expand* (add the new form alongside the old so CI stays green), then *contract* (delete the old form once all callers are migrated). | `big bang refactor`, `flag day`, `rewrite` |
92
- | **God Module** | An anti-pattern: a single module (`functions.py` at 4 583 lines) containing all domain logic, making it impossible to test any concern in isolation. Being eliminated via tickets 01–08. | `utils.py`, `helpers.py`, `core.py` (when used as a catch-all) |
93
- | **Auth Middleware** | A single `require_auth` decorator in `auth.py` that performs the timing-safe Bearer token check — the replacement for copy-pasted `_check_auth()` functions in every blueprint. | `_check_auth`, `auth function`, `bearer check` |
94
- | **MCP Tool Registry** | A `dict[str, Callable]` populated by `@register("tool_name")` decorators, replacing the 300-line `if/elif` dispatch chain in `routes/mcp.py`. | `tool dispatcher`, `elif chain`, `tool handler map` |
95
- | **Privacy Policy** | The documented, extensible set of regex patterns that defines what text is scrubbed before an Observation is stored. Lives in `privacy.py` as `DEFAULT_PATTERNS`. | `regex list`, `scrub rules`, `redaction rules` |
96
- | **Tracer Bullet** | A narrow, complete vertical slice of work that cuts through every layer (storage, logic, API, tests) and is demoable on its own. The unit of work in the ticket breakdown. | `task`, `story`, `sub-task` |
97
-
98
- ---
99
-
100
- ## Infrastructure & Sync
101
-
102
- | Term | Definition | Aliases to avoid |
103
- |------|------------|-----------------|
104
- | **Folder Path** | The absolute filesystem path of the working directory that scopes a Folder Pair. | `cwd`, `directory`, `project path` |
105
- | **KV Store** | The SQLite-backed key-value store that persists all domain data as JSON values keyed by `(scope, key)`. | `database`, `store`, `StateKV` |
106
- | **HF Sync** | The process of backing up the KV Store to a private HuggingFace dataset repo and restoring it on startup. | `sync`, `backup`, `dataset sync` |
107
- | **Audit High-Water Mark** | The `MAX(id)` of the audit log, used by HF Sync to detect whether any writes have occurred since the last backup. | `HWM`, `sync cursor`, `change marker` |
108
- | **Index Shard** | A chunk of the serialized BM25 or vector index stored in the KV Store for persistence across restarts. | `index chunk`, `bm25 shard`, `vector shard` |
109
-
110
- ---
111
-
112
- ## Relationships
113
-
114
- - An **Observation** belongs to exactly one **Folder Pair**.
115
- - A **Folder Pair** has exactly one **Folder Path** and exactly one **Agent ID**.
116
- - A **Folder Pair** accumulates many **Observations** and zero or one **Folder Metadata**.
117
- - **Consolidation** consumes **Observations** from a **Folder Pair** and produces **Episodic Memories**, which in turn feed **Semantic Memory** and **Procedural Memory**.
118
- - A **Lesson** exists globally — not scoped to a **Folder Pair**.
119
- - A **Slot** is scoped to either a project (matched by **Folder Path**) or global (all agents).
120
- - A **Memory** is global — not scoped to a **Folder Pair** — and may link to source **Observations** via `sourceObservationIds`.
121
- - **Recall** and **Smart Search** operate across all **Folder Pairs** (optionally filtered) and also include **Memories**.
122
- - **Context Compilation** assembles **Slots** + **Lessons** + **Episodic Memories** + **Profile** for one **Folder Pair** at session start.
123
- - An **AppContext** is constructed once per process and holds one **KV Store**, one BM25 index, one **Adapter Seam** for the vector index, one embedder, and one broadcast callable.
124
- - The **Auth Middleware** guards every route — the **MCP Tool Registry** handles dispatch after auth passes.
125
- - The **Privacy Policy** is applied to every **Observation** before it is written to the **KV Store** or the typed observations table.
126
-
127
- ---
128
-
129
- ## Flagged Ambiguities
130
-
131
- - **"session"** is used in two conflicting ways:
132
- 1. *Legacy* — a `Session` object with a `sessionId`, from the pre-folder model (now read-only, used only for migration).
133
- 2. *Informal* — an agent's working period within a Folder Pair.
134
- → Use **Folder Pair** for the scope concept and avoid "session" entirely in new code.
135
-
136
- - **"memory"** is used both as the general concept ("agent memory system") and as the specific entity (`Memory` — a saved insight).
137
- → In domain conversations, always qualify: **Working Memory**, **Episodic Memory**, **Semantic Memory**, **Procedural Memory**, or the entity **Memory** (capitalised).
138
-
139
- - **"crystallize" vs "consolidate"** — the codebase uses both for the same pipeline (LLM compression of Observations into higher-tier memories).
140
- → Canonical term: **Consolidation**. `crystallize` is an alias to retire.
141
-
142
- - **"recall" vs "search" vs "smart search"** — three terms for overlapping operations.
143
- → **Recall** = BM25 keyword search. **Smart Search** = hybrid BM25 + vector. **Folder Search** = either, scoped to a Folder Pair.
144
-
145
- - **"forget" vs "auto-forget" vs "evict"** — used interchangeably in code and docs.
146
- → **Forget** = deliberate deletion triggered by an agent. **Auto-Forget** = background TTL sweep. **Eviction** = the act of removing one Observation during Auto-Forget.
147
-
148
- ---
149
-
150
- ## Example Dialogue
151
-
152
- > **Dev:** "When an agent finishes a task, should it call `remember` or does the system handle that automatically?"
153
-
154
- > **Domain expert:** "Those are two different things. `remember` is for **Memories** — things the agent explicitly wants to preserve, like an architecture decision. The system automatically stores every tool call as an **Observation** in the **Folder Pair** via `folder_observe`. **Memories** are always deliberate."
155
-
156
- > **Dev:** "So if the agent never calls `remember`, does it lose everything?"
157
-
158
- > **Domain expert:** "No — the **Observations** are still there in **Working Memory** for that **Folder Pair**. But they're raw and noisy. **Consolidation** is what turns them into clean **Episodic Memories** that survive **Auto-Forget** eviction."
159
-
160
- > **Dev:** "What's the difference between a **Lesson** and a **Semantic Memory**?"
161
-
162
- > **Domain expert:** "A **Lesson** is something the agent explicitly learned and wants to reuse — it has a confidence score that decays. **Semantic Memory** is extracted automatically by the **Consolidation** pipeline from patterns across **Episodic Memories**. You save a **Lesson**; the system extracts **Semantic Memory**."
163
-
164
- > **Dev:** "And a **Slot** is different from both?"
165
-
166
- > **Domain expert:** "Yes. A **Slot** is pinned context — the agent or developer sets it manually and it gets injected at every session start via **Context Compilation**. Think of it as a sticky note, not a memory."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
agentcache.md DELETED
@@ -1,33 +0,0 @@
1
- # AgentCache Automation & Client Hook Roundabout
2
-
3
- This file documents the technical details and configurations for automating memory sessions, observations, and prompt-context syncing in environments that lack native client-side hook runners.
4
-
5
- ---
6
-
7
- ## 1. PowerShell-Level Console Hook Automation
8
- For standard command shells that do not have custom plugins (such as PowerShell), we have implemented a native console hook system directly in the user profile:
9
- * **Profile File**: `D:\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`
10
- * **Automation Mechanism**:
11
- 1. **Prompt Redefinition**: Overrides the default PowerShell `prompt` function to retrieve the last executed command from the session history (`Get-History`).
12
- 2. **Asynchronous Dispatch**: Uses PowerShell's `Start-Job` to send the command, execution status, and duration to the Hugging Face Space database (`https://yash030-agentcache-python.hf.space/agentcache/observe`) in the background, keeping terminal prompts lag-free.
13
- 3. **Interactive Shield**: Wraps the prompts and startup session creation in `if (-not [Console]::IsInputRedirected)` so background script executions or tool runners do not pollute the database.
14
- 4. **Active Session Reuse**: On console startup, checks for a cached session ID in `current_session.txt` and reuses it to prevent session clutter.
15
-
16
- ---
17
-
18
- ## 2. Antigravity Chat Sync Loop
19
- Because the Gemini Antigravity agent runs inside a transient prompt-response loop sandbox, we automate chat log syncing through a shell-level daemon job:
20
- * **Sync Script**: `C:\Users\yashw\.gemini\antigravity\sync_antigravity.py`
21
- * **Daemon Job**: Appended to the PowerShell profile as a background `Start-Job` loop named `AntigravitySync`.
22
- * **Execution Heuristic**:
23
- - The job runs a continuous loop that executes the sync script every 30 seconds.
24
- - Uses a lock file (`sync_antigravity.lock`) to ensure only a single terminal window runs the sync globally.
25
- - The script parses `transcript.jsonl` from the local `brain/` directory and uploads new user prompts and response turns to the Hugging Face Space under the session `antigravity_<conversation_id>`.
26
-
27
- ---
28
-
29
- ## 3. Configuration & Controls
30
- To control this automation inside PowerShell, use the following commands:
31
- * **`Start-MemorySession -project "name"`**: Starts a new memory session. Use the `-Force` switch to override any active session.
32
- * **`End-MemorySession`**: Ends the active session, marking it completed and cleaning up the local cache file.
33
- * **`Get-Job -Name "AntigravitySync"`**: Checks the status of the background chat sync thread.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
issues.md DELETED
@@ -1,273 +0,0 @@
1
- # Technical Issues, Bugs, & Architecture Audit: agentmemory-python
2
-
3
- This document details all technical anomalies, display bugs, synchronization issues, and functional mismatches discovered during the code audit of the `agentmemory-python` project.
4
-
5
- ---
6
-
7
- ## Category A: Syntax & Technical Code Correctness
8
-
9
- ### 1. SQLite Parameterization Syntax Error (`%s` vs `?`)
10
- * **File & Lines:** [src/functions.py:L411-429](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L411-L429) (within `IndexPersistence.save_sharded_index`)
11
- * **The Code:**
12
- ```python
13
- cursor.execute(
14
- "SELECT DISTINCT scope FROM kv_store WHERE scope LIKE %s",
15
- (scope_prefix + "%",)
16
- )
17
- ...
18
- format_strings = ','.join(['%s'] * len(chunk_delete))
19
- cursor.execute(
20
- f"DELETE FROM kv_store WHERE scope IN ({format_strings})",
21
- tuple(chunk_delete)
22
- )
23
- ```
24
- * **Root Cause:** The database backend uses standard Python `sqlite3`, which expects `?` placeholders for parameter injection. `%s` is specific to MySQL or PostgreSQL clients.
25
- * **Consequence:** Executing `save_sharded_index` throws a `sqlite3.OperationalError` every time it attempts to clean up old sharded indexes. This error is captured in a silent `try-except` block, meaning old shards are **never** deleted, leading to database bloat.
26
- * **Remediation:** Replace `%s` with `?` in both queries:
27
- ```python
28
- cursor.execute(
29
- "SELECT DISTINCT scope FROM kv_store WHERE scope LIKE ?",
30
- (scope_prefix + "%",)
31
- )
32
- ...
33
- format_strings = ','.join(['?'] * len(chunk_delete))
34
- ```
35
-
36
- ### 2. Thread Safety Write Locks Omitted
37
- * **File & Lines:** [src/db.py:L75-105](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/db.py#L75-L105) (within `StateKV.set` and `StateKV.delete`)
38
- * **The Code:** The `set()`, `delete()`, and `commit_version()` write methods execute queries and transactions directly on SQLite connections without acquiring `self._lock`. Only `update()` acquires the lock:
39
- ```python
40
- def update(self, scope: str, key: str, ops: List[Dict[str, Any]]) -> Optional[Any]:
41
- with self._lock:
42
- ...
43
- ```
44
- * **Root Cause:** SQLite operates database-level write serialization. In a multi-threaded Flask environment, two threads making concurrent database modifications (one inside `update` and another executing a basic `set` or `delete`) can cause a database race condition.
45
- * **Consequence:** Occasional `sqlite3.OperationalError: database is locked` exceptions, transaction rollbacks, or lost writes.
46
- * **Remediation:** Wrap the database write operations in `set()`, `delete()`, and `commit_version()` with `with self._lock:`.
47
-
48
- ### 3. Nonexistent Delete Memory API Endpoint Called
49
- * **File & Lines:** [src/viewer/index.html:L2813](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L2813) (within `confirmDeleteMemory`)
50
- * **The Code:**
51
- ```javascript
52
- await apiDelete('governance/memories', { memoryIds: [id], reason: 'Deleted via viewer' });
53
- ```
54
- * **Root Cause:** The backend [src/app.py](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/app.py) contains no `/agentmemory/governance/memories` endpoint. It processes deletions via a `POST` route at `/agentmemory/forget`, which expects a payload of `{"memoryId": "<id>"}`.
55
- * **Consequence:** The delete memory request fails with an HTTP 404 / 405 error, leaving memories undeletable from the UI.
56
- * **Remediation:** Update `confirmDeleteMemory` to call `apiPost` on the correct path and query structure:
57
- ```javascript
58
- await apiPost('forget', { memoryId: id });
59
- ```
60
-
61
- ### 4. Nonexistent Graph Modification Endpoints Called
62
- * **File & Lines:** [src/viewer/index.html:L2292](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L2292) and [L2404](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L2404)
63
- * **The Code:**
64
- ```javascript
65
- // L2292 (expanding neighbors)
66
- var result = await apiPost('graph/query', { startNodeId: nodeId, maxDepth: 1 });
67
- ...
68
- // L2404 (rebuilding graph)
69
- await apiPost('graph/build', {});
70
- ```
71
- * **Root Cause:** The backend lacks routes for `/graph/query` and `/graph/build`. It only implements a read-only endpoint `/agentmemory/graph/stats`.
72
- * **Consequence:** Interactive graph expansion and manual rebuilding fail with HTTP 404 errors in the console.
73
- * **Remediation:** Register endpoints `/agentmemory/graph/query` and `/agentmemory/graph/build` in `app.py` or remove these interactive buttons from the dashboard sidebar if they are not supported by the Python backend.
74
-
75
- ---
76
-
77
- ## Category B: Functional Alignment & Purpose Verification
78
-
79
- ### 1. Project-Scoped Memory Slots Collapsing into Global Scope
80
- * **File & Lines:** [src/functions.py:L1277](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L1277) (within `slot_create`) and [L1216](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L1216) (within `list_pinned_slots`)
81
- * **The Code:**
82
- ```python
83
- # L1277
84
- target_kv = KV.globalSlots if scope == "global" else KV.slots
85
- ...
86
- # L1216
87
- p_slots = kv.list(KV.slots)
88
- ```
89
- * **Root Cause:** The KV namespace for project-scoped slots is hardcoded as `KV.slots = "mem:slots"`. This is a single, shared global namespace for all projects.
90
- * **Consequence:** Project scoping is broken. Any project-scoped slot (e.g. `current_task` or `project_context`) is saved under the global `mem:slots` namespace. If Project A writes to `current_task`, it overwrites Project B's `current_task`. Furthermore, Project B inherits Project A's slots, violating intended project isolation boundaries.
91
- * **Remediation:** Derive the project slots database scope dynamically by incorporating the project ID or path name. For example:
92
- ```python
93
- # In functions.py, scope project slots by project name
94
- def project_slots_scope(project: str) -> str:
95
- return f"mem:slots:{project}"
96
- ```
97
- And update `slot_create`, `slot_append`, `slot_replace`, `slot_delete`, and `context` retrieval to pass the project name and use this dynamic scope prefix.
98
-
99
- ### 2. Aggressive Auto-Completion of Parallel Sessions
100
- * **File & Lines:** [src/functions.py:L117-131](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L117-L131) (within `auto_complete_old_active_sessions`)
101
- * **The Code:**
102
- ```python
103
- def auto_complete_old_active_sessions(kv: StateKV, current_session_id: str) -> int:
104
- sessions = kv.list(KV.sessions)
105
- count = 0
106
- for s in sessions:
107
- if s.get("id") != current_session_id and s.get("status") == "active":
108
- s["status"] = "completed"
109
- ...
110
- kv.set(KV.sessions, s["id"], s)
111
- ```
112
- * **Root Cause:** The system operates under the assumption that only one agent session can be active globally. Starting a session or recording an observation automatically marks all other active sessions as completed.
113
- * **Consequence:** If multiple workspaces, parallel subagents, or agents operate concurrently using the same backend, they force-close each other's sessions. Observations are then recorded against closed sessions, or new sessions are spawned, constantly closing others.
114
- * **Remediation:** Scour out the global session force-completion. Sessions should only be closed:
115
- - Explicitly via the `/session/end` endpoint
116
- - When matching the exact project or agent scope (e.g., only auto-complete active sessions belonging to the same project or the same `agentId`).
117
-
118
- ### 3. Agent Scoping Bypassed in MCP Tools
119
- * **File & Lines:** [src/app.py:L2200-2226](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/app.py#L2200-L2226) (within `memory_sessions` and `memory_observations` MCP handlers)
120
- * **The Code:** The REST routes respect `AGENTMEMORY_AGENT_SCOPE=isolated` to restrict session/observation lookups to the configured `agentId` (via `functions.is_agent_scope_isolated()`). However, the MCP tool handlers fetch data globally:
121
- ```python
122
- # L2206 - MCP memory_sessions handler
123
- sessions = functions.list_sessions(kv) # Fetches all sessions globally
124
- ```
125
- * **Root Cause:** The MCP dispatch logic calls the database list functions directly without checking or applying the agent isolation filters.
126
- * **Consequence:** An agent running in an isolated environment (`AGENTMEMORY_AGENT_SCOPE=isolated`) can query other agents' sessions and observations via the MCP tools, violating the promised security isolation boundary.
127
- * **Remediation:** Apply `is_agent_scope_isolated()` and `get_agent_id()` filters inside the MCP dispatcher cases for `memory_sessions` and `memory_observations`.
128
-
129
- ### 4. Telemetry Events and Gauges Legacy Debt
130
- * **File & Lines:** [src/viewer/index.html:L1596-1637](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L1596-L1637) (within `renderDashboard`)
131
- * **Root Cause:** The dashboard UI has gauge components for CPU, Heap memory, RSS memory, Event loop lag, and Circuit Breaker states, which are legacy features from the Node.js implementation. The Python Flask server returns a minimal hardcoded health structure:
132
- ```python
133
- # functions.py L2177
134
- return {
135
- "status": "healthy" if db_status == "connected" else "degraded",
136
- "service": "agentmemory",
137
- "version": "0.9.8",
138
- "database": "dolt", # Legacy name, database is actually sqlite
139
- "databaseStatus": db_status
140
- }
141
- ```
142
- * **Consequence:** The gauges show empty, fallback, or zero values in the dashboard. Additionally, the database type displays as `"dolt"`, which is legacy debt (the project is now SQLite).
143
- * **Remediation:**
144
- - Update `health_check` in [src/functions.py](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L2170) to return `"database": "sqlite"`.
145
- - To support the UI gauges, implement basic process metric collection in Python (e.g. using `os` or `resource` packages) to return CPU and Memory stats, or simplify the dashboard UI to omit Node-specific gauges.
146
-
147
- ---
148
-
149
- ## Category C: Real-Time Data Synchronization
150
-
151
- ### 1. Consolidated Memories Bypassing Search Indexes
152
- * **File & Lines:** [src/functions.py:L2512](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L2512) and [L2532](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L2532) (within `consolidate` memory saving loops)
153
- * **The Code:**
154
- ```python
155
- kv.set(KV.memories, evolved["id"], evolved)
156
- ...
157
- kv.set(KV.memories, memory["id"], memory)
158
- ```
159
- * **Root Cause:** When memories are merged or consolidated, they are saved directly to the SQLite database via `kv.set()`, but they are **never** added to the BM25 index (`_bm25_index.add()`) or the Vector index (`vector_index_add_guarded()`).
160
- * **Consequence:** Consolidated memories remain search-invisible. They are omitted from search results (`memory_recall`, `memory_smart_search`) and context compilation until the server is rebooted (rebooting forces index rebuild from the DB).
161
- * **Remediation:** Add indexing commands directly after saving the memory in `consolidate`:
162
- ```python
163
- # Index evolved memory
164
- try:
165
- _bm25_index.add(memory_to_observation(evolved))
166
- except Exception:
167
- pass
168
- comb_text = evolved["title"] + " " + evolved["content"]
169
- vector_index_add_guarded(evolved["id"], "memory", comb_text, {"kind": "memory", "logId": evolved["id"]})
170
- ```
171
- Repeat this for the newly created `memory` object on line 2532.
172
-
173
- ### 2. Raw Observations Overwritten by Compressed Observations
174
- * **File & Lines:** [src/functions.py:L719](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L719) and [L770](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/functions.py#L770) (within `observe`)
175
- * **The Code:**
176
- ```python
177
- # L719 - Save raw observation
178
- kv.set(KV.observations(session_id), obs_id, raw)
179
- ...
180
- # L770 - Overwrite with synthetic/compressed observation
181
- kv.set(KV.observations(session_id), obs_id, synthetic)
182
- ```
183
- * **Root Cause:** Both calls write to the exact same scope (`KV.observations(session_id)`) and key (`obs_id`).
184
- * **Consequence:** The raw observation is completely overwritten. The backend endpoints and APIs designed to fetch "raw" vs. "compressed" observations are redundant, as only the compressed version is stored (with raw inputs nested inside the `raw` field).
185
- * **Remediation:** Store raw observations under a separate database key or suffix (e.g. `f"{obs_id}:raw"`), or store them in a distinct scope (e.g. `KV.rawObservations(session_id)`).
186
-
187
- ---
188
-
189
- ## Category D: Frontend Page Connection & Tab Synchronization
190
-
191
- ### 1. Silent WebSocket Message Discard (Payload Shape Mismatch)
192
- * **File & Lines:** [src/viewer/index.html:L4130](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L4130) (within `ws.onmessage` event listener)
193
- * **The Code:**
194
- ```javascript
195
- ws.onmessage = function(e) {
196
- if (state.ws !== ws) return;
197
- try {
198
- var msg = JSON.parse(e.data);
199
- if (msg.type === 'stream' && msg.event) {
200
- handleStreamEvent(msg);
201
- } else if (msg.event_type && msg.data) {
202
- handleStreamEvent({ event: { type: 'create', data: msg.data, event_type: msg.event_type } });
203
- }
204
- } catch {}
205
- };
206
- ```
207
- * **Root Cause:** The Python backend broadcasts observations in the following structure:
208
- - `{"type": "raw_observation", "sessionId": ..., "data": {"type": "raw", "observation": {...}}}`
209
- - `{"type": "compressed_observation", "sessionId": ..., "data": {"type": "compressed", "observation": {...}}}`
210
- Neither has `msg.type === 'stream'` or `msg.event_type`.
211
- * **Consequence:** The WebSocket parser silently ignores all server-sent broadcasts. Real-time logging of new observations or commands is broken.
212
- * **Remediation:** Add handlers for Python's `raw_observation` and `compressed_observation` messages:
213
- ```javascript
214
- if (msg.type === 'raw_observation' || msg.type === 'compressed_observation') {
215
- if (msg.data && msg.data.observation) {
216
- routeWsMessage({ observation: msg.data.observation });
217
- }
218
- } else if (msg.type === 'stream' && msg.event) {
219
- ...
220
- ```
221
-
222
- ### 2. WebSocket Connection Disabling Fallback Polling
223
- * **File & Lines:** [src/viewer/index.html:L4125](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L4125) (within `ws.onopen`)
224
- * **Root Cause:** When the WebSocket connection succeeds, the frontend calls `stopPolling()`.
225
- * **Consequence:** Because WebSocket events are silently discarded due to the payload mismatch, and polling is stopped, the dashboard ceases to update at all once the WebSocket is connected. The UI remains completely frozen.
226
- * **Remediation:** Fixing the WebSocket event parsing (Issue D1) will restore live updates. Additionally, if the WebSocket disconnects, the polling mechanism must be correctly re-triggered.
227
-
228
- ### 3. Cached Pages/Tabs Preventing Sync on Navigation
229
- * **File & Lines:** [src/viewer/index.html:L1502-1518](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L1502-1518) (within `loadTab`)
230
- * **The Code:**
231
- ```javascript
232
- async function loadTab(tab) {
233
- switch(tab) {
234
- case 'dashboard': if (!state.dashboard.loaded) await loadDashboard(); break;
235
- case 'graph': if (!state.graph.loaded) await loadGraph(); break;
236
- case 'memories': if (!state.memories.loaded) await loadMemories(); break;
237
- ...
238
- }
239
- }
240
- ```
241
- * **Root Cause:** A tab's data is only fetched the first time it is visited (when `.loaded` is `false`).
242
- * **Consequence:** Switching between tabs (e.g. from Dashboard to Sessions or Memories) displays stale cached data. The user has to hit the browser refresh button to see updates.
243
- * **Remediation:** Force data reload when a tab is clicked, or provide a visual indicator and auto-refresh trigger when switching tabs:
244
- ```javascript
245
- // Always load fresh data on switch, or reset the loaded flag
246
- async function loadTab(tab) {
247
- switch(tab) {
248
- case 'dashboard': await loadDashboard(); break;
249
- case 'graph': await loadGraph(); break;
250
- case 'memories': await loadMemories(); break;
251
- ...
252
- }
253
- }
254
- ```
255
-
256
- ### 4. Flat Project Name Skipping in Graph Construction
257
- * **File & Lines:** [src/viewer/index.html:L1871](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L1871) and [L1893](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/viewer/index.html#L1893) (within `loadGraph`)
258
- * **The Code:**
259
- ```javascript
260
- if (!path.includes('/') && !path.includes('\\')) return;
261
- ```
262
- * **Root Cause:** The graph builder ignores any session/memory whose project path does not contain a slash or backslash.
263
- * **Consequence:** If project names are stored as simple strings (e.g. `agentmemory-python` or `demo_project` rather than absolute directories), they are omitted from the graph, rendering the Graph tab entirely empty (0 nodes, 0 edges).
264
- * **Remediation:** Remove the slash-enforcement condition so any non-empty project name is rendered:
265
- ```javascript
266
- // Remove: if (!path.includes('/') && !path.includes('\\')) return;
267
- ```
268
-
269
- ### 5. Empty Graph Nodes Card on Dashboard
270
- * **File & Lines:** [src/app.py:L990-996](file:///d:/Downloads/Projects/Other%20Projects/agentmemory-python/src/app.py#L990-L996) (within `api_graph_stats`)
271
- * **Root Cause:** The Dashboard tab's "Graph Nodes" card displays stats queried from the backend `/graph/stats` endpoint. The backend queries `kv.list(KV.graphNodes)` and `kv.list(KV.graphEdges)`. However, the Python backend never writes to these scopes.
272
- * **Consequence:** The "Graph Nodes" card always displays `0` even when the Graph tab successfully visualizes active sessions and folders.
273
- * **Remediation:** Calculate these stats dynamically in `api_graph_stats` based on the counts of active unique project paths in the sessions and memories lists, matching the client-side folder map logic.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
product_roadmap.md DELETED
@@ -1,39 +0,0 @@
1
- # Project Roadmap: Prototype to Production
2
-
3
- This document outlines the phased roadmap for scaling our Memory Server project from a prototype to a robust, production-ready product. Each phase builds upon the last, focusing sequentially on Security, Features, Deployment, and Monitoring.
4
-
5
- ## Phase 1: Stabilization & Hardening (Security First)
6
- **Goal:** Eliminate critical vulnerabilities, patch security gaps, and ensure core functionality is robust against common exploits.
7
-
8
- ### Tasks
9
- 1. **Security Audit**: Review all authentication logic (`AGENTCACHE_SECRET` usage) across API endpoints to enforce strict access control checks.
10
- 2. **Input Sanitization**: Implement rigorous input sanitization for all data ingress points (API calls, WebSocket messages) to mitigate SQL injection and XSS risks.
11
- 3. **Dependency Hardening**: Audit `requirements.txt` and update all dependencies to their latest secure versions, flagging any version downgrade/upgrade that could introduce a vulnerability.
12
- 4. **Test Baseline**: Run full test suite (`pytest`) and fix every failing test before moving to Phase 2.
13
-
14
- ## Phase 2: Feature Parity & Depth
15
- **Goal:** Implement all planned features that were marked as incomplete or missing, bringing the system closer to its intended scope.
16
-
17
- ### Tasks
18
- 1. **Memory Deep Dive**: Fully implement complex memory routines like `folder_graph_build` and ensure atomic behavior for `remember`/`forget` operations.
19
- 2. **Search Optimization**: Optimize the hybrid search component (RRF parameters) and profile database queries to improve retrieval performance.
20
- 3. **MCP Tool Completion**: Complete functionality for all remaining tools listed in `/mcp/tools`.
21
- 4. **UX Polish**: Enhance the dashboard viewer (`/viewer`) to provide clear, actionable feedback on system status (e.g., current embedding model, load metrics).
22
-
23
- ## Phase 3: Productionization & Deployment
24
- **Goal:** Prepare the application for a stable, scalable production environment.
25
-
26
- ### Tasks
27
- 1. **Containerization**: Write optimized Dockerfiles for the Flask application and dependencies to ensure environment parity across environments.
28
- 2. **Configuration Decoupling**: Refactor configuration loading to strictly adhere to container-native practices (using ENV variables exclusively) rather than relying on local `.env` file structures for production use.
29
- 3. **Performance Tuning**: Conduct load testing to identify I/O bottlenecks (DB access, network latency). Tune database indices and optimize WebSocket message throughput.
30
- 4. **Scalability Design**: Analyze the statelessness of components to determine optimal strategies for horizontal scaling (e.g., separate API workers vs. WebSocket workers).
31
-
32
- ## Phase 4: Monitoring & Iteration (Live Operations)
33
- **Goal:** Establish continuous monitoring and a feedback loop for post-launch maintenance.
34
-
35
- ### Tasks
36
- 1. **Observability Stack**: Implement structured logging across all modules to facilitate easy debugging in production.
37
- 2. **Metrics Collection**: Integrate Prometheus metrics collection for tracking latency, resource utilization, and error rates.
38
- 3. **Anomaly Detection**: Configure alerts for performance degradation or excessive error rates in the data access layer.
39
- 4. **Feedback Mechanism**: Design and implement a simple feedback mechanism for collecting post-launch bug reports and feature requests.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
questions.md DELETED
@@ -1,176 +0,0 @@
1
- # Architectural Questions for agentcache
2
-
3
- These are design and architecture questions raised by the current codebase.
4
- They are not criticisms — they are things worth understanding and deciding on
5
- before the system grows. Each one points to a real trade-off or risk.
6
-
7
- ---
8
-
9
- ## 1. Flat KV Schema
10
-
11
- The entire data model lives in one SQLite table: `kv_store(scope, key, value TEXT)`.
12
- Observations, memories, index shards, sessions, lessons, slots, graph edges, and
13
- image refs all share this single namespace.
14
-
15
- - What happens to read performance when this table grows to 100k+ rows?
16
- - Every "query" loads an entire scope into Python and filters in memory — no
17
- SQL-level filtering by timestamp, type, or importance. Is that intentional?
18
- - Why not give each data type its own table with typed columns, which would
19
- enable proper indexes and range queries at the DB level?
20
-
21
- ---
22
-
23
- ## 2. In-Memory Index with a Cold-Start Window
24
-
25
- The BM25 and vector indexes live entirely in Python process memory. On restart,
26
- the server either deserializes them from SQLite or rebuilds them from scratch in
27
- a background thread.
28
-
29
- - During the rebuild window, searches return results from an empty or stale
30
- index. Users get silently degraded results with no indication.
31
- - Is there a "index warming" status exposed anywhere? The `/health` endpoint
32
- could surface this, but does it?
33
- - For large datasets, how long does the rebuild take? Is there a bound on that?
34
-
35
- ---
36
-
37
- ## 3. Vector Index is a Flat Python List
38
-
39
- `VectorIndex.search()` iterates over every stored vector and computes cosine
40
- similarity one by one. This is O(n) per query.
41
-
42
- - At 10k observations this is already slow. At 100k it is unusable.
43
- - There is no ANN (approximate nearest neighbor) index — no HNSW, no IVF, no
44
- external vector DB.
45
- - The EPIC mentions Qdrant/Chroma as future backends. What is the plan and
46
- threshold for switching?
47
-
48
- ---
49
-
50
- ## 4. Single Auth Token (No RBAC)
51
-
52
- Authentication is one shared secret compared with `hmac.compare_digest`. Every
53
- client — viewer, agent, admin — uses the same token.
54
-
55
- - If the token leaks from one agent config, everything is exposed.
56
- - The viewer dashboard, the `/forget` endpoint (which can delete all data), and
57
- the `/migrate` endpoint all share the same credential level.
58
- - The EPIC mentions RBAC (viewer/agent/admin tokens). Is there a plan to
59
- implement this before exposing the server to a network?
60
-
61
- ---
62
-
63
- ## 5. Global Module-Level State
64
-
65
- `functions.py` declares `_bm25_index`, `_vector_index`, `_embedding_provider`,
66
- `_hybrid_search`, and `_stream_broadcaster` as module-level globals. They are
67
- set once at startup and mutated by every request.
68
-
69
- - This makes the application impossible to unit test in isolation (you cannot
70
- inject a fresh index per test).
71
- - It also makes it impossible to run two instances in the same process (e.g.
72
- for testing).
73
- - Was this a deliberate simplicity trade-off, or just how it grew?
74
-
75
- ---
76
-
77
- ## 6. No Rate Limiting or Input Size Caps on Most Endpoints
78
-
79
- Observations are capped at 4000 characters. But memories, lessons, slots, and
80
- graph edges have no enforced size limits. The `/agent/observe` endpoint accepts
81
- arbitrary JSON payloads.
82
-
83
- - A misbehaving or compromised agent could flood the server with gigabytes of
84
- data and exhaust disk space.
85
- - There is no per-agent write rate limit, no total storage quota, and no
86
- backpressure mechanism.
87
- - Is this acceptable for the current single-user local use case? What changes
88
- if this is exposed as a shared service?
89
-
90
- ---
91
-
92
- ## 7. HuggingFace Sync Backs Up the Entire SQLite File
93
-
94
- `sync.py` uploads the whole `agentcache.db` file to a HuggingFace dataset repo,
95
- including the BM25/vector index shards stored inside it.
96
-
97
- - The index shards can be large and are fully reproducible from raw observations.
98
- Syncing them wastes bandwidth and storage.
99
- - The backup is not incremental — it uploads the whole file every time the
100
- audit high-water mark changes.
101
- - If the HF token is compromised, all user memory data (observations, memories,
102
- lessons) is exposed. Is that risk documented anywhere for users?
103
-
104
- ---
105
-
106
- ## 8. `functions.py` is ~2000 Lines — a God Module
107
-
108
- All business logic lives in one file: observation ingestion, memory CRUD,
109
- search orchestration, consolidation, auto-forget, graph building, slot
110
- management, lessons, image store, index persistence, and privacy scrubbing.
111
-
112
- - This makes it hard to test any single concern in isolation.
113
- - It creates implicit coupling — a change to how observations are stored can
114
- accidentally affect how the index is rebuilt or how memories are versioned.
115
- - What would it look like to split this into focused modules
116
- (e.g. `observations.py`, `memories.py`, `indexing.py`, `consolidation.py`)?
117
-
118
- ---
119
-
120
- ## 9. Jaccard Similarity for Memory Deduplication
121
-
122
- `remember()` checks for duplicate memories by computing Jaccard similarity
123
- (word overlap) between the new content and all existing memories, with a
124
- threshold of 0.7.
125
-
126
- - This loads all memories into Python memory on every `remember()` call.
127
- - Jaccard on raw word sets is a weak signal for semantic similarity — two
128
- memories about the same concept but phrased differently score low and
129
- both get stored.
130
- - With a vector embedding provider active, why not use cosine similarity
131
- against the vector index for deduplication instead?
132
-
133
- ---
134
-
135
- ## 10. The MCP Endpoint Duplicates Auth and Dispatch Logic
136
-
137
- `routes/mcp.py` has its own `_check_auth()` function, its own `_get_kv()` helper,
138
- and a large `if/elif` chain dispatching 30+ tool names. The same auth logic
139
- exists in other route blueprints too.
140
-
141
- - Auth is copy-pasted across at least 3 places. A future change (e.g. adding
142
- RBAC) would require updating each copy.
143
- - The tool dispatch chain has no registry — adding a new tool requires editing
144
- a long elif block rather than registering a handler.
145
- - Was there a reason not to use a decorator-based dispatch registry or a shared
146
- auth middleware?
147
-
148
- ---
149
-
150
- ## 11. Privacy Scrubbing is a Regex List — Not a Policy
151
-
152
- `strip_private_data()` removes secrets by matching a hardcoded list of regex
153
- patterns (API keys, tokens, passwords). It runs on raw observation text before
154
- storage.
155
-
156
- - If an agent logs a secret with an unusual key name (e.g. `my_service_cred`),
157
- it passes through unredacted.
158
- - The scrubbing happens *after* the data is already in the Python process —
159
- if the process crashes mid-scrub, the raw data may already be partially
160
- visible in a WAL frame.
161
- - Is the current regex set documented so users can audit and extend it?
162
-
163
- ---
164
-
165
- ## 12. No Tests
166
-
167
- The `tests/` directory appears to be empty or minimal. For a system that
168
- persists agent memory and is used as a source of truth for AI context:
169
-
170
- - How do you verify that `folder_search` returns the right results after an
171
- observation is added and the index is updated?
172
- - How do you catch regressions in privacy scrubbing when you add a new pattern?
173
- - How do you verify that the HF sync does not upload stale data after a
174
- failed WAL checkpoint?
175
- - What is the plan for adding test coverage before the system is used in
176
- production or shared with other developers?