agentscope-ai/agentscope · error · TypeError
f"AgentScopeEmbedding `model` must be an EmbeddingModelBase,
Error message
f"AgentScopeEmbedding `model` must be an EmbeddingModelBase, got {type(self.config.model).__name__}." What it means
The embedding adapter type-checks config.model; anything that is not an AgentScope EmbeddingModelBase (string model name, raw OpenAI client, sentence-transformers model) raises this TypeError with the actual type name.
Source
Thrown at src/agentscope/middleware/_longterm_memory/_mem0/_agentscope_adapter.py:251
``EmbeddingModelBase``."""
def __init__(
self,
config: BaseEmbedderConfig | dict | None = None,
) -> None:
# mem0's EmbeddingBase (unlike LLMBase) does NOT auto-convert
# dict configs — it stores whatever is passed. Normalize here
# so callers can use the same dict-config style as the LLM.
if isinstance(config, dict):
config = BaseEmbedderConfig(**config)
super().__init__(config)
if self.config.model is None:
raise ValueError(
"AgentScopeEmbedding requires `model` in the config "
"to be an AgentScope EmbeddingModelBase instance.",
)
if not isinstance(self.config.model, EmbeddingModelBase):
raise TypeError(
f"AgentScopeEmbedding `model` must be an "
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))View on GitHub (pinned to e90f1c7592)
Solutions
- Wrap the provider with an AgentScope embedding class and pass the instance
- Verify the import came from agentscope.model, not the provider SDK
- Delegate construction to build_mem0_config(embedding_model=...)
Example fix
// before
AgentScopeEmbedding({'model': 'text-embedding-3-small'})
// after
from agentscope.model import OpenAIEmbedding
AgentScopeEmbedding({'model': OpenAIEmbedding(model='text-embedding-3-small')}) Defensive patterns
Strategy: type-guard
Validate before calling
from agentscope.model import EmbeddingModelBase
if not isinstance(config.get('model'), EmbeddingModelBase):
raise TypeError('model must be an EmbeddingModelBase instance') Type guard
from agentscope.model import EmbeddingModelBase
def is_embedding_model_base(m) -> bool:
return isinstance(m, EmbeddingModelBase) Try / catch
try:
emb = AgentScopeEmbedding(cfg)
except TypeError as e:
raise SystemExit(f'Bad embedder config: {e}') from e Prevention
- Wrap embedders in agentscope.model classes before passing them as config.model
When it happens
Trigger: AgentScopeEmbedding({'model': 'text-embedding-3-small'}) or passing a SentenceTransformer/HuggingFace object as model.
Common situations: Assuming mem0's string-based embedder config style carries over; mixing HuggingFace locals with the AgentScope adapter.
Related errors
- f"AgentScopeLLM `model` must be a ChatModelBase, got {type(s
- "AgentScopeEmbedding requires `model` in the config to be an
- "AgentScope embedding model returned no embeddings."
- Path {path_file} exists but is not a file.
- "AgentScopeLLM requires `model` in the config to be an Agent
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/aaaf4fe9e4ab0053.
Report an issue: GitHub.