OpenBMB/ChatDev · error · ConfigError

model.name must be a non-empty string

Error message

model.name must be a non-empty string

What it means

Raised when parsing an agent node config: the 'name' field under the model mapping is missing, None, not a string, or a blank/whitespace-only string. The library requires a model identifier (e.g. 'gpt-4o', 'claude-3-5-sonnet') to construct the LLM client. The path in the ConfigError points at the offending 'name' key.

Source

Thrown at entity/configs/node/agent.py:350

    tooling: List[ToolingConfig] = field(default_factory=list)
    thinking: ThinkingConfig | None = None
    memories: List[MemoryAttachmentConfig] = field(default_factory=list)
    skills: AgentSkillsConfig | None = None

    # Runtime attributes (attached dynamically)
    token_tracker: Any | None = field(default=None, init=False, repr=False)
    node_id: str | None = field(default=None, init=False, repr=False)

    @classmethod
    def from_dict(cls, data: Mapping[str, Any], *, path: str) -> "AgentConfig":
        mapping = require_mapping(data, path)
        provider = require_str(mapping, "provider", path)
        base_url = optional_str(mapping, "base_url", path)
        name_value = mapping.get("name")
        if isinstance(name_value, str) and name_value.strip():
            model_name = name_value.strip()
        else:
            raise ConfigError("model.name must be a non-empty string", extend_path(path, "name"))

        role = optional_str(mapping, "role", path)
        api_key = optional_str(mapping, "api_key", path)
        params = optional_dict(mapping, "params", path) or {}
        raw_input_mode = optional_str(mapping, "input_mode", path)
        input_mode = AgentInputMode.MESSAGES
        if raw_input_mode:
            try:
                input_mode = AgentInputMode(raw_input_mode.strip().lower())
            except ValueError as exc:
                raise ConfigError(
                    "model.input_mode must be 'prompt' or 'messages'",
                    extend_path(path, "input_mode"),
                ) from exc

        tooling_cfg: List[ToolingConfig] = []
        if "tooling" in mapping and mapping["tooling"] is not None:
            raw_tooling = mapping["tooling"]

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Add a non-empty 'name' string to the model mapping, e.g. "name": "gpt-4o"
  2. Strip surrounding whitespace only if the value is genuinely present; ensure it is a str, not null/int
  3. If the name comes from an env var, default it: os.environ.get('MODEL_NAME') or fail fast with a clear message
  4. Check the error's path field to locate which node/model in a nested config failed

Example fix

// before
{"model": {"provider": "openai", "name": ""}}
// after
{"model": {"provider": "openai", "name": "gpt-4o"}}
Defensive patterns

Strategy: validation

Validate before calling

def check_model_name(cfg: dict) -> None:
    name = cfg.get('model', {}).get('name')
    if not isinstance(name, str) or not name.strip():
        raise ValueError('model.name missing/blank')

Type guard

def has_valid_model_name(cfg: dict) -> bool:
    n = cfg.get('model', {}).get('name')
    return isinstance(n, str) and bool(n.strip())

Try / catch

try:
    cfg = ModelConfig.from_dict(data, path='agent')
except ConfigError as e:
    if 'model.name' in e.path:
        name = input('model name: ').strip() or DEFAULT_MODEL
        data['model']['name'] = name
        cfg = ModelConfig.from_dict(data, path='agent')
    else:
        raise

Prevention

When it happens

Trigger: Calling AgentNodeConfig/ModelConfig.from_dict (or loading a serialized agent node) with a model dict that omits 'name', sets it to null, uses a non-string value like 123, or passes an empty/whitespace string ''.

Common situations: YAML/JSON agent definitions where the model name was commented out or renamed; template placeholders like '' left unfilled; name supplied as a number (e.g. name: 4 thinking it's a version) and silently coerced elsewhere.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/f6a1e4dd1f16ff23. Report an issue: GitHub.