mem0ai/mem0 · error · ValueError
Invalid memory action: {memory_action}
Error message
Invalid memory action: {memory_action} What it means
Raised by VertexAIEmbedding.embed when memory_action is a value not in the class's embedding_types mapping (which maps mem0 actions like 'add'/'search' to Vertex task types such as RETRIEVAL_DOCUMENT/QUESTION_ANSWERING). Passing None is allowed (defaults to SEMANTIC_SIMILARITY); any other unknown string is rejected before the API call.
Source
Thrown at mem0/embeddings/vertexai.py:57
"Google application credentials JSON is not provided. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable."
)
self.model = TextEmbeddingModel.from_pretrained(self.config.model)
def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None):
"""
Get the embedding for the given text using Vertex AI.
Args:
text (str): The text to embed.
memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None.
Returns:
list: The embedding vector.
"""
embedding_type = "SEMANTIC_SIMILARITY"
if memory_action is not None:
if memory_action not in self.embedding_types:
raise ValueError(f"Invalid memory action: {memory_action}")
embedding_type = self.embedding_types[memory_action]
text_input = TextEmbeddingInput(text=text, task_type=embedding_type)
embeddings = self.model.get_embeddings(texts=[text_input], output_dimensionality=self.config.embedding_dims)
return embeddings[0].values
def embed_batch(self, texts, memory_action="add"):
if not texts:
return []
embedding_type = "SEMANTIC_SIMILARITY"
if memory_action is not None:
if memory_action not in self.embedding_types:
raise ValueError(f"Invalid memory action: {memory_action}")
embedding_type = self.embedding_types[memory_action]
all_embeddings = []
for i in range(0, len(texts), 250):View on GitHub (pinned to 001c235229)
Solutions
- Pass only None or the actions defined in the provider's embedding_types mapping (add, search, update)
- Upgrade mem0 so the provider's mapping matches the actions used by the memory layer
- If you call embed() directly for generic embedding, omit memory_action entirely
Example fix
// before
vec = embedder.embed("hello", memory_action="index") # ValueError
# after
vec = embedder.embed("hello", memory_action="add")
# or omit: vec = embedder.embed("hello") Defensive patterns
Strategy: validation
Validate before calling
VALID_ACTIONS = {None, "add", "search", "update"} # provider's embedding_types keys
assert memory_action in VALID_ACTIONS, f"unsupported memory_action: {memory_action!r}" Type guard
from typing import Optional
VALID_ACTIONS = {"add", "search", "update"}
def is_valid_action(a) -> bool:
return a is None or a in VALID_ACTIONS Try / catch
try:
vec = embedder.embed(text, memory_action=action)
except ValueError as e:
if "Invalid memory action" in str(e):
vec = embedder.embed(text) # fall back to default task type
else:
raise Prevention
- Treat memory_action as an enum, not free text
- Let Memory handle the action; pass None when calling embed directly
- Upgrade mem0 core and providers together so action vocabularies match
When it happens
Trigger: Calling embed(text, memory_action="delete") or a custom string; a mem0-internal caller passing a new action type this provider never mapped; user code invoking the embedder directly with an arbitrary label.
Common situations: Direct use of VertexAIEmbedding outside Memory; version skew where a newer mem0 passes an action this provider version does not know; typos in the action string.
Related errors
- Vertex AI embed_batch() returned {len(all_embeddings)} embed
- Invalid memory action: ${memoryAction}
- `model` parameter is required
- `model` must be an instance of Embeddings
- LM Studio embed_batch() returned {len(embeddings)} embedding
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/59fefdcc750aeb11.
Report an issue: GitHub.