langchain-ai/langgraph · error · ValueError

Number of embeddings

Error message

Number of embeddings ({len(embeddings)}) does not match number of indices ({len(indices)})

What it means

Internal invariant check in InMemoryStore._insertinmem_store: after embedding texts collected during a batch PUT, the count of vectors returned by the embedding call does not equal the number of (namespace, key, path) index slots that were queued for embedding. This is not a user-input error per se — it signals the embedding function violated its contract (returned a different number of vectors than input texts), or duplicated-text deduplication bookkeeping diverged.

Solutions

  1. Fix the custom embedding function to return exactly one vector per input text (len(output) == len(texts))
  2. If using EmbeddingsLambda, verify the wrapped function's return shape is list[list[float]]
  3. Update langgraph-checkpoint if running an old version with an embedding dedup bug
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/checkpoint/langgraph/checkpoint/store/memory/__init__.py:453 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/1fcafe7ec12910b1. Report an issue: GitHub.

Appendix: source

Thrown at libs/checkpoint/langgraph/checkpoint/store/memory/__init__.py:453

    def _insertinmem_store(
        self,
        to_embed: dict[str, list[tuple[tuple[str, ...], str, str]]],
        embeddings: list[list[float]],
    ) -> None:
        indices = [index for indices in to_embed.values() for index in indices]
        if len(indices) != len(embeddings):
            raise ValueError(
                f"Number of embeddings ({len(embeddings)}) does not"
                f" match number of indices ({len(indices)})"
            )
        for embedding, (ns, key, path) in zip(embeddings, indices, strict=False):
            self._vectors[ns][key][path] = embedding

View on GitHub (pinned to 38031739e5)