{"record":{"id":"bcac4c9ff2822c24","repo":"mem0ai/mem0","slug":"method-delete-not-available-on-the-provided-lang","errorCode":null,"errorMessage":"Method 'delete' not available on the provided Langchain VectorStore client.","messagePattern":"Method 'delete' not available on the provided Langchain VectorStore client\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/langchain.ts","lineNumber":191,"sourceCode":"        // Langchain's delete often takes its own internal IDs or filter.\n        // Attempting deletion via filter is the most likely approach.\n        console.warn(\n          \"LangchainVectorStore: Attempting delete via filter on '_mem0_id'. Success depends on the specific Langchain VectorStore's delete implementation.\",\n        );\n        await (this.lcStore as any).delete({ filter: { _mem0_id: vectorId } });\n        // OR if it takes IDs directly (less common for *our* IDs):\n        // await (this.lcStore as any).delete({ ids: [vectorId] });\n      } catch (e) {\n        console.error(\n          `LangchainVectorStore: Delete failed. Underlying store's delete method might expect different arguments or filters. Error: ${e}`,\n        );\n        throw new Error(`Delete failed in underlying Langchain store: ${e}`);\n      }\n    } else {\n      console.error(\n        `LangchainVectorStore: The underlying Langchain store instance does not seem to support a 'delete' method.`,\n      );\n      throw new Error(\n        \"Method 'delete' not available on the provided Langchain VectorStore client.\",\n      );\n    }\n  }\n\n  async list(\n    filters?: SearchFilters,\n    topK: number = 100,\n  ): Promise<[VectorStoreResult[], number]> {\n    // No standard list method in Langchain core interface.\n    console.error(\n      `LangchainVectorStore: The 'list' method is not supported by the generic LangchainVectorStore wrapper.`,\n    );\n    throw new Error(\n      \"Method 'list' not supported by LangchainVectorStore wrapper.\",\n    );\n    // Could potentially be implemented if the underlying store has a specific list/scroll/query capability.\n  }","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/langchain.ts#L173-L209","documentation":"delete() checks typeof store.delete === 'function' before attempting deletion; Langchain's abstract VectorStore interface does not guarantee delete, so adapters without it cannot remove documents. The adapter throws with a console.error rather than silently pretending deletion succeeded — important because silent no-op deletes leak memories.","triggerScenarios":"Calling store.delete(id) when the wrapped Langchain store class implements addVectors/similaritySearchVectorWithScore but not delete (true for some minimal community stores and custom implementations).","commonSituations":"Using a lightweight custom or third-party Langchain store for search-only workloads, then wiring it into mem0 where Memory.add() attempts to delete superseded memories; prototyping with MemoryVectorStore variants lacking delete.","solutions":["Use a Langchain store implementation that supports delete (FAISS, Chroma, PGVector, Qdrant adapters).","Implement delete({ filter }) or delete({ ids }) on your custom store class.","Avoid memory-update flows (which delete) with delete-incapable stores."],"exampleFix":"// before\nclass MyStore { addVectors() {} similaritySearchVectorWithScore() {} }\nawait store.delete(id); // throws\n\n// after\nclass MyStore {\n  addVectors() {}\n  similaritySearchVectorWithScore() {}\n  async delete(opts: { filter?: any; ids?: string[] }) { /* remove docs */ }\n}\nawait store.delete(id);","handlingStrategy":"type-guard","validationCode":"if (typeof (config.client as any).delete !== 'function') {\n  throw new Error('Chosen Langchain store cannot delete; memory updates will fail. Use a delete-capable store.');\n}","typeGuard":"const isDeletableStore = (c: unknown): c is { delete(opts: unknown): Promise<void> } =>\n  typeof c === 'object' && c !== null && typeof (c as any).delete === 'function';","tryCatchPattern":"try {\n  await store.delete(vectorId);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"'delete' not available\")) {\n    // cannot be worked around via this wrapper: switch store or implement delete on it\n  }\n  throw e;\n}","preventionTips":["Verify delete support on the store class before wiring it into Memory.","Use mainstream Langchain stores (FAISS, Chroma, PGVector) for full CRUD.","Avoid memory-update flows with search-only stores."],"tags":["langchain","delete","unsupported-operation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}