{"record":{"id":"014da6e13e0790df","repo":"langchain-ai/deepagents","slug":"could-not-apply-label-to-model-model-name","errorCode":null,"errorMessage":"Could not apply {label} to model '{model_name}': {exc}. The model may not support profile assignment.","messagePattern":"Could not apply (.+?) to model '(.+?)': (.+?)\\. The model may not support profile assignment\\.","errorType":"exception","errorClass":"ModelConfigError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5631,"sourceCode":"\n    Raises:\n        ModelConfigError: If `raise_on_failure` is `True` and the model\n            rejects profile assignment.\n    \"\"\"\n    from deepagents_code.model_config import ModelConfigError\n\n    logger.debug(\"Applying %s profile overrides: %s\", label, overrides)\n    profile = getattr(model, \"profile\", None)\n    merged = {**profile, **overrides} if isinstance(profile, dict) else overrides\n    try:\n        model.profile = merged  # ty: ignore[invalid-assignment]\n    except (AttributeError, TypeError, ValueError) as exc:\n        if raise_on_failure:\n            msg = (\n                f\"Could not apply {label} to model '{model_name}': {exc}. \"\n                f\"The model may not support profile assignment.\"\n            )\n            raise ModelConfigError(msg) from exc\n        logger.warning(\n            \"Could not apply %s profile overrides to model '%s': %s. \"\n            \"Overrides will be ignored.\",\n            label,\n            model_name,\n            exc,\n        )\n\n\ndef create_model(\n    model_spec: str | None = None,\n    *,\n    extra_kwargs: dict[str, Any] | None = None,\n    profile_overrides: dict[str, Any] | None = None,\n    cli_max_retries: int | None = None,\n) -> ModelResult:\n    \"\"\"Create a chat model.\n","sourceCodeStart":5613,"sourceCodeEnd":5649,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5613-L5649","documentation":"Raised (when `raise_on_failure=True`) by `_apply_profile_overrides` if assigning the merged profile dict onto `model.profile` fails with AttributeError/TypeError/ValueError, meaning the chat model object does not accept profile assignment.","triggerScenarios":"`create_model` with profile overrides (config.toml or `--profile-override`) applied to a custom `BaseChatModel` whose `profile` attribute is read-only, absent in a way that rejects setattr, or validated against a strict schema.","commonSituations":"Third-party or custom model classes with frozen/slot-based attributes, provider integrations where `profile` is a property without a setter, langchain version where profile shape changed.","solutions":["Set `raise_on_failure=False` (the default) so overrides are ignored with a warning instead of failing model creation.","Use a model class that supports mutable `profile` assignment (standard langchain chat models do).","Drop the profile override for that model, or apply the capability flags another way.","Check the chained exception for which attribute/assignment failed."],"exampleFix":"// before\n_apply_profile_overrides(model, overrides, name, label=\"cli\", raise_on_failure=True)\n// after\n_apply_profile_overrides(model, overrides, name, label=\"cli\", raise_on_failure=False)  # warn + ignore instead","handlingStrategy":"fallback","validationCode":"profile = getattr(model, \"profile\", None)\ncan_assign = isinstance(profile, dict) or (profile is None and not hasattr(type(model), \"__slots__\"))\n# only request raise_on_failure=True when can_assign","typeGuard":null,"tryCatchPattern":"try:\n    _apply_profile_overrides(model, overrides, name, label=label, raise_on_failure=True)\nexcept ModelConfigError:\n    logger.warning(\"Profile overrides unsupported for %s; continuing without them\", name)","preventionTips":["Leave raise_on_failure=False (default) unless override application is mandatory","Target profile overrides only at standard langchain chat models","Verify the custom model class has a writable profile attribute before enabling overrides","Confirm the langchain version's profile schema matches your override keys"],"tags":["model-config","profile-override","langchain"],"backgroundTag":"model-profile-assignment-unsupported","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}