agentscope-ai/agentscope · error · RuntimeError
"AgentScope embedding model returned no embeddings."
Error message
"AgentScope embedding model returned no embeddings."
What it means
embed() calls the AgentScope embedding model and expects a non-empty embeddings list in the response. If the model returns an EmbeddingResponse with empty embeddings, there is no vector to return and a RuntimeError is raised.
Source
Thrown at src/agentscope/middleware/_longterm_memory/_mem0/_agentscope_adapter.py:271
f"EmbeddingModelBase, got "
f"{type(self.config.model).__name__}.",
)
self._agentscope_model: EmbeddingModelBase = self.config.model
self._bridge = _AsyncBridge()
# ----- EmbeddingBase interface -----
# pylint: disable=unused-argument
def embed(
self,
text: str | list[str],
memory_action: str | None = None, # mem0 contract — unused
) -> list[float]:
"""mem0 ``EmbeddingBase`` entry — runs the AgentScope embedding
model synchronously and returns the first vector."""
text_list = [text] if isinstance(text, str) else list(text)
response = self._bridge.run(self._agentscope_model(text_list))
if not response.embeddings:
raise RuntimeError(
"AgentScope embedding model returned no embeddings.",
)
# AgentScope EmbeddingResponse.embeddings is List[List[float]];
# mem0 expects a single vector for a single-text call.
return response.embeddings[0]
# ----------------------------------------------------------------------
# Build a mem0 MemoryConfig wired to AgentScope models
# ----------------------------------------------------------------------
# The provider name we register under in mem0's factory + config layer.
_AGENTSCOPE_PROVIDER = "agentscope"
def build_mem0_config(
*,
chat_model: ChatModelBase | None = None,View on GitHub (pinned to e90f1c7592)
Solutions
- Test the embedding model directly to verify it returns vectors
- Fix mocks to include at least one vector
- Check provider API key/quota and input text validity
Example fix
// before mock_model.return_value = EmbeddingResponse(embeddings=[]) // after mock_model.return_value = EmbeddingResponse(embeddings=[[0.1, 0.2, 0.3]])
Defensive patterns
Strategy: validation
Validate before calling
resp = await embedding_model(['ping'])
if not resp.embeddings:
raise RuntimeError('embedding model returned no vectors — check provider/key') Try / catch
try:
vec = emb.embed('text')
except RuntimeError as e:
if 'no embeddings' in str(e):
vec = retry_with_backoff(lambda: emb.embed('text'))
else:
raise Prevention
- Health-check the embedding model once at startup with a single-string call
- Populate embeddings in all test mocks
When it happens
Trigger: A misbehaving or mocked embedding model returning EmbeddingResponse(embeddings=[]) or embedding=False; provider returning an empty body.
Common situations: Mocked models in tests that forget to populate embeddings; provider errors that still parse into a response object.
Related errors
- "AgentScopeEmbedding requires `model` in the config to be an
- f"AgentScopeEmbedding `model` must be an EmbeddingModelBase,
- Path {path_file} exists but is not a file.
- "AgentScopeLLM requires `model` in the config to be an Agent
- f"AgentScopeLLM `model` must be a ChatModelBase, got {type(s
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/9abe6861e769994d.
Report an issue: GitHub.