Skip to content

fix(memory): stop reporting deletions that did not happen - #4738

Open
ConnorMoss02 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ConnorMoss02:fix/memory-delete-reporting
Open

fix(memory): stop reporting deletions that did not happen#4738
ConnorMoss02 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ConnorMoss02:fix/memory-delete-reporting

Conversation

@ConnorMoss02

@ConnorMoss02 ConnorMoss02 commented Sep 2, 2026

Copy link
Copy Markdown

Closes #4740

Problem

delete_entities, delete_observations and delete_relations report success no matter what matched:

structuredContent: { success: true, message: "Entities deleted successfully" }

The message is hardcoded, and the three manager methods return void, so nothing ever looks at whether a name existed. An agent that deletes "Alise" instead of "Alice" is told its memory is clean while the entity is still on disk, and nothing in the response contradicts that.

Ten lines above, addObservations throws Entity with name ${o.entityName} not found for exactly this condition, so the file already disagreed with itself about whether a missing entity is worth mentioning.

Approach

README.md documented "Silent operation if entity doesn't exist", so the tools still do not throw. This changes the response only:

  • Nothing new throws.
  • outputSchema is unchanged: still { success: boolean, message: string }.
  • When every target is found, the message is byte-identical to before, so a caller matching on "Entities deleted successfully" is unaffected.

Only the case that was previously untrue changes:

delete_entities(["Alice", "Alise"])
  → "Deleted 1 of 2 entities. Not found: Alise"

delete_observations([{ entityName: "Carol", observations: ["x"] }])
  → "Deleted 0 of 1 observations. Entities not found: Carol"

delete_relations([...one match, one miss...])
  → "Deleted 1 of 2 relations. The rest matched nothing."

Changes

  • src/memory/index.ts: the three manager methods return what they matched; the handlers report it.
  • src/memory/__tests__/delete-reporting.test.ts: 7 tests over the real KnowledgeGraphManager, no mocks.
  • src/memory/README.md: the three "Silent operation" bullets described the absence of an error, which is still true, but read as if the response said nothing either.

Validation

cd src/memory && npx tsc --noEmit && npx vitest run

62 passed across 5 files. Typecheck clean.

Confirmed the tests are load-bearing: with index.ts reverted, 6 of the 7 new tests fail.

Note

I put the tests in a new file rather than __tests__/index.test.ts, since #4692 is adding that file. Its delete tests assert on the persisted graph rather than the response text, so the two do not overlap.

delete_entities, delete_observations and delete_relations returned
success: true with a hardcoded "deleted successfully" message regardless
of what matched. An agent that mistypes an entity name is told its memory
is clean while the data is still on disk, and nothing in the response
contradicts that. addObservations throws for the same condition ten lines
above, so the file already disagreed with itself.

Staying quiet is deliberate and documented, so nothing throws and the
output schema is unchanged. The three manager methods now return what
they matched, and the handlers say so. A delete where everything is found
returns the same message it always did.

README updated: the three "Silent operation" bullets described the
absence of an error, which is still true, but read as if the response
said nothing either.
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.

memory: delete tools report success when nothing matched

1 participant