Commit 07875ad
committed
update forget implementation in mcp (supermemoryai#773)
### 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.1 parent 9f7f415 commit 07875ad
1 file changed
Lines changed: 31 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
164 | 185 | | |
165 | 186 | | |
166 | 187 | | |
167 | 188 | | |
168 | | - | |
| 189 | + | |
169 | 190 | | |
170 | 191 | | |
171 | 192 | | |
| |||
176 | 197 | | |
177 | 198 | | |
178 | 199 | | |
179 | | - | |
| 200 | + | |
180 | 201 | | |
181 | 202 | | |
182 | 203 | | |
| 204 | + | |
| 205 | + | |
183 | 206 | | |
184 | 207 | | |
185 | 208 | | |
| |||
189 | 212 | | |
190 | 213 | | |
191 | 214 | | |
192 | | - | |
| 215 | + | |
193 | 216 | | |
194 | 217 | | |
195 | 218 | | |
| |||
198 | 221 | | |
199 | 222 | | |
200 | 223 | | |
201 | | - | |
| 224 | + | |
202 | 225 | | |
203 | 226 | | |
204 | 227 | | |
205 | 228 | | |
206 | 229 | | |
207 | 230 | | |
| 231 | + | |
208 | 232 | | |
209 | 233 | | |
210 | 234 | | |
| |||
0 commit comments