agentscope-ai/agentscope · error · ValueError

Embedding model card {yaml_path!r} is missing the required t

Error message

Embedding model card {yaml_path!r} is missing the required top-level 'dimensions' field.

What it means

EmbeddingModelCard.from_yaml requires a top-level 'dimensions' key in the YAML model card; without it the card is rejected because model dimensionality cannot be inferred from provider parameters alone.

Source

Thrown at src/agentscope/embedding/_embedding_model_card.py:130

        Merges the base ``parameter_class`` JSON Schema with
        ``parameter_overrides`` from the YAML — identical to the
        approach used by :meth:`~agentscope.model.ModelCard.from_yaml`.

        Args:
            yaml_path (`str`):
                Path to the YAML file.
            parameter_class (`Type[BaseModel]`):
                The ``Parameters`` class from the embedding model subclass.

        Returns:
            `EmbeddingModelCard`: The loaded model card.
        """
        with open(yaml_path, "r", encoding="utf-8") as f:
            config = yaml.safe_load(f)

        if "dimensions" not in config:
            raise ValueError(
                f"Embedding model card {yaml_path!r} is missing the "
                f"required top-level 'dimensions' field.",
            )

        # Build parameter schema from the Parameters class
        base_schema = parameter_class.model_json_schema()
        properties = copy.deepcopy(base_schema.get("properties", {}))

        # Apply parameter_overrides (same logic as ModelCard.from_yaml)
        overrides = config.get("parameter_overrides", {})
        for param_name, override in overrides.items():
            if override is None:
                # null means remove
                properties.pop(param_name, None)
                continue

            if isinstance(override, dict):
                if override.get("hidden"):

View on GitHub (pinned to e90f1c7592)

Solutions

  1. Add `dimensions: 1024` at the top level of the YAML card
  2. Validate card files in CI with a schema check before shipping them
  3. Regenerate cards from a known-good template that includes dimensions

Example fix

# before
# card.yaml
name: text-embedding-v3
# after
name: text-embedding-v3
dimensions: 1024
Defensive patterns

Strategy: validation

Validate before calling

import yaml
cfg = yaml.safe_load(open(path))
assert \"dimensions\" in cfg, f\"{path} missing dimensions\"

Try / catch

try:\n    card = EmbeddingModelCard.from_yaml(path)\nexcept ValueError as e:\n    if \"dimensions\" in str(e): patch_card_with_dimensions(path); card = EmbeddingModelCard.from_yaml(path)\n    else: raise

Prevention

When it happens

Trigger: Calling from_yaml (directly or via list_models) on a card file that lacks the top-level dimensions field.

Common situations: Hand-written or third-party model cards missing the field; cards written for an older schema where dimensions were optional; merge/serialization that dropped the key.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/2b35aa33d46317f4. Report an issue: GitHub.