agent-working-memory 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +428 -399
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +60 -5
- package/dist/api/routes.js.map +1 -1
- package/dist/cli.js +468 -68
- package/dist/cli.js.map +1 -1
- package/dist/coordination/index.d.ts +11 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +39 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/mcp-tools.d.ts +8 -0
- package/dist/coordination/mcp-tools.d.ts.map +1 -0
- package/dist/coordination/mcp-tools.js +221 -0
- package/dist/coordination/mcp-tools.js.map +1 -0
- package/dist/coordination/routes.d.ts +9 -0
- package/dist/coordination/routes.d.ts.map +1 -0
- package/dist/coordination/routes.js +573 -0
- package/dist/coordination/routes.js.map +1 -0
- package/dist/coordination/schema.d.ts +12 -0
- package/dist/coordination/schema.d.ts.map +1 -0
- package/dist/coordination/schema.js +125 -0
- package/dist/coordination/schema.js.map +1 -0
- package/dist/coordination/schemas.d.ts +227 -0
- package/dist/coordination/schemas.d.ts.map +1 -0
- package/dist/coordination/schemas.js +125 -0
- package/dist/coordination/schemas.js.map +1 -0
- package/dist/coordination/stale.d.ts +27 -0
- package/dist/coordination/stale.d.ts.map +1 -0
- package/dist/coordination/stale.js +58 -0
- package/dist/coordination/stale.js.map +1 -0
- package/dist/engine/activation.d.ts.map +1 -1
- package/dist/engine/activation.js +119 -23
- package/dist/engine/activation.js.map +1 -1
- package/dist/engine/consolidation.d.ts.map +1 -1
- package/dist/engine/consolidation.js +27 -6
- package/dist/engine/consolidation.js.map +1 -1
- package/dist/index.js +100 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +149 -80
- package/dist/mcp.js.map +1 -1
- package/dist/storage/sqlite.d.ts +21 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +331 -282
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/types/engram.d.ts +24 -0
- package/dist/types/engram.d.ts.map +1 -1
- package/dist/types/engram.js.map +1 -1
- package/package.json +57 -55
- package/src/api/index.ts +3 -3
- package/src/api/routes.ts +600 -536
- package/src/cli.ts +850 -397
- package/src/coordination/index.ts +47 -0
- package/src/coordination/mcp-tools.ts +318 -0
- package/src/coordination/routes.ts +846 -0
- package/src/coordination/schema.ts +120 -0
- package/src/coordination/schemas.ts +155 -0
- package/src/coordination/stale.ts +97 -0
- package/src/core/decay.ts +63 -63
- package/src/core/embeddings.ts +88 -88
- package/src/core/hebbian.ts +93 -93
- package/src/core/index.ts +5 -5
- package/src/core/logger.ts +36 -36
- package/src/core/query-expander.ts +66 -66
- package/src/core/reranker.ts +101 -101
- package/src/engine/activation.ts +758 -656
- package/src/engine/connections.ts +103 -103
- package/src/engine/consolidation-scheduler.ts +125 -125
- package/src/engine/consolidation.ts +29 -6
- package/src/engine/eval.ts +102 -102
- package/src/engine/eviction.ts +101 -101
- package/src/engine/index.ts +8 -8
- package/src/engine/retraction.ts +100 -100
- package/src/engine/staging.ts +74 -74
- package/src/index.ts +208 -121
- package/src/mcp.ts +1093 -1013
- package/src/storage/index.ts +3 -3
- package/src/storage/sqlite.ts +1017 -963
- package/src/types/agent.ts +67 -67
- package/src/types/checkpoint.ts +46 -46
- package/src/types/engram.ts +245 -217
- package/src/types/eval.ts +100 -100
- package/src/types/index.ts +6 -6
package/README.md
CHANGED
|
@@ -1,399 +1,428 @@
|
|
|
1
|
-
# AgentWorkingMemory (AWM)
|
|
2
|
-
|
|
3
|
-
**Persistent working memory for AI agents.**
|
|
4
|
-
|
|
5
|
-
AWM helps agents retain important project knowledge across conversations and sessions. Instead of storing everything and retrieving by similarity alone, it filters for salience, builds associative links between related memories, and periodically consolidates useful knowledge while letting noise fade.
|
|
6
|
-
|
|
7
|
-
Use it through Claude Code via MCP or as a local HTTP service for custom agents. Everything runs locally: SQLite + ONNX models + Node.js. No cloud, no API keys.
|
|
8
|
-
|
|
9
|
-
### Without AWM
|
|
10
|
-
- Agent forgets earlier architecture decision
|
|
11
|
-
- Suggests Redux after project standardized on Zustand
|
|
12
|
-
- Repeats discussion already settled three days ago
|
|
13
|
-
- Every new conversation starts from scratch
|
|
14
|
-
|
|
15
|
-
### With AWM
|
|
16
|
-
- Recalls prior state-management decision and rationale
|
|
17
|
-
- Surfaces related implementation patterns from past sessions
|
|
18
|
-
- Continues work without re-asking for context
|
|
19
|
-
- Gets more consistent the longer you use it
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Quick Start
|
|
24
|
-
|
|
25
|
-
**Node.js 20+** required — check with `node --version`.
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install -g agent-working-memory
|
|
29
|
-
awm setup --global
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Restart Claude Code. That's it — 14 memory tools appear automatically.
|
|
33
|
-
|
|
34
|
-
First conversation will be ~30 seconds slower while ML models download (~200MB total, cached locally). After that, everything runs on your machine.
|
|
35
|
-
|
|
36
|
-
> For isolated memory per folder, see [Separate Memory Pools](#separate-memory-pools). For team onboarding, see [docs/quickstart.md](docs/quickstart.md).
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## Who this is for
|
|
41
|
-
|
|
42
|
-
- **Long-running coding agents** that need cross-session project knowledge
|
|
43
|
-
- **Multi-agent workflows** where specialized agents share a common memory
|
|
44
|
-
- **Local-first setups** where cloud memory is not acceptable
|
|
45
|
-
- **Teams using Claude Code** who want persistent context without manual notes
|
|
46
|
-
|
|
47
|
-
## What this is not
|
|
48
|
-
|
|
49
|
-
- Not a chatbot UI
|
|
50
|
-
- Not a hosted SaaS
|
|
51
|
-
- Not a generic vector database
|
|
52
|
-
- Not a replacement for your source of truth (code, docs, tickets)
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Why it's different
|
|
57
|
-
|
|
58
|
-
Most "memory for AI" projects are vector databases with a retrieval wrapper. AWM goes further:
|
|
59
|
-
|
|
60
|
-
| | Typical RAG / Vector Store | AWM |
|
|
61
|
-
|---|---|---|
|
|
62
|
-
| **Storage** | Everything | Salience-filtered with low-confidence fallback (novel events go active, borderline enter staging, low-salience stored at reduced confidence) |
|
|
63
|
-
| **Retrieval** | Cosine similarity | 10-phase pipeline: dual BM25 (keyword + expanded) + vectors + reranking + graph walk + decay + coref expansion |
|
|
64
|
-
| **Connections** | None | Hebbian edges that strengthen when memories co-activate |
|
|
65
|
-
| **Over time** | Grows forever, gets noisier | Consolidation: diameter-enforced clustering, cross-topic bridges, synaptic-tagged decay |
|
|
66
|
-
| **Forgetting** | Manual cleanup | Cognitive forgetting: unused memories fade, reinforced knowledge persists (access-count modulated) |
|
|
67
|
-
| **Feedback** | None | Useful/not-useful signals tune confidence and retrieval rank |
|
|
68
|
-
| **Correction** | Delete and re-insert | Retraction: wrong memories invalidated, corrections linked, penalties propagate |
|
|
69
|
-
| **Noise rejection** | None | Multi-channel agreement gate: requires 2+ retrieval channels to agree before returning results |
|
|
70
|
-
| **Duplicates** | Stored repeatedly | Reinforce-on-duplicate: near-exact matches boost existing memory instead of creating copies |
|
|
71
|
-
|
|
72
|
-
The design is based on cognitive science — ACT-R activation decay, Hebbian learning, complementary learning systems, synaptic homeostasis, and synaptic tagging — rather than ad-hoc heuristics. See [How It Works](#how-it-works) and [docs/cognitive-model.md](docs/cognitive-model.md) for details.
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Benchmarks (v0.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
###
|
|
90
|
-
|
|
91
|
-
|
|
|
92
|
-
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
###
|
|
107
|
-
|
|
108
|
-
|
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
##
|
|
398
|
-
|
|
399
|
-
|
|
1
|
+
# AgentWorkingMemory (AWM)
|
|
2
|
+
|
|
3
|
+
**Persistent working memory for AI agents.**
|
|
4
|
+
|
|
5
|
+
AWM helps agents retain important project knowledge across conversations and sessions. Instead of storing everything and retrieving by similarity alone, it filters for salience, builds associative links between related memories, and periodically consolidates useful knowledge while letting noise fade.
|
|
6
|
+
|
|
7
|
+
Use it through Claude Code via MCP or as a local HTTP service for custom agents. Everything runs locally: SQLite + ONNX models + Node.js. No cloud, no API keys.
|
|
8
|
+
|
|
9
|
+
### Without AWM
|
|
10
|
+
- Agent forgets earlier architecture decision
|
|
11
|
+
- Suggests Redux after project standardized on Zustand
|
|
12
|
+
- Repeats discussion already settled three days ago
|
|
13
|
+
- Every new conversation starts from scratch
|
|
14
|
+
|
|
15
|
+
### With AWM
|
|
16
|
+
- Recalls prior state-management decision and rationale
|
|
17
|
+
- Surfaces related implementation patterns from past sessions
|
|
18
|
+
- Continues work without re-asking for context
|
|
19
|
+
- Gets more consistent the longer you use it
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
**Node.js 20+** required — check with `node --version`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g agent-working-memory
|
|
29
|
+
awm setup --global
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Restart Claude Code. That's it — 14 memory tools appear automatically.
|
|
33
|
+
|
|
34
|
+
First conversation will be ~30 seconds slower while ML models download (~200MB total, cached locally). After that, everything runs on your machine.
|
|
35
|
+
|
|
36
|
+
> For isolated memory per folder, see [Separate Memory Pools](#separate-memory-pools). For team onboarding, see [docs/quickstart.md](docs/quickstart.md).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Who this is for
|
|
41
|
+
|
|
42
|
+
- **Long-running coding agents** that need cross-session project knowledge
|
|
43
|
+
- **Multi-agent workflows** where specialized agents share a common memory
|
|
44
|
+
- **Local-first setups** where cloud memory is not acceptable
|
|
45
|
+
- **Teams using Claude Code** who want persistent context without manual notes
|
|
46
|
+
|
|
47
|
+
## What this is not
|
|
48
|
+
|
|
49
|
+
- Not a chatbot UI
|
|
50
|
+
- Not a hosted SaaS
|
|
51
|
+
- Not a generic vector database
|
|
52
|
+
- Not a replacement for your source of truth (code, docs, tickets)
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Why it's different
|
|
57
|
+
|
|
58
|
+
Most "memory for AI" projects are vector databases with a retrieval wrapper. AWM goes further:
|
|
59
|
+
|
|
60
|
+
| | Typical RAG / Vector Store | AWM |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| **Storage** | Everything | Salience-filtered with low-confidence fallback (novel events go active, borderline enter staging, low-salience stored at reduced confidence) |
|
|
63
|
+
| **Retrieval** | Cosine similarity | 10-phase pipeline: dual BM25 (keyword + expanded) + vectors + reranking + graph walk + decay + coref expansion |
|
|
64
|
+
| **Connections** | None | Hebbian edges that strengthen when memories co-activate |
|
|
65
|
+
| **Over time** | Grows forever, gets noisier | Consolidation: diameter-enforced clustering, cross-topic bridges, synaptic-tagged decay |
|
|
66
|
+
| **Forgetting** | Manual cleanup | Cognitive forgetting: unused memories fade, reinforced knowledge persists (access-count modulated) |
|
|
67
|
+
| **Feedback** | None | Useful/not-useful signals tune confidence and retrieval rank |
|
|
68
|
+
| **Correction** | Delete and re-insert | Retraction: wrong memories invalidated, corrections linked, penalties propagate |
|
|
69
|
+
| **Noise rejection** | None | Multi-channel agreement gate: requires 2+ retrieval channels to agree before returning results |
|
|
70
|
+
| **Duplicates** | Stored repeatedly | Reinforce-on-duplicate: near-exact matches boost existing memory instead of creating copies |
|
|
71
|
+
|
|
72
|
+
The design is based on cognitive science — ACT-R activation decay, Hebbian learning, complementary learning systems, synaptic homeostasis, and synaptic tagging — rather than ad-hoc heuristics. See [How It Works](#how-it-works) and [docs/cognitive-model.md](docs/cognitive-model.md) for details.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Benchmarks (v0.6.0)
|
|
77
|
+
|
|
78
|
+
### Eval Harness (new in v0.6.0)
|
|
79
|
+
|
|
80
|
+
| Suite | Score | Threshold | What it tests |
|
|
81
|
+
|-------|-------|-----------|---------------|
|
|
82
|
+
| Retrieval | **Recall@5 = 0.800** | >= 0.80 | 200 facts, 50 queries — BM25 + vector + reranker pipeline precision |
|
|
83
|
+
| Associative | **success@10 = 1.000** | >= 0.70 | 20 multi-hop causal chains — graph walk finds non-obvious connections |
|
|
84
|
+
| Redundancy | **dedup F1 = 0.966** | >= 0.80 | 50 clusters × 4 paraphrases — consolidation removes duplicates correctly |
|
|
85
|
+
| Temporal | **Spearman = 0.932** | >= 0.75 | 25 facts with controlled age/access — ACT-R decay ranking accuracy |
|
|
86
|
+
|
|
87
|
+
Key finding: **consolidation improves retrieval by 30%** — post-consolidation recall (0.950) exceeds pre-consolidation (0.650). Removing redundant noise helps ranking.
|
|
88
|
+
|
|
89
|
+
### Full Test Suite
|
|
90
|
+
|
|
91
|
+
| Command | Score | What it tests |
|
|
92
|
+
|---------|-------|---------------|
|
|
93
|
+
| `npm run eval` | **4/4 suites pass** | Retrieval, associative, redundancy, temporal benchmarks with ablation support |
|
|
94
|
+
| `npm run test:run` | **77/77 tests** | Unit tests: salience, decay, hebbian, supersession, coordination |
|
|
95
|
+
| `npm run test:mcp` | **5/5 pass** | MCP protocol: write, recall, feedback, retract, stats |
|
|
96
|
+
| `npm run test:self` | **94.1% EXCELLENT** | Pipeline component checks across all cognitive subsystems |
|
|
97
|
+
| `npm run test:edge` | **All pass** | 9 failure modes: narcissistic interference, identity collision, contradiction trapping, bridge overshoot, noise forgetting |
|
|
98
|
+
| `npm run test:stress` | **96.2% (50/52)** | 500 memories, 100 sleep cycles, catastrophic forgetting, adversarial spam, recovery |
|
|
99
|
+
| `npm run test:workday` | **93.3% EXCELLENT** | 43 memories across 4 projects, cross-cutting queries, noise filtering |
|
|
100
|
+
| `npm run test:ab` | **AWM 20/22 vs Baseline 18/22** | AWM outperforms keyword baseline on architecture + testing topics |
|
|
101
|
+
| `npm run test:sleep` | **71.4%** | 60 memories, 4 topic clusters, consolidation impact across 3 cycles |
|
|
102
|
+
| `npm run test:tokens` | **56.3% savings, 2.3x efficiency** | Memory-guided context vs full history, keyword accuracy 72.5% |
|
|
103
|
+
| `npm run test:pilot` | **14/15 pass** | Production-like queries with noise rejection (5/5 noise rejected) |
|
|
104
|
+
| `npm run test:locomo` | **28.2%** | Industry-standard LoCoMo conversational memory benchmark (1,986 QA pairs) |
|
|
105
|
+
|
|
106
|
+
### Consolidation Health (v0.6.0)
|
|
107
|
+
|
|
108
|
+
| Metric | Value |
|
|
109
|
+
|--------|-------|
|
|
110
|
+
| Topic clusters formed | **10** per consolidation cycle |
|
|
111
|
+
| Cross-topic bridges | **20** in first cycle |
|
|
112
|
+
| Edges strengthened | **135** per cycle (access-weighted) |
|
|
113
|
+
| Graph size at scale | **3,000-4,500 edges** (500 memories) |
|
|
114
|
+
| Recall after 100 cycles | **90%** stable |
|
|
115
|
+
| Catastrophic forgetting survival | **5/5** (100%) |
|
|
116
|
+
| Post-dedup retrieval | **0.950** (consolidation improves recall) |
|
|
117
|
+
|
|
118
|
+
All evals are reproducible. See [Testing & Evaluation](#testing--evaluation).
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Features
|
|
123
|
+
|
|
124
|
+
### Memory Tools (14)
|
|
125
|
+
|
|
126
|
+
| Tool | Purpose |
|
|
127
|
+
|------|---------|
|
|
128
|
+
| `memory_write` | Store a memory (salience filter + reinforce-on-duplicate) |
|
|
129
|
+
| `memory_recall` | Retrieve relevant memories by context (dual BM25 + coref expansion) |
|
|
130
|
+
| `memory_feedback` | Report whether a recalled memory was useful |
|
|
131
|
+
| `memory_retract` | Invalidate a wrong memory with optional correction |
|
|
132
|
+
| `memory_supersede` | Replace outdated memory with current version |
|
|
133
|
+
| `memory_stats` | View memory health metrics and activity |
|
|
134
|
+
| `memory_checkpoint` | Save execution state (survives context compaction) |
|
|
135
|
+
| `memory_restore` | Recover state + relevant context at session start |
|
|
136
|
+
| `memory_task_add` | Create a prioritized task |
|
|
137
|
+
| `memory_task_update` | Change task status/priority |
|
|
138
|
+
| `memory_task_list` | List tasks by status |
|
|
139
|
+
| `memory_task_next` | Get the highest-priority actionable task |
|
|
140
|
+
| `memory_task_begin` | Start a task — auto-checkpoints and recalls context |
|
|
141
|
+
| `memory_task_end` | End a task — writes summary and checkpoints |
|
|
142
|
+
|
|
143
|
+
### Separate Memory Pools
|
|
144
|
+
|
|
145
|
+
By default, all projects share one memory pool. For isolated pools per folder, place a `.mcp.json` in each parent folder with a different `AWM_AGENT_ID`:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
C:\Users\you\work\.mcp.json -> AWM_AGENT_ID: "work"
|
|
149
|
+
C:\Users\you\personal\.mcp.json -> AWM_AGENT_ID: "personal"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Claude Code uses the closest `.mcp.json` ancestor. Same database, isolation by agent ID.
|
|
153
|
+
|
|
154
|
+
### Incognito Mode
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
AWM_INCOGNITO=1 claude
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Registers zero tools — Claude doesn't see memory at all. All other tools and MCP servers work normally.
|
|
161
|
+
|
|
162
|
+
### Auto-Checkpoint Hooks
|
|
163
|
+
|
|
164
|
+
Installed by `awm setup --global`:
|
|
165
|
+
|
|
166
|
+
- **Stop** — reminds Claude to write/recall after each response
|
|
167
|
+
- **PreCompact** — auto-checkpoints before context compression
|
|
168
|
+
- **SessionEnd** — auto-checkpoints and consolidates on close
|
|
169
|
+
- **15-min timer** — silent auto-checkpoint while session is active
|
|
170
|
+
|
|
171
|
+
### Auto-Backup
|
|
172
|
+
|
|
173
|
+
The HTTP server automatically copies the database to a `backups/` directory on startup with a timestamp. Cheap insurance against data loss.
|
|
174
|
+
|
|
175
|
+
### Activity Log
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
tail -f "$(npm root -g)/agent-working-memory/data/awm.log"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Real-time: writes, recalls, reinforcements, checkpoints, consolidation, hook events.
|
|
182
|
+
|
|
183
|
+
### Activity Stats
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
curl http://127.0.0.1:8401/stats
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Returns daily counts: `{"writes": 8, "recalls": 9, "hooks": 3, "total": 25}`
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Memory Invocation Strategy
|
|
194
|
+
|
|
195
|
+
AWM combines deterministic hooks for guaranteed memory operations at lifecycle transitions with agent-directed usage during active work.
|
|
196
|
+
|
|
197
|
+
### Deterministic triggers (always happen)
|
|
198
|
+
|
|
199
|
+
| Event | Action |
|
|
200
|
+
|-------|--------|
|
|
201
|
+
| Session start | `memory_restore` — recover state + recall context |
|
|
202
|
+
| Pre-compaction | Auto-checkpoint via hook sidecar |
|
|
203
|
+
| Session end | Auto-checkpoint + full consolidation |
|
|
204
|
+
| Every 15 min | Silent auto-checkpoint (if active) |
|
|
205
|
+
| Task start | `memory_task_begin` — checkpoint + recall |
|
|
206
|
+
| Task end | `memory_task_end` — summary + checkpoint |
|
|
207
|
+
|
|
208
|
+
### Agent-directed triggers (when these situations occur)
|
|
209
|
+
|
|
210
|
+
**Write memory when:**
|
|
211
|
+
- A project decision is made or changed
|
|
212
|
+
- A root cause is discovered
|
|
213
|
+
- A reusable implementation pattern is established
|
|
214
|
+
- A preference, constraint, or requirement is clarified
|
|
215
|
+
- A prior assumption is found to be wrong
|
|
216
|
+
|
|
217
|
+
**Recall memory when:**
|
|
218
|
+
- Starting work on a new task or subsystem
|
|
219
|
+
- Re-entering code you haven't touched recently
|
|
220
|
+
- After context compaction
|
|
221
|
+
- After a failed attempt (check if there's prior knowledge)
|
|
222
|
+
- Before refactoring or making architectural changes
|
|
223
|
+
|
|
224
|
+
**Retract when:**
|
|
225
|
+
- A stored memory turns out to be wrong or outdated
|
|
226
|
+
|
|
227
|
+
**Feedback when:**
|
|
228
|
+
- A recalled memory was used (useful) or irrelevant (not useful)
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## HTTP API
|
|
233
|
+
|
|
234
|
+
For custom agents, scripts, or non-Claude-Code workflows:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
awm serve # From npm install
|
|
238
|
+
npx tsx src/index.ts # From source
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Write a memory:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
curl -X POST http://localhost:8400/memory/write \
|
|
245
|
+
-H "Content-Type: application/json" \
|
|
246
|
+
-d '{
|
|
247
|
+
"agentId": "my-agent",
|
|
248
|
+
"concept": "Express error handling",
|
|
249
|
+
"content": "Use centralized error middleware as the last app.use()",
|
|
250
|
+
"eventType": "causal",
|
|
251
|
+
"surprise": 0.5,
|
|
252
|
+
"causalDepth": 0.7
|
|
253
|
+
}'
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Recall:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
curl -X POST http://localhost:8400/memory/activate \
|
|
260
|
+
-H "Content-Type: application/json" \
|
|
261
|
+
-d '{
|
|
262
|
+
"agentId": "my-agent",
|
|
263
|
+
"context": "How should I handle errors in my Express API?"
|
|
264
|
+
}'
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## How It Works
|
|
270
|
+
|
|
271
|
+
### The Memory Lifecycle
|
|
272
|
+
|
|
273
|
+
1. **Write** — Salience scoring evaluates novelty, surprise, causal depth, and effort. High-salience memories go active; borderline ones enter staging; low-salience stored at reduced confidence for recall fallback. Near-duplicates reinforce existing memories instead of creating copies.
|
|
274
|
+
|
|
275
|
+
2. **Connect** — Vector embedding (BGE-small-en-v1.5, 384d). Temporal edges link to recent memories. Hebbian edges form between co-retrieved memories. Coref expansion resolves pronouns to entity names.
|
|
276
|
+
|
|
277
|
+
3. **Retrieve** — 10-phase pipeline: coref expansion + query expansion + dual BM25 (keyword-stripped + expanded) + semantic vectors + Rocchio pseudo-relevance feedback + ACT-R temporal decay (synaptic-tagged) + Hebbian boost + entity-bridge boost + graph walk + cross-encoder reranking + multi-channel agreement gate.
|
|
278
|
+
|
|
279
|
+
4. **Consolidate** — 7-phase sleep cycle: diameter-enforced clustering (prevents chaining), edge strengthening (access-weighted), cross-topic bridge formation (direct closest-pair), confidence-modulated decay (synaptic tagging extends half-life), synaptic homeostasis, cognitive forgetting, staging sweep. Embedding backfill ensures all memories are clusterable.
|
|
280
|
+
|
|
281
|
+
5. **Feedback** — Useful/not-useful signals adjust confidence, affecting retrieval rank and forgetting resistance.
|
|
282
|
+
|
|
283
|
+
### Cognitive Foundations
|
|
284
|
+
|
|
285
|
+
- **ACT-R activation decay** (Anderson 1993) — memories decay with time, strengthen with use. Synaptic tagging: heavily-accessed memories decay slower (log-scaled).
|
|
286
|
+
- **Hebbian learning** — co-retrieved memories form stronger associative edges
|
|
287
|
+
- **Complementary Learning Systems** — fast capture (salience + staging) + slow consolidation (sleep cycle)
|
|
288
|
+
- **Synaptic homeostasis** — edge weight normalization prevents hub domination
|
|
289
|
+
- **Forgetting as feature** — noise removal improves signal-to-noise for connected memories
|
|
290
|
+
- **Diameter-enforced clustering** — prevents semantic chaining (e.g., physics->biophysics->cooking = 1 cluster)
|
|
291
|
+
- **Multi-channel agreement** — OOD detection requires multiple retrieval channels to agree
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Architecture
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
src/
|
|
299
|
+
core/ # Cognitive primitives
|
|
300
|
+
embeddings.ts - Local vector embeddings (BGE-small-en-v1.5, 384d)
|
|
301
|
+
reranker.ts - Cross-encoder passage scoring (ms-marco-MiniLM)
|
|
302
|
+
query-expander.ts - Synonym expansion (flan-t5-small)
|
|
303
|
+
salience.ts - Write-time importance scoring (novelty + salience + reinforce-on-duplicate)
|
|
304
|
+
decay.ts - ACT-R temporal activation decay
|
|
305
|
+
hebbian.ts - Association strengthening/weakening
|
|
306
|
+
logger.ts - Append-only activity log (data/awm.log)
|
|
307
|
+
engine/ # Processing pipelines
|
|
308
|
+
activation.ts - 10-phase retrieval pipeline (dual BM25, coref, agreement gate)
|
|
309
|
+
consolidation.ts - 7-phase sleep cycle (diameter clustering, direct bridging, synaptic tagging)
|
|
310
|
+
connections.ts - Discover links between memories
|
|
311
|
+
staging.ts - Weak signal buffer (promote or discard)
|
|
312
|
+
retraction.ts - Negative memory / corrections
|
|
313
|
+
eviction.ts - Capacity enforcement
|
|
314
|
+
hooks/
|
|
315
|
+
sidecar.ts - Hook HTTP server (auto-checkpoint, stats, timer)
|
|
316
|
+
storage/
|
|
317
|
+
sqlite.ts - SQLite + FTS5 persistence layer
|
|
318
|
+
api/
|
|
319
|
+
routes.ts - HTTP endpoints (memory + task + system)
|
|
320
|
+
mcp.ts - MCP server (14 tools, incognito support)
|
|
321
|
+
cli.ts - CLI (setup, serve, hook config)
|
|
322
|
+
index.ts - HTTP server entry point (auto-backup on startup)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
For detailed architecture including pipeline phases, database schema, and system diagrams, see [docs/architecture.md](docs/architecture.md).
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Testing & Evaluation
|
|
330
|
+
|
|
331
|
+
### Unit Tests
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
npx vitest run # 77 tests (salience, decay, hebbian, supersession)
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Eval Harness (v0.6.0)
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
npm run eval # All 4 benchmark suites
|
|
341
|
+
npm run eval -- --suite=retrieval # Single suite
|
|
342
|
+
npm run eval -- --bm25-only # Ablation: BM25 only
|
|
343
|
+
npm run eval -- --no-graph-walk # Ablation: disable graph walk
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Suites: retrieval (Recall@5), associative (multi-hop), redundancy (dedup F1), temporal (Spearman vs ACT-R). Ablation flags isolate each pipeline component's contribution.
|
|
347
|
+
|
|
348
|
+
### Full Test Suite
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
npm run test:mcp # MCP protocol smoke test (5/5)
|
|
352
|
+
npm run test:self # Pipeline component checks (94.1%)
|
|
353
|
+
npm run test:edge # 9 adversarial failure modes
|
|
354
|
+
npm run test:stress # 500 memories, 100 consolidation cycles (96.2%)
|
|
355
|
+
npm run test:workday # 4-session production simulation (93.3%)
|
|
356
|
+
npm run test:ab # AWM vs baseline comparison
|
|
357
|
+
npm run test:sleep # Consolidation impact measurement
|
|
358
|
+
npm run test:tokens # Token savings analysis (56.3% savings)
|
|
359
|
+
npm run test:pilot # Production-like query validation (14/15)
|
|
360
|
+
npm run test:locomo # LoCoMo industry benchmark (28.2%)
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Environment Variables
|
|
366
|
+
|
|
367
|
+
| Variable | Default | Purpose |
|
|
368
|
+
|----------|---------|---------|
|
|
369
|
+
| `AWM_PORT` | `8400` | HTTP server port |
|
|
370
|
+
| `AWM_DB_PATH` | `memory.db` | SQLite database path |
|
|
371
|
+
| `AWM_AGENT_ID` | `claude-code` | Agent ID (memory namespace) |
|
|
372
|
+
| `AWM_EMBED_MODEL` | `Xenova/bge-small-en-v1.5` | Embedding model (retrieval-optimized) |
|
|
373
|
+
| `AWM_EMBED_DIMS` | `384` | Embedding dimensions |
|
|
374
|
+
| `AWM_RERANKER_MODEL` | `Xenova/ms-marco-MiniLM-L-6-v2` | Reranker model |
|
|
375
|
+
| `AWM_HOOK_PORT` | `8401` | Hook sidecar port |
|
|
376
|
+
| `AWM_HOOK_SECRET` | *(none)* | Bearer token for hook auth |
|
|
377
|
+
| `AWM_API_KEY` | *(none)* | Bearer token for HTTP API auth |
|
|
378
|
+
| `AWM_INCOGNITO` | *(unset)* | Set to `1` to disable all tools |
|
|
379
|
+
|
|
380
|
+
## Tech Stack
|
|
381
|
+
|
|
382
|
+
| Component | Technology |
|
|
383
|
+
|-----------|-----------|
|
|
384
|
+
| Language | TypeScript (ES2022, strict) |
|
|
385
|
+
| Database | SQLite via better-sqlite3 + FTS5 |
|
|
386
|
+
| HTTP | Fastify 5 |
|
|
387
|
+
| MCP | @modelcontextprotocol/sdk |
|
|
388
|
+
| ML Runtime | @huggingface/transformers (local ONNX) |
|
|
389
|
+
| Embeddings | BGE-small-en-v1.5 (BAAI, retrieval-optimized, 384d) |
|
|
390
|
+
| Reranker | ms-marco-MiniLM-L-6-v2 (cross-encoder) |
|
|
391
|
+
| Query Expansion | flan-t5-small (synonym generation) |
|
|
392
|
+
| Tests | Vitest 4 |
|
|
393
|
+
| Validation | Zod 4 |
|
|
394
|
+
|
|
395
|
+
All three ML models run locally via ONNX. No external API calls for retrieval. The entire system is a single SQLite file + a Node.js process.
|
|
396
|
+
|
|
397
|
+
## What's New in v0.6.0
|
|
398
|
+
|
|
399
|
+
- **Memory taxonomy** — memories classified as `episodic`, `semantic`, `procedural`, or `unclassified`. Auto-classified on write. Filter by type on recall.
|
|
400
|
+
- **Query-adaptive retrieval** — pipeline adapts to query type: `targeted` (boost exact matches), `exploratory` (wider graph walk, more semantic), `balanced` (default).
|
|
401
|
+
- **Decision propagation** — decisions automatically broadcast to coordination layer for cross-agent discovery. Peer decisions shown on `memory_restore`.
|
|
402
|
+
- **Completion verification** — workers must provide proof of work (result summary, optional commit SHA) when completing assignments.
|
|
403
|
+
- **Task priority & dependencies** — priority field (0-10) and `blocked_by` for task ordering.
|
|
404
|
+
- **Eval harness** — `npm run eval` benchmarks retrieval, associative, redundancy, and temporal performance with ablation mode.
|
|
405
|
+
- **DB hardening** — busy_timeout, integrity check on startup, hot backups every 10 min, WAL checkpoint on shutdown.
|
|
406
|
+
- **Consolidation recall fix** — redundancy pruning transfers associations and tags to survivor memory.
|
|
407
|
+
|
|
408
|
+
See [CHANGELOG.md](CHANGELOG.md) for full details.
|
|
409
|
+
|
|
410
|
+
## Project Status
|
|
411
|
+
|
|
412
|
+
AWM is in active development (v0.6.0). The core memory pipeline, consolidation system, multi-agent coordination, and MCP integration are stable and used daily in production coding workflows.
|
|
413
|
+
|
|
414
|
+
- Core retrieval and consolidation: **stable**
|
|
415
|
+
- MCP tools and Claude Code integration: **stable**
|
|
416
|
+
- Multi-agent coordination: **stable** (v0.6.0)
|
|
417
|
+
- Task management: **stable**
|
|
418
|
+
- Hook sidecar and auto-checkpoint: **stable**
|
|
419
|
+
- HTTP API: **stable** (for custom agents)
|
|
420
|
+
- Eval harness: **stable** (v0.6.0)
|
|
421
|
+
|
|
422
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## License
|
|
427
|
+
|
|
428
|
+
Apache 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
|