diff --git a/AGENTS.md b/AGENTS.md
index 762b9b745..6f64946fc 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -116,7 +116,7 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import).
## Current Stats (v0.9.28)
-- 53 MCP tools (8 visible by default, `AGENTMEMORY_TOOLS=all` for all)
+- 54 MCP tools (8 visible by default, `AGENTMEMORY_TOOLS=all` for all)
- 129 REST endpoints
- 6 MCP resources, 3 MCP prompts
- 12 hooks, 15 skills
diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.md
index f368220b3..18c78d3bf 100644
--- a/INSTALL_FOR_AGENTS.md
+++ b/INSTALL_FOR_AGENTS.md
@@ -80,7 +80,7 @@ agentmemory connect
If you cannot tell which agent you are, default to `claude-code`. After wiring, restart the agent or run its MCP reload command (for example `/mcp` in Claude Code) so it picks up the server.
-Expect: the agent now lists agentmemory's tools. With the server running you should see the full set of 53 tools (for example `memory_save`, `memory_smart_search`, `memory_sessions`). If you see only 7 tools, the MCP shim could not reach a server, see Troubleshooting.
+Expect: the agent now lists agentmemory's tools. With the server running you should see the full set of 54 tools (for example `memory_save`, `memory_smart_search`, `memory_sessions`). If you see only 7 tools, the MCP shim could not reach a server, see Troubleshooting.
## 6. Install native skills
@@ -128,7 +128,7 @@ These are off by default because they spend tokens. Enable them only if the user
## Tool surface
-The MCP server exposes 53 tools by default (`--tools all`). Use `--tools core` (or `AGENTMEMORY_TOOLS=core`) for a lean 8-tool set on hosts with tight tool limits. The 8 core tools cover save, recall, consolidate, smart search, sessions, diagnose, lesson save, and reflect.
+The MCP server exposes 54 tools by default (`--tools all`). Use `--tools core` (or `AGENTMEMORY_TOOLS=core`) for a lean 8-tool set on hosts with tight tool limits. The 8 core tools cover save, recall, consolidate, smart search, sessions, diagnose, lesson save, and reflect.
## Lifecycle commands
diff --git a/README.md b/README.md
index 0c4ea33e0..332e2010c 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@
-
+
@@ -511,7 +511,7 @@ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cl
### Claude Code (one block, paste it)
```text
-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, 15 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.
+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, 15 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 54 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.
```
#### Claude Code without the plugin install (MCP-standalone path)
@@ -540,7 +540,7 @@ codex plugin add agentmemory@agentmemory
The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:
-- `@agentmemory/mcp` as an MCP server (proxies all 53 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
+- `@agentmemory/mcp` as an MCP server (proxies all 54 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
- 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
- 8 invocable skills: `/recall`, `/remember`, `/session-history`, `/forget`, `/recap`, `/handoff`, `/commit-context`, `/commit-history`, plus 7 reference skills the agent loads on demand (MCP tools, REST API, config, agents, hooks, architecture, and the skill-authoring guide)
@@ -574,7 +574,7 @@ copilot plugin install rohitg00/agentmemory:plugin
OpenClaw (paste this prompt)
```text
-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 53 memory tools:
+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 54 memory tools:
{
"mcpServers": {
@@ -599,7 +599,7 @@ Full guide: [`integrations/openclaw/`](integrations/openclaw/)
Hermes Agent (paste this prompt)
```text
-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 53 memory tools:
+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 54 memory tools:
mcp_servers:
agentmemory:
@@ -956,11 +956,11 @@ npm install @huggingface/transformers
-53 tools, 6 resources, 3 prompts, and 15 skills, the most comprehensive MCP memory toolkit for any agent.
+54 tools, 6 resources, 3 prompts, and 15 skills, the most comprehensive MCP memory toolkit for any agent.
-> **MCP shim vs full server:** the published `@agentmemory/mcp` package is a thin shim. It exposes the full 53-tool surface **only when it can reach a running agentmemory server** via `AGENTMEMORY_URL` (proxy mode). With no server reachable, the shim falls back to a 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). The `AGENTMEMORY_TOOLS=core|all` env var is a *server-side* flag — setting it in the shim's `env` block has no effect. If you see only 7 tools in Cursor / OpenCode / Gemini CLI, start `npx @agentmemory/agentmemory` (or the Docker stack) and set `AGENTMEMORY_URL=http://localhost:3111`.
+> **MCP shim vs full server:** the published `@agentmemory/mcp` package is a thin shim. It exposes the full 54-tool surface **only when it can reach a running agentmemory server** via `AGENTMEMORY_URL` (proxy mode). With no server reachable, the shim falls back to a 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). The `AGENTMEMORY_TOOLS=core|all` env var is a *server-side* flag — setting it in the shim's `env` block has no effect. If you see only 7 tools in Cursor / OpenCode / Gemini CLI, start `npx @agentmemory/agentmemory` (or the Docker stack) and set `AGENTMEMORY_URL=http://localhost:3111`.
-### 53 Tools
+### 54 Tools
Core tools (always available)
@@ -982,7 +982,7 @@ npm install @huggingface/transformers
-Extended tools (53 total — set AGENTMEMORY_TOOLS=all)
+Extended tools (54 total — set AGENTMEMORY_TOOLS=all)
| Tool | Description |
|------|-------------|
@@ -1490,7 +1490,7 @@ Create `~/.agentmemory/.env`:
# USER_ID=
# TEAM_MODE=private
-# Tool visibility: "core" (8 tools, lean fallback) or "all" (53 tools)
+# Tool visibility: "core" (8 tools, lean fallback) or "all" (54 tools)
# AGENTMEMORY_TOOLS=core
```
diff --git a/assets/tags/light/stat-tools.svg b/assets/tags/light/stat-tools.svg
index e6d598532..9ed07e9fa 100644
--- a/assets/tags/light/stat-tools.svg
+++ b/assets/tags/light/stat-tools.svg
@@ -1,5 +1,5 @@
-
-
+
diff --git a/plugin/plugin.json b/plugin/plugin.json
index 7d9cfca11..90d248c58 100644
--- a/plugin/plugin.json
+++ b/plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "agentmemory",
"version": "0.9.28",
- "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 53 MCP tools, 15 skills, real-time viewer.",
+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 54 MCP tools, 15 skills, real-time viewer.",
"author": {
"name": "Rohit Ghumare",
"url": "https://github.com/rohitg00"
diff --git a/plugin/skills/agentmemory-mcp-tools/REFERENCE.md b/plugin/skills/agentmemory-mcp-tools/REFERENCE.md
index 0c556fc77..b6b185835 100644
--- a/plugin/skills/agentmemory-mcp-tools/REFERENCE.md
+++ b/plugin/skills/agentmemory-mcp-tools/REFERENCE.md
@@ -3,7 +3,7 @@
Generated from `src/mcp/tools-registry.ts`. Do not edit the block below by hand; run `npm run skills:gen` after changing the registry.
-agentmemory exposes 53 MCP tools. 8 are in the lean core set (`--tools core` or `AGENTMEMORY_TOOLS=core`); the rest load with `--tools all` (default).
+agentmemory exposes 54 MCP tools. 8 are in the lean core set (`--tools core` or `AGENTMEMORY_TOOLS=core`); the rest load with `--tools all` (default).
| Tool | Core | Parameters | Purpose |
| --- | --- | --- | --- |
@@ -28,6 +28,7 @@ agentmemory exposes 53 MCP tools. 8 are in the lean core set (`--tools core` or
| `memory_heal` | | `categories`: string, `dryRun`: string | Auto-fix all fixable issues found by diagnostics. Unblocks stuck actions, expires stale leases, cleans up orphaned data. |
| `memory_insight_list` | | `project`: string, `minConfidence`: number, `limit`: number | List synthesized insights, higher-order observations derived from patterns across memories, lessons, and crystals. |
| `memory_lease` | | `actionId`*: string, `agentId`*: string, `operation`*: string, `result`: string, `ttlMs`: number | Acquire, release, or renew an exclusive lease on an action. Prevents multiple agents from working on the same thing. |
+| `memory_lesson_delete` | | `lessonId`*: string | Soft-delete a lesson by id. Deleted lessons are excluded from recall and list; re-saving the same content creates a fresh lesson. |
| `memory_lesson_recall` | | `query`*: string, `project`: string, `minConfidence`: number, `limit`: number | Search lessons by query. Returns lessons sorted by confidence and recency. Use to check what the agent has learned before making decisions. |
| `memory_lesson_save` | yes | `content`*: string, `context`: string, `confidence`: number, `project`: string, `tags`: string | Save a lesson learned from this session. Lessons have confidence scores that strengthen when reinforced and decay when not used. Duplicate content auto-strengthens the existing lesson. |
| `memory_mesh_sync` | | `peerId`: string, `direction`: string | Sync memories and actions with peer agentmemory instances for multi-agent collaboration. |
diff --git a/plugin/skills/agentmemory-rest-api/REFERENCE.md b/plugin/skills/agentmemory-rest-api/REFERENCE.md
index 77e0a5e4d..d12ff4610 100644
--- a/plugin/skills/agentmemory-rest-api/REFERENCE.md
+++ b/plugin/skills/agentmemory-rest-api/REFERENCE.md
@@ -65,6 +65,7 @@ The REST API is the primary surface. All paths are under `http://localhost:3111`
| POST | `/agentmemory/leases/release` |
| POST | `/agentmemory/leases/renew` |
| POST | `/agentmemory/lessons` |
+| POST | `/agentmemory/lessons/delete` |
| POST | `/agentmemory/lessons/search` |
| POST | `/agentmemory/lessons/strengthen` |
| GET | `/agentmemory/livez` |
diff --git a/src/functions/lessons.ts b/src/functions/lessons.ts
index 9e69f464f..0314298ce 100644
--- a/src/functions/lessons.ts
+++ b/src/functions/lessons.ts
@@ -203,6 +203,32 @@ export function registerLessonsFunctions(sdk: ISdk, kv: StateKV): void {
},
);
+ sdk.registerFunction("mem::lesson-delete",
+ async (data: { lessonId: string }) => {
+ if (!data.lessonId) {
+ return { success: false, error: "lessonId is required" };
+ }
+
+ const lesson = await kv.get(KV.lessons, data.lessonId);
+ if (!lesson || lesson.deleted) {
+ return { success: false, error: "lesson not found" };
+ }
+
+ lesson.deleted = true;
+ lesson.updatedAt = new Date().toISOString();
+
+ await kv.set(KV.lessons, lesson.id, lesson);
+
+ try {
+ await recordAudit(kv, "lesson_delete", "mem::lesson-delete", [
+ lesson.id,
+ ]);
+ } catch {}
+
+ return { success: true, lesson };
+ },
+ );
+
sdk.registerFunction("mem::lesson-decay-sweep",
async () => {
const lessons = await kv.list(KV.lessons);
diff --git a/src/functions/remember.ts b/src/functions/remember.ts
index 5cbfb6931..759fddb5f 100644
--- a/src/functions/remember.ts
+++ b/src/functions/remember.ts
@@ -190,15 +190,17 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {
if (data.memoryId) {
const mem = await kv.get(KV.memories, data.memoryId);
- await kv.delete(KV.memories, data.memoryId);
- if (mem?.imageRef) {
- await decrementImageRef(kv, sdk, mem.imageRef);
+ if (mem) {
+ await kv.delete(KV.memories, data.memoryId);
+ if (mem.imageRef) {
+ await decrementImageRef(kv, sdk, mem.imageRef);
+ }
+ await deleteAccessLog(kv, data.memoryId);
+ getSearchIndex().remove(data.memoryId);
+ vectorIndexRemove(data.memoryId);
+ deletedMemoryIds.push(data.memoryId);
+ deleted++;
}
- await deleteAccessLog(kv, data.memoryId);
- getSearchIndex().remove(data.memoryId);
- vectorIndexRemove(data.memoryId);
- deletedMemoryIds.push(data.memoryId);
- deleted++;
}
if (
diff --git a/src/mcp/server.ts b/src/mcp/server.ts
index dbca07d9b..13240003b 100644
--- a/src/mcp/server.ts
+++ b/src/mcp/server.ts
@@ -1122,6 +1122,16 @@ export function registerMcpEndpoints(
return { status_code: 200, body: { content: [{ type: "text", text: JSON.stringify(lessonRecallResult, null, 2) }] } };
}
+ case "memory_lesson_delete": {
+ if (typeof args.lessonId !== "string" || !args.lessonId.trim()) {
+ return { status_code: 400, body: { error: "lessonId is required" } };
+ }
+ const lessonDeleteResult = await sdk.trigger({ function_id: "mem::lesson-delete", payload: {
+ lessonId: args.lessonId.trim(),
+ } });
+ return { status_code: 200, body: { content: [{ type: "text", text: JSON.stringify(lessonDeleteResult, null, 2) }] } };
+ }
+
case "memory_reflect": {
const reflectResult = await sdk.trigger({ function_id: "mem::reflect", payload: {
project: args.project,
diff --git a/src/mcp/standalone.ts b/src/mcp/standalone.ts
index dd66ecb1d..1ace150b1 100644
--- a/src/mcp/standalone.ts
+++ b/src/mcp/standalone.ts
@@ -339,7 +339,7 @@ async function handleProxyGeneric(
handle: ProxyHandle,
): Promise<{ content: Array<{ type: string; text: string }> }> {
// Forward to the server's full MCP surface so non-Claude clients can
- // reach all 53 tools (lessons, sentinels, slots, signals, graph, …)
+ // reach all 54 tools (lessons, sentinels, slots, signals, graph, …)
// instead of being capped at the 7 IMPLEMENTED_TOOLS set baked into
// this shim. The server validates arguments per tool.
const result = (await handle.call("/agentmemory/mcp/call", {
diff --git a/src/mcp/tools-registry.ts b/src/mcp/tools-registry.ts
index c4df3499c..464cb3b0c 100644
--- a/src/mcp/tools-registry.ts
+++ b/src/mcp/tools-registry.ts
@@ -799,6 +799,18 @@ export const V070_TOOLS: McpToolDef[] = [
required: ["query"],
},
},
+ {
+ name: "memory_lesson_delete",
+ description:
+ "Soft-delete a lesson by id. Deleted lessons are excluded from recall and list; re-saving the same content creates a fresh lesson.",
+ inputSchema: {
+ type: "object",
+ properties: {
+ lessonId: { type: "string", description: "The lesson id (lsn_...)" },
+ },
+ required: ["lessonId"],
+ },
+ },
{
name: "memory_obsidian_export",
description:
@@ -950,8 +962,8 @@ export function getAllTools(): McpToolDef[] {
}
// default switched from "core" (8 essential tools) to "all"
-// (full 53-tool surface). README and plugin manifests have always
-// advertised 53 tools "in proxy mode"; the old default left OpenCode /
+// (full 54-tool surface). README and plugin manifests have always
+// advertised 54 tools "in proxy mode"; the old default left OpenCode /
// Claude Code users seeing 8 with no indication the other tools existed.
// Users who want the lean essentials can still set AGENTMEMORY_TOOLS=core.
export function getVisibleTools(): McpToolDef[] {
diff --git a/src/triggers/api.ts b/src/triggers/api.ts
index ce339ae05..701e87374 100644
--- a/src/triggers/api.ts
+++ b/src/triggers/api.ts
@@ -3197,6 +3197,21 @@ export function registerApiTriggers(
});
sdk.registerTrigger({ type: "http", function_id: "api::lesson-strengthen", config: { api_path: "/agentmemory/lessons/strengthen", http_method: "POST" } });
+ sdk.registerFunction("api::lesson-delete", async (req: ApiRequest) => {
+ const denied = checkAuth(req, secret);
+ if (denied) return denied;
+ const body = req.body as Record;
+ const lessonId = typeof body?.lessonId === "string" ? body.lessonId.trim() : "";
+ if (!lessonId) return { status_code: 400, body: { error: "lessonId is required" } };
+ const result = await sdk.trigger({ function_id: "mem::lesson-delete", payload: { lessonId } });
+ const resp = result as { success?: boolean; error?: string };
+ if (resp?.success === false && resp.error === "lesson not found") {
+ return { status_code: 404, body: { error: "lesson not found" } };
+ }
+ return { status_code: 200, body: result };
+ });
+ sdk.registerTrigger({ type: "http", function_id: "api::lesson-delete", config: { api_path: "/agentmemory/lessons/delete", http_method: "POST" } });
+
sdk.registerFunction("api::obsidian-export", async (req: ApiRequest) => {
const denied = checkAuth(req, secret);
if (denied) return denied;
diff --git a/src/types.ts b/src/types.ts
index 113daeae1..7cda80ffb 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -596,6 +596,7 @@ export interface AuditEntry {
| "lesson_save"
| "lesson_recall"
| "lesson_strengthen"
+ | "lesson_delete"
| "obsidian_export"
| "reflect"
| "insight_search"
diff --git a/test/lessons.test.ts b/test/lessons.test.ts
index 4a55003e1..b55fb5976 100644
--- a/test/lessons.test.ts
+++ b/test/lessons.test.ts
@@ -349,4 +349,107 @@ describe("Lessons", () => {
expect(after!.confidence).toBeGreaterThan(0.4);
});
});
+
+ describe("mem::lesson-delete", () => {
+ it("soft-deletes an existing lesson", async () => {
+ const saved = (await sdk.trigger("mem::lesson-save", {
+ content: "Delete me",
+ confidence: 0.7,
+ })) as { lesson: Lesson };
+
+ const result = (await sdk.trigger("mem::lesson-delete", {
+ lessonId: saved.lesson.id,
+ })) as { success: boolean; lesson: Lesson };
+
+ expect(result.success).toBe(true);
+ expect(result.lesson.deleted).toBe(true);
+
+ const stored = await kv.get("mem:lessons", saved.lesson.id);
+ expect(stored!.deleted).toBe(true);
+ });
+
+ it("excludes a soft-deleted lesson from recall and list", async () => {
+ const saved = (await sdk.trigger("mem::lesson-save", {
+ content: "Hide me from recall",
+ confidence: 0.9,
+ })) as { lesson: Lesson };
+
+ await sdk.trigger("mem::lesson-delete", { lessonId: saved.lesson.id });
+
+ const recall = (await sdk.trigger("mem::lesson-recall", {
+ query: "hide recall",
+ })) as { lessons: Lesson[] };
+ expect(recall.lessons.some((l) => l.id === saved.lesson.id)).toBe(false);
+
+ const list = (await sdk.trigger("mem::lesson-list", {})) as {
+ lessons: Lesson[];
+ };
+ expect(list.lessons.some((l) => l.id === saved.lesson.id)).toBe(false);
+ });
+
+ it("returns not found for an already-deleted lesson", async () => {
+ const saved = (await sdk.trigger("mem::lesson-save", {
+ content: "Double delete",
+ })) as { lesson: Lesson };
+
+ await sdk.trigger("mem::lesson-delete", { lessonId: saved.lesson.id });
+ const second = (await sdk.trigger("mem::lesson-delete", {
+ lessonId: saved.lesson.id,
+ })) as { success: boolean; error?: string };
+
+ expect(second.success).toBe(false);
+ expect(second.error).toBe("lesson not found");
+ });
+
+ it("returns not found for a nonexistent lessonId", async () => {
+ const result = (await sdk.trigger("mem::lesson-delete", {
+ lessonId: "lsn_nonexistent",
+ })) as { success: boolean; error?: string };
+
+ expect(result.success).toBe(false);
+ expect(result.error).toBe("lesson not found");
+ });
+
+ it("rejects a missing lessonId", async () => {
+ const result = (await sdk.trigger("mem::lesson-delete", {})) as {
+ success: boolean;
+ error?: string;
+ };
+
+ expect(result.success).toBe(false);
+ expect(result.error).toBe("lessonId is required");
+ });
+
+ it("creates a fresh lesson when deleted content is re-saved", async () => {
+ const saved = (await sdk.trigger("mem::lesson-save", {
+ content: "Resave after delete",
+ })) as { lesson: Lesson };
+
+ await sdk.trigger("mem::lesson-delete", { lessonId: saved.lesson.id });
+
+ const resaved = (await sdk.trigger("mem::lesson-save", {
+ content: "Resave after delete",
+ })) as { action: string; lesson: Lesson };
+
+ expect(resaved.action).toBe("created");
+ expect(resaved.lesson.id).toBe(saved.lesson.id);
+ expect(resaved.lesson.deleted).toBeUndefined();
+ });
+
+ it("records a lesson_delete audit row", async () => {
+ const saved = (await sdk.trigger("mem::lesson-save", {
+ content: "Audited delete",
+ })) as { lesson: Lesson };
+
+ await sdk.trigger("mem::lesson-delete", { lessonId: saved.lesson.id });
+
+ const auditRows = (await kv.list("mem:audit")) as Array<{
+ operation: string;
+ targetIds: string[];
+ }>;
+ const row = auditRows.find((r) => r.operation === "lesson_delete");
+ expect(row).toBeDefined();
+ expect(row!.targetIds).toEqual([saved.lesson.id]);
+ });
+ });
});
diff --git a/test/remember-forget-audit.test.ts b/test/remember-forget-audit.test.ts
index 7d17b543c..f875b7c07 100644
--- a/test/remember-forget-audit.test.ts
+++ b/test/remember-forget-audit.test.ts
@@ -122,6 +122,40 @@ describe("mem::forget audit coverage (issue #125)", () => {
const auditRows = await kv.list("mem:audit");
expect(auditRows).toHaveLength(0);
});
+
+ // Regression coverage for issue #1120: mem::forget must not report a
+ // deletion for ids it never touches (e.g. lesson ids live in KV.lessons,
+ // not KV.memories).
+ it("returns deleted: 0 for a nonexistent memoryId (lesson id)", async () => {
+ const sdk = mockSdk();
+ const kv = mockKV();
+ registerRememberFunction(sdk as never, kv as never);
+
+ const deleteSpy = vi.spyOn(kv, "delete");
+ const result = await sdk.trigger({
+ function_id: "mem::forget",
+ payload: { memoryId: "lsn_4f9cb07017a7c8ac" },
+ });
+
+ expect(result).toEqual({ success: true, deleted: 0 });
+ // No-op path must not touch the memories keyspace or search index.
+ expect(deleteSpy).not.toHaveBeenCalled();
+ expect(getSearchIndex().has("lsn_4f9cb07017a7c8ac")).toBe(false);
+ });
+
+ it("emits no audit row when memoryId does not exist", async () => {
+ const sdk = mockSdk();
+ const kv = mockKV();
+ registerRememberFunction(sdk as never, kv as never);
+
+ await sdk.trigger({
+ function_id: "mem::forget",
+ payload: { memoryId: "lsn_4f9cb07017a7c8ac" },
+ });
+
+ const auditRows = await kv.list("mem:audit");
+ expect(auditRows).toHaveLength(0);
+ });
});
// Delete paths must tear down the BM25 index entry and synchronously
diff --git a/test/tool-count-consistency.test.ts b/test/tool-count-consistency.test.ts
index 6e845df06..a5b7b5b50 100644
--- a/test/tool-count-consistency.test.ts
+++ b/test/tool-count-consistency.test.ts
@@ -9,7 +9,7 @@ vi.mock("../src/logger.js", () => ({
import { getAllTools, ESSENTIAL_TOOLS } from "../src/mcp/tools-registry.js";
const ROOT = join(import.meta.dirname, "..");
-const EXPECTED_TOOL_COUNT = 53;
+const EXPECTED_TOOL_COUNT = 54;
function readText(relativePath: string): string {
return readFileSync(join(ROOT, relativePath), "utf-8");