From 384da901287c71ae91b6cfd1fa2a5c6b5b4034c3 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Fri, 16 Oct 2026 21:38:22 +0000 Subject: [PATCH 1/4] feat(memory): sharpen MCP tool descriptions for reliable invocation Search previously gated recall behind "non-trivial task", which agents resolve by skipping, and gave no trigger for the highest-value moment: hitting an error mid-task. Store gave a vague post-work cue and treated dedupe as a preference rather than a procedure. - memory_searchKnowledge: trigger on ANY task plus IMMEDIATELY on errors/test failures, with an error-text example and a narrow skip-only clause - memory_storeKnowledge: explicit AFTER-completing + post-error/post- gotcha triggers, procedural search-first-then-update routing, and a one-line do-not-store list - Schema fields: query accepts pasted error text; title written so a future agent knows when it applies - memory_updateKnowledge: cover additive updates ("or incomplete") Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> From 5900a8d0c273c85525ed2fe69449428d7d12cad8 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Fri, 16 Oct 2026 21:40:33 +0000 Subject: [PATCH 2/4] feat(memory): apply sharpened MCP tool descriptions Actual file changes for the previous commit (its pre-commit hook failure left the index unstaged, producing an empty commit). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> From ef6da7af55f3cbda86cf942abbff1b86836a1090 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Fri, 16 Oct 2026 21:41:52 +0000 Subject: [PATCH 3/4] feat(memory): apply sharpened MCP tool descriptions Actual file changes for the earlier empty commit (pre-commit hook failure had left the index unstaged). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> From 4ef6c1a575df2708e908582106cf873a1173799c Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Fri, 16 Oct 2026 21:42:59 +0000 Subject: [PATCH 4/4] feat(memory): apply sharpened MCP tool descriptions Actual file changes for the earlier empty commits (the pre-commit suite resets the index mid-run, producing empty commits). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- packages/memory/src/server.ts | 11 ++++++----- .../memory/tests/unit/server.descriptions.test.ts | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/memory/src/server.ts b/packages/memory/src/server.ts index d1114644c..46ac80c64 100644 --- a/packages/memory/src/server.ts +++ b/packages/memory/src/server.ts @@ -25,13 +25,14 @@ type ToolResponse = { const STORE_TOOL = { name: "memory_storeKnowledge", description: - "Persist verified, reusable knowledge for future sessions. After completing meaningful work, store decisions, conventions, gotchas, or fixes that a future agent would otherwise rediscover the hard way (e.g. 'This repo pins better-sqlite3 to 12.x; native builds fail on newer versions'). Prefer updating an existing item over storing a near-duplicate.", + "AFTER completing a task — and especially right after fixing an error, discovering a gotcha, or making a decision a future agent would otherwise rediscover the hard way — persist it as verified, reusable knowledge for future sessions (e.g. 'This repo pins better-sqlite3 to 12.x; native builds fail on newer versions'). Before storing, run memory_searchKnowledge on what you learned; if a matching item exists, use memory_updateKnowledge instead of creating a near-duplicate. Do not store secrets, raw logs, task progress, or one-off details.", inputSchema: { type: "object" as const, properties: { title: { type: "string", - description: "Short, explicit description of the rule (5-12 words, 10-100 chars)", + description: + "Short, explicit description of the rule, written so a future agent knows when it applies (5-12 words, 10-100 chars)", }, content: { type: "string", @@ -56,7 +57,7 @@ const STORE_TOOL = { const UPDATE_TOOL = { name: "memory_updateKnowledge", description: - "Correct an existing knowledge item by ID when you learn it is outdated or inaccurate — update it instead of storing a duplicate. First run memory_searchKnowledge to find the item and its ID; pass only the fields that change.", + "Correct an existing knowledge item by ID when you learn it is outdated, inaccurate, or incomplete — update it instead of storing a duplicate. First run memory_searchKnowledge to find the item and its ID; pass only the fields that change.", inputSchema: { type: "object" as const, properties: { @@ -90,14 +91,14 @@ const UPDATE_TOOL = { const SEARCH_TOOL = { name: "memory_searchKnowledge", description: - "Call BEFORE starting any non-trivial task to check for prior knowledge — this is cheap and prevents redoing solved work. Pass a short description of what you are about to do (e.g. 'wire MCP server into Gemini CLI settings' or 'fix vitest flaky teardown in cli package') and apply relevant results. Also call it when a task reveals a convention worth remembering later.", + "Call BEFORE starting ANY task — trivial or not — and again IMMEDIATELY when you hit an error, test failure, or surprising behavior during work. This check is cheap and prevents re-solving already-solved problems. Pass a short description of what you are about to do or the error you hit (e.g. 'wire MCP server into Gemini CLI settings', 'vitest flaky teardown in cli package', 'EPERM on npm ci in worktree'). Skip only for pure conversation with no action. Apply relevant results, and prefer them over re-deriving from scratch.", inputSchema: { type: "object" as const, properties: { query: { type: "string", description: - "Natural language task description to search for relevant knowledge (3-500 chars)", + "Natural language task description — or paste the error text you just hit — to search for relevant knowledge (3-500 chars)", }, contextTags: { type: "array", diff --git a/packages/memory/tests/unit/server.descriptions.test.ts b/packages/memory/tests/unit/server.descriptions.test.ts index e62a56b49..6bd0d6569 100644 --- a/packages/memory/tests/unit/server.descriptions.test.ts +++ b/packages/memory/tests/unit/server.descriptions.test.ts @@ -21,8 +21,9 @@ describe("memory MCP tool descriptions (always-loaded prompt surface)", () => { ]); }); - it("instructs the agent to search BEFORE non-trivial tasks, with an example", () => { - expect(SEARCH.description).toMatch(/BEFORE starting any non-trivial task/i); + it("instructs the agent to search BEFORE any task and on errors, with an example", () => { + expect(SEARCH.description).toMatch(/BEFORE starting any task/i); + expect(SEARCH.description).toMatch(/IMMEDIATELY when you hit an error/i); expect(SEARCH.description).toMatch(/e\.g\.|example|such as/i); expect(SEARCH.description!.length).toBeGreaterThan(80); }); @@ -32,6 +33,8 @@ describe("memory MCP tool descriptions (always-loaded prompt surface)", () => { /after completing|when you (have )?(just )?(verified|learned|solved)/i, ); expect(STORE.description).toMatch(/reusable/i); + expect(STORE.description).toMatch(/memory_updateKnowledge/i); + expect(STORE.description).toMatch(/instead of creating a near-duplicate/i); }); it("instructs the agent to update instead of duplicating when knowledge is wrong", () => {