Skip to content

feat(memory): sharpen MCP tool descriptions for reliable invocation - #399

Merged
codeaholicguy merged 4 commits into
mainfrom
feat/memory-mcp-descriptions
Oct 17, 2026
Merged

codeaholicguy merged 4 commits into
mainfrom
feat/memory-mcp-descriptions

Conversation

@codeaholicguy

Copy link
Copy Markdown
Owner

Summary

Tightens the always-loaded MCP tool metadata in packages/memory/src/server.ts so agents retrieve memory before work and store after — without being told. Implements the top recommendations from the tool-metadata evaluation.

Two invocation failures being fixed:

  1. Skipped pre-task recall — search was gated behind "any non-trivial task". Agents systematically self-assess tasks as trivial, so the check was skipped exactly when it mattered. No during-task trigger existed either, so agents retried errors blind instead of recalling prior fixes.
  2. Missed/duplicate stores — store's "after completing meaningful work" cue was vague and missed the post-error/post-gotcha moment; dedupe was a soft preference rather than a procedure.

Before / after

Tool Before After
memory_searchKnowledge "Call BEFORE starting any non-trivial task… 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… Skip only for pure conversation with no action." (+ error-text example)
memory_storeKnowledge "Persist verified, reusable knowledge… After completing meaningful work… Prefer updating an existing item over storing a near-duplicate." "AFTER completing a task — and especially right after fixing an error, discovering a gotcha… Before storing, run memory_searchKnowledge; 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."
memory_updateKnowledge "outdated or inaccurate" "outdated, inaccurate, or incomplete" (covers additive updates)
search.query field "Natural language task description…" "Natural language task description — or paste the error text you just hit —…"
store.title field "Short, explicit description of the rule" "…written so a future agent knows when it applies"

server.descriptions.test.ts updated to pin the new phrasing while preserving its original intent (timing cue + example + dedupe cue); it now also asserts the error trigger and the store→update cross-reference.

Test plan

  • packages/memory: vitest — 23 files / 171 tests pass
  • Pre-commit hook: repo-wide fmt:check, lint, test (all 8 projects incl. Rust) pass
  • git diff origin/main — only server.ts + the descriptions test changed

Generated with Devin

codeaholicguy and others added 4 commits October 16, 2026 21:38
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>
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>
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>
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>
@codeaholicguy
codeaholicguy merged commit 31f5bb4 into main Oct 17, 2026
8 checks passed
@codeaholicguy
codeaholicguy deleted the feat/memory-mcp-descriptions branch October 17, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant