mem0ai/mem0 · error
messages array cannot contain only blank content. Provide at
Error message
messages array cannot contain only blank content. Provide at least one message with non-empty content.
What it means
Thrown by the OSS Memory.add() method when the messages argument is an array in which every message has string content that is empty or whitespace-only. The SDK refuses to spend an LLM/embedding call on input that carries no information. It is a client-side validation guard that fires before any provider call.
Source
Thrown at mem0-ts/src/oss/src/memory/index.ts:750
}
// Validate messages input
if (messages === undefined || messages === null) {
throw new Error(
"messages is required and cannot be undefined or null. Provide a string or array of messages.",
);
}
if (Array.isArray(messages)) {
if (messages.length === 0) {
throw new Error(
"messages array cannot be empty. Provide at least one message with non-empty content.",
);
}
const allBlank = messages.every(
(m) => typeof m.content === "string" && m.content.trim() === "",
);
if (allBlank) {
throw new Error(
"messages array cannot contain only blank content. Provide at least one message with non-empty content.",
);
}
} else if (messages.trim() === "") {
throw new Error(
"messages string cannot be empty. Provide non-empty content.",
);
}
const temporalUsageNotice = detectTemporalUsageFromMetadata(
config?.metadata,
);
await this._ensureInitialized();
await this._captureEvent("add", {
message_count: Array.isArray(messages) ? messages.length : 1,
has_metadata: !!config.metadata,
has_filters: !!config.filters,View on GitHub (pinned to 001c235229)
Solutions
- Filter or reject blank messages before calling add(): messages.filter(m => typeof m.content !== 'string' || m.content.trim() !== '')
- If the array becomes empty after filtering, validate earlier in your pipeline and skip the add() call entirely
- Check that message objects actually carry the content field and it was not renamed (e.g. 'text') during mapping
Example fix
// before
await memory.add([{ role: 'user', content: ' ' }]);
// after
const msgs = transcript.filter(m => m.content?.trim());
if (msgs.length) {
await memory.add(msgs);
} Defensive patterns
Strategy: validation
Validate before calling
const hasContent = (msgs) =>
Array.isArray(msgs)
? msgs.some((m) => typeof m.content !== 'string' || m.content.trim() !== '')
: msgs.trim() !== '';
if (!hasContent(messages)) throw new Error('nothing to memorize'); Try / catch
try { await memory.add(messages, { userId }); } catch (e) { if (e instanceof Error && e.message.includes('blank content')) { /* skip empty input */ } else throw e; } Prevention
- Trim and reject empty chat input at the UI/boundary layer before it reaches memory.add()
- When mapping transcripts to Message[], assert every message has non-blank string content
When it happens
Trigger: Calling memory.add(messages) where messages is a non-empty array and messages.every(m => typeof m.content === 'string' && m.content.trim() === '') is true, e.g. memory.add([{ role: 'user', content: ' ' }]). Non-string content (e.g. image parts) makes every() false, so only all-blank string arrays trigger it.
Common situations: Passing user input straight from a form/chat UI where the user submitted whitespace; upstream trimming that reduces content to ''; transcript arrays whose text fields were dropped during JSON transformation.
Related errors
- messages string cannot be empty. Provide non-empty content.
- One of the filters: userId, agentId or runId is required!
- Either memoryId or --all is required
- At least one entity ID is required for deleteEntities.
- Unknown LLM provider: ${providerId}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/b3bf9962d2685874.
Report an issue: GitHub.