{"record":{"id":"89c96e1d4542f3bb","repo":"langchain-ai/deepagents","slug":"invalid-model-spec-model-spec-model-name-is-r","errorCode":null,"errorMessage":"Invalid model spec '{model_spec}': model name is required (e.g., 'anthropic:claude-sonnet-4-5' or 'claude-sonnet-4-5')","messagePattern":"Invalid model spec '(.+?)': model name is required \\(e\\.g\\., 'anthropic:claude-sonnet-4-5' or 'claude-sonnet-4-5'\\)","errorType":"validation","errorClass":"ModelConfigError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5743,"sourceCode":"        provider, model_name = parsed.provider, parsed.model\n    elif inferred_provider == \"bedrock\":\n        provider, model_name = inferred_provider, model_spec\n    elif parsed:\n        # Explicit provider:model (e.g., \"anthropic:claude-sonnet-4-5\")\n        provider, model_name = parsed.provider, parsed.model\n    elif \":\" in model_spec:\n        # Contains colon but ModelSpec rejected it (empty provider or model)\n        _, _, after = model_spec.partition(\":\")\n        if after:\n            # Leading colon (e.g., \":claude-opus-4-6\") — treat as bare model name\n            model_name = after\n            provider = detect_provider(model_name) or \"\"\n        else:\n            msg = (\n                f\"Invalid model spec '{model_spec}': model name is required \"\n                \"(e.g., 'anthropic:claude-sonnet-4-5' or 'claude-sonnet-4-5')\"\n            )\n            raise ModelConfigError(msg)\n    else:\n        # Bare model name — auto-detect provider or let init_chat_model infer\n        model_name = model_spec\n        provider = inferred_provider or \"\"\n\n    if provider == \"google_vertexai\" and model_name.lower().startswith(\"claude-\"):\n        msg = (\n            f\"Claude model '{model_name}' uses the Anthropic Messages API on \"\n            \"Vertex AI. Use \"\n            f\"'google_anthropic_vertex:{model_name}' instead of \"\n            f\"'google_vertexai:{model_name}'.\"\n        )\n        raise ModelConfigError(msg)\n\n    resolved_spec = f\"{provider}:{model_name}\" if provider else model_spec\n    # The authoritative policy gate, and its position is load-bearing: it runs\n    # after provider inference (so a bare name is matched in canonical form)\n    # but before credential bridging, provider profiles, and provider imports.","sourceCodeStart":5725,"sourceCodeEnd":5761,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5725-L5761","documentation":"Raised by `create_model` when the model spec contains a colon but no model name — e.g. 'anthropic:' or ':'. ModelSpec parsing rejected it, and since the text after the colon is empty, the app cannot treat it as a bare model name.","triggerScenarios":"Calling `create_model('anthropic:')` or any `provider:` string with an empty model part; also a spec like ':' with nothing on either side.","commonSituations":"Truncated config.toml value (model key set to 'openai:'), shell variable interpolation that dropped the model name ('$MODEL' unset leaving 'anthropic:'), accidental trailing colon in a slash command.","solutions":["Supply the model name after the colon: 'anthropic:claude-sonnet-4-5'.","Or drop the colon entirely and use a bare name like 'claude-sonnet-4-5' for auto-detection.","Check the config/env value feeding model_spec for an unset or truncated variable."],"exampleFix":"// before\nmodel = create_model(\"anthropic:\")\n// after\nmodel = create_model(\"anthropic:claude-sonnet-4-5\")","handlingStrategy":"validation","validationCode":"def is_valid_model_spec(spec: str) -> bool:\n    if \":\" in spec:\n        provider, _, model = spec.partition(\":\")\n        return bool(provider and model)\n    return bool(spec)\nassert is_valid_model_spec(model_spec), \"model name is required after ':'\"","typeGuard":null,"tryCatchPattern":"try:\n    result = create_model(spec)\nexcept ModelConfigError as e:\n    if \"model name is required\" in str(e):\n        spec = spec.rstrip(\":\")  # fall back to bare-name auto-detection\n        result = create_model(spec)","preventionTips":["Never leave the model part of 'provider:' empty in config or env","Expand shell variables feeding model_spec and fail fast if empty","Strip accidental trailing colons before passing specs","Use bare model names when you want auto-detection instead of an empty provider"],"tags":["model-config","validation","parsing"],"backgroundTag":"invalid-model-spec","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}