mem0ai/mem0 · error · Error

Delete failed in underlying Langchain store: ${e}

Error message

Delete failed in underlying Langchain store: ${e}

What it means

delete() catches any exception from the underlying Langchain store's delete({ filter: { _mem0_id: vectorId } }) call and rethrows wrapped. The adapter guesses a filter-based delete signature because Langchain's delete API varies by implementation; if the store expects ids or a different filter shape, it throws and the wrapper surfaces it.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/langchain.ts:185

  async delete(vectorId: string): Promise<void> {
    // Check if the underlying store supports deletion by ID
    if (typeof (this.lcStore as any).delete === "function") {
      try {
        // We need to delete based on our stored _mem0_id.
        // Langchain's delete often takes its own internal IDs or filter.
        // Attempting deletion via filter is the most likely approach.
        console.warn(
          "LangchainVectorStore: Attempting delete via filter on '_mem0_id'. Success depends on the specific Langchain VectorStore's delete implementation.",
        );
        await (this.lcStore as any).delete({ filter: { _mem0_id: vectorId } });
        // OR if it takes IDs directly (less common for *our* IDs):
        // await (this.lcStore as any).delete({ ids: [vectorId] });
      } catch (e) {
        console.error(
          `LangchainVectorStore: Delete failed. Underlying store's delete method might expect different arguments or filters. Error: ${e}`,
        );
        throw new Error(`Delete failed in underlying Langchain store: ${e}`);
      }
    } else {
      console.error(
        `LangchainVectorStore: The underlying Langchain store instance does not seem to support a 'delete' method.`,
      );
      throw new Error(
        "Method 'delete' not available on the provided Langchain VectorStore client.",
      );
    }
  }

  async list(
    filters?: SearchFilters,
    topK: number = 100,
  ): Promise<[VectorStoreResult[], number]> {
    // No standard list method in Langchain core interface.
    console.error(
      `LangchainVectorStore: The 'list' method is not supported by the generic LangchainVectorStore wrapper.`,

View on GitHub (pinned to 001c235229)

Solutions

  1. Read the underlying store's delete() signature; if it takes ids, call it directly: lcStore.delete({ ids: [vectorId] }) instead of the wrapper.
  2. Ensure inserts actually store the mem0 id under the _mem0_id metadata key (the adapter does this; custom pipelines may not).
  3. Inspect the wrapped error message — it contains the store's own reason (permissions, connectivity, not found).
  4. Wrap delete in try-catch and treat 'not found' style errors as success if idempotency is desired.

Example fix

// before
await store.delete(vectorId); // filter-based delete not supported by store

// after
const lcStore = store.getUnderlyingStore?.() ?? lcStoreRef;
await lcStore.delete({ ids: [vectorId] });
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await store.delete(vectorId);
} catch (e) {
  const msg = e instanceof Error ? e.message : String(e);
  if (msg.includes('Delete failed in underlying Langchain store')) {
    // inspect inner message; if the store takes ids, call it directly:
    // await lcStore.delete({ ids: [vectorId] });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling store.delete(id) when the underlying store's delete method has a different signature (e.g. expects { ids: [...] }), the filter field name differs, the store cannot filter on metadata during delete, or the store raises on missing permissions/not-found.

Common situations: Using community stores whose delete takes ids rather than a filter; the metadata key used for deletion not matching _mem0_id; store-side errors (connection loss, index missing) bubbling through delete.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/70d5ef7da056eafd. Report an issue: GitHub.