mem0ai/mem0 · error

At least one filter is required to delete all memories. If…

Error message

At least one filter is required to delete all memories. If you want to delete all memories, use the `reset()` method.

What it means

Thrown by Memory.deleteAll() when none of userId, agentId, or runId is provided in the config. Bulk deletion must be entity-scoped; the message explicitly points to reset() for the wipe-everything use case. The check runs after validateAndTrimEntityId normalizes the camelCase params, so whitespace-only IDs also end up here.

Solutions

  1. Scope the deletion: memory.deleteAll({ userId: 'u1' })
  2. To wipe everything (e.g. between test runs), call memory.reset() instead
  3. If IDs come from session state, assert they are non-empty before calling

Example fix

// before
await memory.deleteAll({});

// after
await memory.deleteAll({ userId: 'alice' });
// or wipe everything:
await memory.reset();
Defensive patterns

Strategy: validation

Validate before calling

if (!userId && !agentId && !runId) {
  throw new Error('deleteAll requires a scope; use reset() to wipe everything');
}
await memory.deleteAll({ userId, agentId, runId });

Prevention

When it happens

Trigger: Calling memory.deleteAll({}) or memory.deleteAll({ userId: ' ' }) — after trimming, filters is empty and Object.keys(filters).length === 0.

Common situations: Trying to clear the whole store for tests by calling deleteAll() with no args; passing entity IDs that are empty strings from an unset session; confusing deleteAll (scoped) with reset (global).

Related errors


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

Appendix: source

Thrown at mem0-ts/src/oss/src/memory/index.ts:1738

  ): Promise<{ message: string }> {
    await this._ensureInitialized();
    await this._captureEvent("delete_all", {
      has_user_id: !!config.userId,
      has_agent_id: !!config.agentId,
      has_run_id: !!config.runId,
    });
    const userId = validateAndTrimEntityId(config.userId, "userId");
    const agentId = validateAndTrimEntityId(config.agentId, "agentId");
    const runId = validateAndTrimEntityId(config.runId, "runId");

    // Convert camelCase entity params to snake_case for filters (matches storage and search/getAll)
    const filters: SearchFilters = {};
    if (userId) filters.user_id = userId;
    if (agentId) filters.agent_id = agentId;
    if (runId) filters.run_id = runId;

    if (!Object.keys(filters).length) {
      throw new Error(
        "At least one filter is required to delete all memories. If you want to delete all memories, use the `reset()` method.",
      );
    }

    let deletedCount = 0;
    const seenBatches = new Set<string>();

    while (true) {
      const [batch] = await this.vectorStore.list(
        filters,
        DELETE_ALL_BATCH_SIZE,
      );
      if (!batch.length) {
        break;
      }
      const batchKey = batch
        .map((memory) => String(memory.id))
        .sort()

View on GitHub (pinned to 001c235229)