fix(memory): stop reporting deletions that did not happen - #4738
Open
ConnorMoss02 wants to merge 1 commit into
Open
fix(memory): stop reporting deletions that did not happen#4738ConnorMoss02 wants to merge 1 commit into
ConnorMoss02 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4740
Problem
delete_entities,delete_observationsanddelete_relationsreport success no matter what matched: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,
addObservationsthrowsEntity with name ${o.entityName} not foundfor exactly this condition, so the file already disagreed with itself about whether a missing entity is worth mentioning.Approach
README.mddocumented "Silent operation if entity doesn't exist", so the tools still do not throw. This changes the response only:outputSchemais unchanged: still{ success: boolean, message: string }."Entities deleted successfully"is unaffected.Only the case that was previously untrue changes:
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 realKnowledgeGraphManager, 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
62 passed across 5 files. Typecheck clean.
Confirmed the tests are load-bearing: with
index.tsreverted, 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.