{"record":{"id":"c0b05f3ccdce45c3","repo":"mem0ai/mem0","slug":"method-update-not-supported-by-langchainvectorst","errorCode":null,"errorMessage":"Method 'update' not supported by LangchainVectorStore wrapper.","messagePattern":"Method 'update' not supported by LangchainVectorStore wrapper\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/langchain.ts","lineNumber":162,"sourceCode":"    );\n    throw new Error(\n      \"Method 'get' not reliably supported by LangchainVectorStore wrapper.\",\n    );\n    // Potential (inefficient) simulation:\n    // Perform a search with a filter like { _mem0_id: vectorId }, limit 1.\n    // This requires the underlying store to support filtering on _mem0_id.\n  }\n\n  async update(\n    vectorId: string,\n    vector: number[],\n    payload: Record<string, any>,\n  ): Promise<void> {\n    // Updates often require delete + add in Langchain.\n    console.error(\n      `LangchainVectorStore: The 'update' method is not directly supported. Use delete followed by insert.`,\n    );\n    throw new Error(\n      \"Method 'update' not supported by LangchainVectorStore wrapper.\",\n    );\n    // Possible implementation: Check if store has delete, call delete({_mem0_id: vectorId}), then insert.\n  }\n\n  async delete(vectorId: string): Promise<void> {\n    // Check if the underlying store supports deletion by ID\n    if (typeof (this.lcStore as any).delete === \"function\") {\n      try {\n        // We need to delete based on our stored _mem0_id.\n        // 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] });","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/langchain.ts#L144-L180","documentation":"update() is deliberately unimplemented: most Langchain stores have no in-place update, the canonical pattern being delete-then-add. The adapter throws rather than performing an incorrect partial mutation.","triggerScenarios":"Any Memory flow that ends in VectorStore.update(vectorId, vector, payload) — e.g. memory updates after LLM extraction — while using the langchain provider.","commonSituations":"Running Memory.add() with updates to existing memories over a langchain-backed store; migrating an app from another provider where update worked.","solutions":["Perform update manually: await store.delete(id) then store.insert([vector], [id], [payload]).","Wrap the adapter in a subclass implementing update as delete+insert if you control the store wiring.","If transparent updates are required, choose a vector store provider with native update support (qdrant, chroma, elasticsearch)."],"exampleFix":"// before\nawait store.update(vectorId, vector, payload); // throws\n\n// after\nawait store.delete(vectorId);\nawait store.insert([vector], [vectorId], [payload]);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await store.update(vectorId, vector, payload);\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Method 'update' not supported\")) {\n    await store.delete(vectorId);\n    await store.insert([vector], [vectorId], [payload]);\n    return;\n  }\n  throw e;\n}","preventionTips":["Implement updates as delete + insert from the start with the langchain provider.","Wrap the store in an adapter exposing update() implemented as delete+insert.","Pick a provider with native update if atomic updates matter."],"tags":["langchain","unsupported-operation","update","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}