agent-working-memory 0.8.8 → 0.9.1

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.
@@ -66,5 +66,17 @@ export declare class ConnectionEngine {
66
66
  * Find and create connections for a given engram.
67
67
  */
68
68
  private findConnections;
69
+ /**
70
+ * R1 — form entity co-occurrence edges (default-off, `AWM_BROAD_EDGES=1`).
71
+ *
72
+ * Extract proper-noun entities from the engram, find other engrams that
73
+ * literally mention the same entity, and link them at a lower weight than
74
+ * the semantic edges above. The BM25 candidate is re-checked with a
75
+ * case-insensitive substring match so a coincidental capitalized word
76
+ * doesn't create a spurious edge (precision guard); edge weight scales with
77
+ * the number of shared entities but stays below the 0.7 semantic floor so
78
+ * semantic links still dominate the graph walk.
79
+ */
80
+ private formEntityEdges;
69
81
  }
70
82
  //# sourceMappingURL=connections.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/engine/connections.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKxD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,UAAU,CAAS;gBAGzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,gBAAgB,EACxB,SAAS,GAAE,MAAY;IAOzB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;YAM/C,mBAAmB;IAYjC;;;;;;;;OAQG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBnC,mEAAmE;IACnE,SAAS,IAAI,MAAM;IAInB;;OAEG;YACW,eAAe;CAoC9B"}
1
+ {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/engine/connections.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAiDxD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,UAAU,CAAS;gBAGzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,gBAAgB,EACxB,SAAS,GAAE,MAAY;IAOzB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;YAM/C,mBAAmB;IAYjC;;;;;;;;OAQG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBnC,mEAAmE;IACnE,SAAS,IAAI,MAAM;IAInB;;OAEG;YACW,eAAe;IA2C7B;;;;;;;;;;OAUG;YACW,eAAe;CAgC9B"}
@@ -22,6 +22,50 @@
22
22
  * queued ID. AWM remains cheap to NOT use.
23
23
  */
24
24
  const COLD_START_THRESHOLD = Number(process.env.AWM_CONNECTION_COLD_START_THRESHOLD ?? 10);
25
+ /**
26
+ * R1 — broaden edge FORMATION beyond high-cosine semantic links.
27
+ *
28
+ * The semantic `activate` path only links engrams at ≥0.7 cosine, so two facts
29
+ * that share an entity but are lexically/semantically distant ("my main project
30
+ * is Atlas" vs "Atlas's codename is Magpie") never get an edge — starving the
31
+ * graph walk / spreading activation of exactly the bridges multi-hop needs.
32
+ *
33
+ * When enabled, after the semantic pass we also form *entity co-occurrence*
34
+ * edges: extract proper-noun entities from the engram, find other engrams that
35
+ * literally mention the same entity (BM25 + substring re-check for precision),
36
+ * and link them at a LOWER weight than semantic edges. Recall-only by design —
37
+ * the edges feed candidate generation; the reranker still makes the final cut.
38
+ *
39
+ * Default-OFF (gate per docs/awm-improvement-register.md). Set
40
+ * `AWM_BROAD_EDGES=1` to enable.
41
+ */
42
+ const BROAD_EDGES = process.env.AWM_BROAD_EDGES === '1';
43
+ /** Max entity-co-occurrence edges formed per engram (on top of semantic). */
44
+ const MAX_ENTITY_EDGES = Number(process.env.AWM_BROAD_EDGES_MAX ?? 6);
45
+ /** Proper-noun entity extraction — mirrors auto-tagger's `entity:` pattern. */
46
+ const ENTITY_RE = /\b([A-Z][a-z]{2,}(?:\s+[A-Z][a-z]+)*)\b/g;
47
+ /** Common capitalized words that are not useful entity bridges. */
48
+ const ENTITY_STOPWORDS = new Set([
49
+ 'The', 'This', 'That', 'These', 'Those', 'There', 'Then', 'They', 'Them',
50
+ 'And', 'But', 'For', 'With', 'From', 'Into', 'When', 'What', 'Where', 'Which',
51
+ 'While', 'Who', 'Why', 'How', 'Also', 'After', 'Before', 'Because', 'Should',
52
+ 'Would', 'Could', 'Will', 'Was', 'Were', 'Has', 'Have', 'Had', 'Not', 'Now',
53
+ 'New', 'One', 'Two', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
54
+ 'Saturday', 'Sunday', 'January', 'February', 'March', 'April', 'June', 'July',
55
+ 'August', 'September', 'October', 'November', 'December',
56
+ ]);
57
+ function extractEntities(text) {
58
+ const out = new Set();
59
+ for (const m of text.matchAll(ENTITY_RE)) {
60
+ const name = m[1].trim();
61
+ if (name.length < 3 || name.length > 40)
62
+ continue;
63
+ if (ENTITY_STOPWORDS.has(name))
64
+ continue;
65
+ out.add(name);
66
+ }
67
+ return [...out];
68
+ }
25
69
  export class ConnectionEngine {
26
70
  store;
27
71
  engine;
@@ -118,6 +162,7 @@ export class ConnectionEngine {
118
162
  limit: 5,
119
163
  minScore: this.threshold,
120
164
  internal: true,
165
+ spread: false, // edge discovery must not recurse through R2 spreading
121
166
  });
122
167
  // Filter out self and already-connected engrams
123
168
  const existing = await this.store.getAssociationsFor(engram.id);
@@ -131,6 +176,56 @@ export class ConnectionEngine {
131
176
  await this.store.upsertAssociation(engram.id, result.engram.id, result.score, 'connection');
132
177
  // Bidirectional
133
178
  await this.store.upsertAssociation(result.engram.id, engram.id, result.score, 'connection');
179
+ existingIds.add(result.engram.id);
180
+ }
181
+ if (BROAD_EDGES) {
182
+ await this.formEntityEdges(engram, existingIds);
183
+ }
184
+ }
185
+ /**
186
+ * R1 — form entity co-occurrence edges (default-off, `AWM_BROAD_EDGES=1`).
187
+ *
188
+ * Extract proper-noun entities from the engram, find other engrams that
189
+ * literally mention the same entity, and link them at a lower weight than
190
+ * the semantic edges above. The BM25 candidate is re-checked with a
191
+ * case-insensitive substring match so a coincidental capitalized word
192
+ * doesn't create a spurious edge (precision guard); edge weight scales with
193
+ * the number of shared entities but stays below the 0.7 semantic floor so
194
+ * semantic links still dominate the graph walk.
195
+ */
196
+ async formEntityEdges(engram, existingIds) {
197
+ const entities = extractEntities(`${engram.concept} ${engram.content}`);
198
+ if (entities.length === 0)
199
+ return;
200
+ // Gather candidates that match any of the engram's entities (BM25 OR).
201
+ const query = entities.slice(0, 6).join(' ');
202
+ const candidates = await this.store.searchBM25(engram.agentId, query, 20);
203
+ const lowerEntities = entities.map(e => e.toLowerCase());
204
+ // Rank candidates by how many of our entities they literally contain.
205
+ const scored = [];
206
+ for (const cand of candidates) {
207
+ if (cand.id === engram.id)
208
+ continue;
209
+ if (existingIds.has(cand.id))
210
+ continue;
211
+ if (cand.stage !== 'active')
212
+ continue;
213
+ const candText = `${cand.concept} ${cand.content}`.toLowerCase();
214
+ let shared = 0;
215
+ for (const ent of lowerEntities) {
216
+ if (candText.includes(ent))
217
+ shared++;
218
+ }
219
+ if (shared > 0)
220
+ scored.push({ id: cand.id, engram: cand, shared });
221
+ }
222
+ scored.sort((a, b) => b.shared - a.shared);
223
+ for (const { id, shared } of scored.slice(0, MAX_ENTITY_EDGES)) {
224
+ // Below the 0.7 semantic floor; more shared entities → stronger edge.
225
+ const weight = Math.min(0.6, 0.4 + 0.1 * shared);
226
+ await this.store.upsertAssociation(engram.id, id, weight, 'connection');
227
+ await this.store.upsertAssociation(id, engram.id, weight, 'connection');
228
+ existingIds.add(id);
134
229
  }
135
230
  }
136
231
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/engine/connections.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAC;AAE3F,MAAM,OAAO,gBAAgB;IACnB,KAAK,CAAc;IACnB,MAAM,CAAmB;IACzB,SAAS,CAAS;IAClB,KAAK,GAAa,EAAE,CAAC;IACrB,UAAU,GAAG,KAAK,CAAC;IAE3B,YACE,KAAkB,EAClB,MAAwB,EACxB,YAAoB,GAAG;QAEvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,QAAgB;QACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,QAAgB,EAAE,OAAe;QACpD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,C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E,MAAM,EAAE,CAAC;YACvC,CAAC;YACD,IAAI,MAAM,GAAG,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3C,KAAK,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE,CAAC;YAC/D,sEAAsE;YACtE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC;YACjD,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
package/dist/mcp.js CHANGED
@@ -186,15 +186,15 @@ else {
186
186
  return 'unclassified';
187
187
  }
188
188
  // --- Tools ---
189
- server.tool('memory_write', `Store a memory. The salience filter decides whether it's worth keeping (active), needs more evidence (staging), or should be discarded.
190
-
191
- CALL THIS PROACTIVELY — do not wait to be asked. Write memories when you:
192
- - Discover something about the codebase, bugs, or architecture
193
- - Make a decision and want to remember why
194
- - Encounter and resolve an error
195
- - Learn a user preference or project pattern
196
- - Complete a significant piece of work
197
-
189
+ server.tool('memory_write', `Store a memory. The salience filter decides whether it's worth keeping (active), needs more evidence (staging), or should be discarded.
190
+
191
+ CALL THIS PROACTIVELY — do not wait to be asked. Write memories when you:
192
+ - Discover something about the codebase, bugs, or architecture
193
+ - Make a decision and want to remember why
194
+ - Encounter and resolve an error
195
+ - Learn a user preference or project pattern
196
+ - Complete a significant piece of work
197
+
198
198
  The concept should be a short label (3-8 words). The content should be the full detail.`, {
199
199
  concept: z.string().describe('Short label for this memory (3-8 words)'),
200
200
  content: z.string().describe('Full detail of what was learned'),
@@ -298,15 +298,15 @@ The concept should be a short label (3-8 words). The content should be the full
298
298
  }],
299
299
  };
300
300
  });
301
- server.tool('memory_recall', `Recall memories relevant to a query. Uses cognitive activation — not keyword search.
302
-
303
- ALWAYS call this when:
304
- - Starting work on a project or topic (recall what you know)
305
- - Debugging (recall similar errors and solutions)
306
- - Making decisions (recall past decisions and outcomes)
307
- - The user mentions a topic you might have stored memories about
308
-
309
- Accepts either "query" or "context" parameter — both work identically.
301
+ server.tool('memory_recall', `Recall memories relevant to a query. Uses cognitive activation — not keyword search.
302
+
303
+ ALWAYS call this when:
304
+ - Starting work on a project or topic (recall what you know)
305
+ - Debugging (recall similar errors and solutions)
306
+ - Making decisions (recall past decisions and outcomes)
307
+ - The user mentions a topic you might have stored memories about
308
+
309
+ Accepts either "query" or "context" parameter — both work identically.
310
310
  Returns the most relevant memories ranked by text relevance, temporal recency, and associative strength.`, {
311
311
  query: z.string().optional().describe('What to search for — describe the situation, question, or topic'),
312
312
  context: z.string().optional().describe('Alias for query (either works)'),
@@ -377,8 +377,8 @@ Returns the most relevant memories ranked by text relevance, temporal recency, a
377
377
  }],
378
378
  };
379
379
  });
380
- server.tool('memory_feedback', `Report whether a recalled memory was actually useful. This updates the memory's confidence score — useful memories become stronger, useless ones weaken.
381
-
380
+ server.tool('memory_feedback', `Report whether a recalled memory was actually useful. This updates the memory's confidence score — useful memories become stronger, useless ones weaken.
381
+
382
382
  Always call this after using a recalled memory so the system learns what's valuable.`, {
383
383
  engram_id: z.string().describe('ID of the memory (from memory_recall results)'),
384
384
  useful: z.boolean().describe('Was this memory actually helpful?'),
@@ -401,8 +401,8 @@ Always call this after using a recalled memory so the system learns what's valua
401
401
  }],
402
402
  };
403
403
  });
404
- server.tool('memory_retract', `Retract a memory that turned out to be wrong. Creates a correction and reduces confidence of related memories.
405
-
404
+ server.tool('memory_retract', `Retract a memory that turned out to be wrong. Creates a correction and reduces confidence of related memories.
405
+
406
406
  Use this when you discover a memory contains incorrect information.`, {
407
407
  engram_id: z.string().describe('ID of the wrong memory'),
408
408
  reason: z.string().describe('Why is this memory wrong?'),
@@ -426,13 +426,13 @@ Use this when you discover a memory contains incorrect information.`, {
426
426
  }],
427
427
  };
428
428
  });
429
- server.tool('memory_supersede', `Replace an outdated memory with a newer one. Unlike retraction (which marks memories as wrong), supersession marks the old memory as outdated but historically correct.
430
-
431
- Use this when:
432
- - A status or count has changed (e.g., "5 reviews done" → "7 reviews done")
433
- - Architecture or infrastructure evolved (e.g., "two-repo model" → "three-repo model")
434
- - A schedule or plan was updated
435
-
429
+ server.tool('memory_supersede', `Replace an outdated memory with a newer one. Unlike retraction (which marks memories as wrong), supersession marks the old memory as outdated but historically correct.
430
+
431
+ Use this when:
432
+ - A status or count has changed (e.g., "5 reviews done" → "7 reviews done")
433
+ - Architecture or infrastructure evolved (e.g., "two-repo model" → "three-repo model")
434
+ - A schedule or plan was updated
435
+
436
436
  The old memory stays in the database (searchable for history) but is heavily down-ranked in recall so the current version dominates.`, {
437
437
  old_engram_id: z.string().describe('ID of the outdated memory'),
438
438
  new_engram_id: z.string().describe('ID of the replacement memory'),
@@ -459,7 +459,7 @@ The old memory stays in the database (searchable for history) but is heavily dow
459
459
  }],
460
460
  };
461
461
  });
462
- server.tool('memory_stats', `Get memory health stats — how many memories, confidence levels, association count, and system performance.
462
+ server.tool('memory_stats', `Get memory health stats — how many memories, confidence levels, association count, and system performance.
463
463
  Also shows the activity log path so the user can tail it to see what's happening.`, {}, async () => {
464
464
  const metrics = await evalEngine.computeMetrics(AGENT_ID);
465
465
  const checkpoint = await store.getCheckpoint(AGENT_ID);
@@ -490,13 +490,13 @@ Also shows the activity log path so the user can tail it to see what's happening
490
490
  };
491
491
  });
492
492
  // --- Checkpointing Tools ---
493
- server.tool('memory_checkpoint', `Save your current execution state so you can recover after context compaction.
494
-
495
- ALWAYS call this before:
496
- - Long operations (multi-file generation, large refactors, overnight work)
497
- - Anything that might fill the context window
498
- - Switching to a different task
499
-
493
+ server.tool('memory_checkpoint', `Save your current execution state so you can recover after context compaction.
494
+
495
+ ALWAYS call this before:
496
+ - Long operations (multi-file generation, large refactors, overnight work)
497
+ - Anything that might fill the context window
498
+ - Switching to a different task
499
+
500
500
  Also call periodically during long sessions to avoid losing state. The state is saved per-agent and overwrites any previous checkpoint.`, {
501
501
  current_task: z.string().describe('What you are currently working on'),
502
502
  decisions: z.array(z.string()).optional().default([])
@@ -530,14 +530,14 @@ Also call periodically during long sessions to avoid losing state. The state is
530
530
  }],
531
531
  };
532
532
  });
533
- server.tool('memory_restore', `Restore your previous execution state after context compaction or at session start.
534
-
535
- Returns:
536
- - Your saved execution state (task, decisions, next steps, files)
537
- - Recently recalled memories for context
538
- - Your last write for continuity
539
- - How long you were idle
540
-
533
+ server.tool('memory_restore', `Restore your previous execution state after context compaction or at session start.
534
+
535
+ Returns:
536
+ - Your saved execution state (task, decisions, next steps, files)
537
+ - Recently recalled memories for context
538
+ - Your last write for continuity
539
+ - How long you were idle
540
+
541
541
  Use this at the start of every session or after compaction to pick up where you left off.`, {}, async () => {
542
542
  const checkpoint = await store.getCheckpoint(AGENT_ID);
543
543
  const now = Date.now();
@@ -645,9 +645,9 @@ Use this at the start of every session or after compaction to pick up where you
645
645
  if (coordDb) {
646
646
  try {
647
647
  const myAgent = coordDb.prepare(`SELECT id FROM coord_agents WHERE name = ? AND status != 'dead' ORDER BY last_seen DESC LIMIT 1`).get(AGENT_ID);
648
- const peerDecisions = coordDb.prepare(`SELECT d.summary, a.name AS author_name, d.created_at
649
- FROM coord_decisions d JOIN coord_agents a ON d.author_id = a.id
650
- WHERE d.author_id != ? AND d.created_at > datetime('now', '-30 minutes')
648
+ const peerDecisions = coordDb.prepare(`SELECT d.summary, a.name AS author_name, d.created_at
649
+ FROM coord_decisions d JOIN coord_agents a ON d.author_id = a.id
650
+ WHERE d.author_id != ? AND d.created_at > datetime('now', '-30 minutes')
651
651
  ORDER BY d.created_at DESC LIMIT 10`).all(myAgent?.id ?? '');
652
652
  if (peerDecisions.length > 0) {
653
653
  parts.push(`\n**Peer decisions (last 30 min):**`);
@@ -666,13 +666,13 @@ Use this at the start of every session or after compaction to pick up where you
666
666
  };
667
667
  });
668
668
  // --- Task Management Tools ---
669
- server.tool('memory_task_add', `Create a task that you need to come back to. Tasks are memories with status and priority tracking.
670
-
671
- Use this when:
672
- - You identify work that needs doing but can't do it right now
673
- - The user mentions something to do later
674
- - You want to park a sub-task while focusing on something more urgent
675
-
669
+ server.tool('memory_task_add', `Create a task that you need to come back to. Tasks are memories with status and priority tracking.
670
+
671
+ Use this when:
672
+ - You identify work that needs doing but can't do it right now
673
+ - The user mentions something to do later
674
+ - You want to park a sub-task while focusing on something more urgent
675
+
676
676
  Tasks automatically get high salience so they won't be discarded.`, {
677
677
  concept: z.string().describe('Short task title (3-10 words)'),
678
678
  content: z.string().describe('Full task description — what needs doing, context, acceptance criteria'),
@@ -712,11 +712,11 @@ Tasks automatically get high salience so they won't be discarded.`, {
712
712
  }],
713
713
  };
714
714
  });
715
- server.tool('memory_task_update', `Update a task's status or priority. Use this to:
716
- - Start working on a task (open → in_progress)
717
- - Mark a task done (→ done)
718
- - Block a task on another (→ blocked)
719
- - Reprioritize (change priority)
715
+ server.tool('memory_task_update', `Update a task's status or priority. Use this to:
716
+ - Start working on a task (open → in_progress)
717
+ - Mark a task done (→ done)
718
+ - Block a task on another (→ blocked)
719
+ - Reprioritize (change priority)
720
720
  - Unblock a task (clear blocked_by)`, {
721
721
  task_id: z.string().describe('ID of the task to update'),
722
722
  status: z.enum(['open', 'in_progress', 'blocked', 'done']).optional()
@@ -746,8 +746,8 @@ Tasks automatically get high salience so they won't be discarded.`, {
746
746
  }],
747
747
  };
748
748
  });
749
- server.tool('memory_task_list', `List tasks with optional status filter. Shows tasks ordered by priority (urgent first).
750
-
749
+ server.tool('memory_task_list', `List tasks with optional status filter. Shows tasks ordered by priority (urgent first).
750
+
751
751
  Use at the start of a session to see what's pending, or to check blocked/done tasks.`, {
752
752
  status: z.enum(['open', 'in_progress', 'blocked', 'done']).optional()
753
753
  .describe('Filter by status (omit to see all active tasks)'),
@@ -773,10 +773,10 @@ Use at the start of a session to see what's pending, or to check blocked/done ta
773
773
  }],
774
774
  };
775
775
  });
776
- server.tool('memory_task_next', `Get the single most important task to work on next.
777
-
778
- Prioritizes: in_progress tasks first (finish what you started), then by priority level, then oldest first. Skips blocked and done tasks.
779
-
776
+ server.tool('memory_task_next', `Get the single most important task to work on next.
777
+
778
+ Prioritizes: in_progress tasks first (finish what you started), then by priority level, then oldest first. Skips blocked and done tasks.
779
+
780
780
  Use this when you finish a task or need to decide what to do next.`, {}, async () => {
781
781
  const next = await store.getNextTask(AGENT_ID);
782
782
  if (!next) {
@@ -792,13 +792,13 @@ Use this when you finish a task or need to decide what to do next.`, {}, async (
792
792
  };
793
793
  });
794
794
  // --- Task Bracket Tools ---
795
- server.tool('memory_task_begin', `Signal that you're starting a significant task. Auto-checkpoints current state and recalls relevant memories.
796
-
797
- CALL THIS when starting:
798
- - A multi-step operation (doc generation, large refactor, migration)
799
- - Work on a new topic or project area
800
- - Anything that might fill the context window
801
-
795
+ server.tool('memory_task_begin', `Signal that you're starting a significant task. Auto-checkpoints current state and recalls relevant memories.
796
+
797
+ CALL THIS when starting:
798
+ - A multi-step operation (doc generation, large refactor, migration)
799
+ - Work on a new topic or project area
800
+ - Anything that might fill the context window
801
+
802
802
  This ensures your state is saved before you start, and primes recall with relevant context.`, {
803
803
  topic: z.string().describe('What task are you starting? (3-15 words)'),
804
804
  files: z.array(z.string()).optional().default([])
@@ -849,13 +849,13 @@ This ensures your state is saved before you start, and primes recall with releva
849
849
  }],
850
850
  };
851
851
  });
852
- server.tool('memory_task_end', `Signal that you've finished a significant task. Writes a summary memory and auto-checkpoints.
853
-
854
- CALL THIS when you finish:
855
- - A multi-step operation
856
- - Before switching to a different topic
857
- - At the end of a work session
858
-
852
+ server.tool('memory_task_end', `Signal that you've finished a significant task. Writes a summary memory and auto-checkpoints.
853
+
854
+ CALL THIS when you finish:
855
+ - A multi-step operation
856
+ - Before switching to a different topic
857
+ - At the end of a work session
858
+
859
859
  This captures what was accomplished so future sessions can recall it.`, {
860
860
  summary: z.string().describe('What was accomplished? Include key outcomes, decisions, and any issues.'),
861
861
  tags: z.array(z.string()).optional().default([])
@@ -928,14 +928,14 @@ This captures what was accomplished so future sessions can recall it.`, {
928
928
  }],
929
929
  };
930
930
  });
931
- server.tool('compress_output', `Compress a STRUCTURED tool output (JSON object/array, query rows, log records) into TOON —
932
- a compact, schema-aware tabular encoding — before putting it in your context. Cuts ~50-65%
933
- of the tokens on uniform arrays at zero comprehension cost (validated: models read TOON as
934
- accurately as JSON). Use this on large tool results you need to keep in context.
935
-
936
- Output-only and safe: it never changes the data. Non-JSON / prose is returned unchanged.
937
- TOON is only emitted when it reproduces the input exactly (self-verified round-trip);
938
- otherwise you get plain JSON back. When compressed, you also get a 'ref' — call
931
+ server.tool('compress_output', `Compress a STRUCTURED tool output (JSON object/array, query rows, log records) into TOON —
932
+ a compact, schema-aware tabular encoding — before putting it in your context. Cuts ~50-65%
933
+ of the tokens on uniform arrays at zero comprehension cost (validated: models read TOON as
934
+ accurately as JSON). Use this on large tool results you need to keep in context.
935
+
936
+ Output-only and safe: it never changes the data. Non-JSON / prose is returned unchanged.
937
+ TOON is only emitted when it reproduces the input exactly (self-verified round-trip);
938
+ otherwise you get plain JSON back. When compressed, you also get a 'ref' — call
939
939
  retrieve_original(ref) to get the verbatim source back if you ever need it.`, {
940
940
  output: z.string().describe('The tool output to compress — JSON text (preferred) or any string. Non-JSON is returned unchanged.'),
941
941
  min_saving_chars: z.number().optional().describe('Only emit TOON if it saves at least this many characters (default 40).'),
@@ -949,8 +949,8 @@ retrieve_original(ref) to get the verbatim source back if you ever need it.`, {
949
949
  content: [{ type: 'text', text: header + r.text }],
950
950
  };
951
951
  });
952
- server.tool('retrieve_original', `Retrieve the verbatim original text for a 'ref' returned by compress_output. Use this when
953
- you need the exact, uncompressed source (e.g. to pass it to another tool unchanged). Returns
952
+ server.tool('retrieve_original', `Retrieve the verbatim original text for a 'ref' returned by compress_output. Use this when
953
+ you need the exact, uncompressed source (e.g. to pass it to another tool unchanged). Returns
954
954
  an error if the ref has expired (originals are kept for the most recent compressions only).`, {
955
955
  ref: z.string().describe('The ref handle returned by compress_output (e.g. "awm_orig_12").'),
956
956
  }, async (params) => {
@@ -208,6 +208,7 @@ export interface ActivationQuery {
208
208
  */
209
209
  requireConfidence?: number;
210
210
  internal?: boolean;
211
+ spread?: boolean;
211
212
  memoryType?: MemoryType;
212
213
  mode?: QueryMode;
213
214
  workspace?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"engram.d.ts","sourceRoot":"","sources":["../../src/types/engram.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAG3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,IAAI,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAGhB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;IAGtB,KAAK,EAAE,WAAW,CAAC;IACnB,GAAG,EAAE,MAAM,GA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,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-working-memory",
3
- "version": "0.8.8",
3
+ "version": "0.9.1",
4
4
  "description": "Cognitive memory layer for AI agents — activation-based retrieval, salience filtering, associative connections",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/cli.ts CHANGED
@@ -444,9 +444,13 @@ async function importMemories() {
444
444
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
445
445
  `);
446
446
 
447
+ // NOTE: associations.last_activated is NOT NULL on the engrams DB (storage/sqlite.ts),
448
+ // so importing into an existing store fails if it's omitted — and because import wraps
449
+ // memories+associations in ONE transaction, that rolls back the memories too (silent
450
+ // "empty store"). Set it alongside created_at. (migrate/merge paths already do this.)
447
451
  const insertAssoc = db.prepare(`
448
- INSERT INTO associations (id, from_engram_id, to_engram_id, weight, type, activation_count, created_at)
449
- VALUES (?, ?, ?, ?, ?, ?, datetime('now'))
452
+ INSERT INTO associations (id, from_engram_id, to_engram_id, weight, type, activation_count, created_at, last_activated)
453
+ VALUES (?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'))
450
454
  `);
451
455
 
452
456
  const importTx = db.transaction(() => {
@@ -47,6 +47,7 @@ import {
47
47
  type NoveltyResult,
48
48
  } from './salience.js';
49
49
  import { embed } from './embeddings.js';
50
+ import { extractMetaTags } from './auto-tagger.js';
50
51
  import { DEFAULT_AGENT_CONFIG } from '../types/agent.js';
51
52
 
52
53
  /** Confidence floor below which a matched engram is treated as "decaying out". */
@@ -444,6 +445,20 @@ async function createNewEngram(
444
445
  const tags = [...(input.tags ?? [])];
445
446
  if (isLowSalience && !tags.includes('low-salience')) tags.push('low-salience');
446
447
 
448
+ // Auto-tag meta-tags (default-OFF, AWM_AUTOTAG=1). extractMetaTags emits
449
+ // `entity:<ProperNoun>` and `cat:<category>` tags from concept+content. These
450
+ // are indexed in FTS5 (→ BM25 recall boost on entity/category terms) AND feed
451
+ // the Phase 3.7 entity-bridge boost, which is otherwise STARVED: that boost
452
+ // explicitly skips session/speaker/turn tags, so without `entity:` tags it has
453
+ // nothing to bridge on (inert on LoCoMo and underfed in real use). Gated +
454
+ // additive so existing callers' tags are untouched when off.
455
+ if (process.env.AWM_AUTOTAG === '1') {
456
+ const existing = new Set(tags.map(t => t.toLowerCase()));
457
+ for (const mt of extractMetaTags(input.concept, input.content)) {
458
+ if (!existing.has(mt.toLowerCase())) { tags.push(mt); existing.add(mt.toLowerCase()); }
459
+ }
460
+ }
461
+
447
462
  const engram = await store.createEngram({
448
463
  agentId: input.agentId,
449
464
  concept: input.concept,