Skip to content

update forget implementation in mcp#773

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-07-update_forget_implementation_in_mcp
Mar 9, 2026
Merged

update forget implementation in mcp#773
graphite-app[bot] merged 1 commit intomainfrom
03-07-update_forget_implementation_in_mcp

Conversation

@sohamd22
Copy link
Contributor

@sohamd22 sohamd22 commented Mar 7, 2026

TL;DR

Enhanced the forgetMemory method to try exact content matching first, then fall back to semantic search with a high similarity threshold for more precise memory deletion.

What changed?

The forgetMemory method now uses a two-step approach: first attempting exact content matching via the API, and if that fails with a 404, falling back to semantic search with a similarity threshold of 0.85. The search method also accepts an optional threshold parameter. Error messages now distinguish between exact matches and semantic matches, including similarity scores in the response.

How to test?

  1. Call forgetMemory with the exact content of an existing memory to verify direct deletion
  2. Call forgetMemory with similar but not identical content to test the semantic search fallback
  3. Call forgetMemory with completely unrelated content to verify the "no matching memory found" response
  4. Verify that success messages indicate whether deletion used exact matching or semantic matching with similarity scores

Why make this change?

This approach provides more precise memory deletion by prioritizing exact matches while still offering a fallback for similar content. The high similarity threshold (0.85) ensures that only very similar memories are deleted when exact matches aren't found, reducing the risk of accidentally deleting unrelated memories.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app 07875ad Mar 09 2026, 07:02 PM

@sohamd22 sohamd22 self-assigned this Mar 7, 2026
Copy link
Contributor Author

sohamd22 commented Mar 7, 2026


How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sohamd22 sohamd22 marked this pull request as ready for review March 7, 2026 21:58
@graphite-app graphite-app bot requested a review from Dhravya March 7, 2026 21:58
@sohamd22 sohamd22 force-pushed the 03-07-update_forget_implementation_in_mcp branch from bf75808 to 15f1453 Compare March 7, 2026 22:46
@sohamd22 sohamd22 force-pushed the 03-07-update_forget_implementation_in_mcp branch from 15f1453 to 541604f Compare March 7, 2026 23:05
@graphite-app
Copy link

graphite-app bot commented Mar 9, 2026

Merge activity

### TL;DR

Enhanced the `forgetMemory` method to try exact content matching first, then fall back to semantic search with a high similarity threshold for more precise memory deletion.

### What changed?

The `forgetMemory` method now uses a two-step approach: first attempting exact content matching via the API, and if that fails with a 404, falling back to semantic search with a similarity threshold of 0.85. The search method also accepts an optional threshold parameter. Error messages now distinguish between exact matches and semantic matches, including similarity scores in the response.

### How to test?

1. Call `forgetMemory` with the exact content of an existing memory to verify direct deletion
2. Call `forgetMemory` with similar but not identical content to test the semantic search fallback
3. Call `forgetMemory` with completely unrelated content to verify the "no matching memory found" response
4. Verify that success messages indicate whether deletion used exact matching or semantic matching with similarity scores

### Why make this change?

This approach provides more precise memory deletion by prioritizing exact matches while still offering a fallback for similar content. The high similarity threshold (0.85) ensures that only very similar memories are deleted when exact matches aren't found, reducing the risk of accidentally deleting unrelated memories.
@graphite-app graphite-app bot force-pushed the 03-07-update_forget_implementation_in_mcp branch from 541604f to 07875ad Compare March 9, 2026 18:59
@graphite-app graphite-app bot merged commit 07875ad into main Mar 9, 2026
4 of 6 checks passed
Comment on lines +167 to +177
})

return {
success: true,
message: `Successfully forgot memory (exact match) with ID: ${result.id}`,
containerTag: this.containerTag,
}
} catch (error: any) {
// If not 404, it's a real error - re-throw it
if (error?.status !== 404) {
throw error
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code incorrectly assumes this.client.memories.forget() returns an object with an id. Accessing result.id will cause a TypeError because the function likely returns void.
Severity: HIGH

Suggested Fix

Remove the assignment of the return value from this.client.memories.forget() to the result variable. Update the success message to indicate successful deletion without referencing a non-existent result.id, as the function does not appear to return any value.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: apps/mcp/src/client.ts#L164-L177

Potential issue: The code calls `this.client.memories.forget()` and assigns its return
value to `result`, then attempts to access `result.id`. Evidence from other parts of the
codebase suggests that `memories.forget()` returns `void` or `undefined`. This
discrepancy will cause a `TypeError` when `result.id` is accessed. The existing `catch`
block is not designed to handle a `TypeError`, so the function will throw an unhandled
error even when the memory deletion operation succeeds, breaking the intended
functionality of this new code path.

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.

2 participants