mem0ai/mem0 · error
At least one filter is required to delete all memories. If y
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.
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)
Solutions
- Scope the deletion: memory.deleteAll({ userId: 'u1' })
- To wipe everything (e.g. between test runs), call memory.reset() instead
- 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
- Reserve reset() for test/seed scripts; production deletes should always carry a user/agent/run scope
- Assert session entity IDs are non-empty strings before offering bulk delete
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
- messages array cannot contain only blank content. Provide at
- messages string cannot be empty. Provide non-empty content.
- One of the filters: userId, agentId or runId is required!
- filters must contain at least one of: user_id, agent_id, run
- At least one of text, metadata, or expirationDate must be pr
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/deb2ac24a3186d3e.
Report an issue: GitHub.