{"record":{"id":"e9d6b879e23010a7","repo":"langchain-ai/deepagents","slug":"failed-to-apply-provider-profile-for-spec-ex","errorCode":null,"errorMessage":"Failed to apply provider profile for '{spec}': {exc}. Check that the provider package is installed and up to date, or set explicit kwargs via `--model-params`.","messagePattern":"Failed to apply provider profile for '(.+?)': (.+?)\\. Check that the provider package is installed and up to date, or set explicit kwargs via `--model-params`\\.","errorType":"exception","errorClass":"ModelConfigError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5835,"sourceCode":"        try:\n            kwargs = apply_provider_profile(spec, kwargs)\n        except ModelConfigError:\n            raise\n        except Exception as exc:\n            # `pre_init` and `init_kwargs_factory` callables registered on a\n            # `ProviderProfile` may raise arbitrary exceptions (e.g. an\n            # `ImportError` from the OpenRouter min-version check). Surface\n            # them as `ModelConfigError` so the app's error path renders an\n            # actionable message instead of a raw stack trace.\n            logger.debug(\n                \"ProviderProfile resolution for %r failed.\", spec, exc_info=True\n            )\n            msg = (\n                f\"Failed to apply provider profile for '{spec}': {exc}. \"\n                f\"Check that the provider package is installed and up to date, \"\n                f\"or set explicit kwargs via `--model-params`.\"\n            )\n            raise ModelConfigError(msg) from exc\n\n    # App --model-params take highest priority.\n    reasoning_effort_override: object = None\n    reasoning_override: object = None\n    if extra_kwargs:\n        extra_kwargs = dict(extra_kwargs)\n        reasoning_effort_override = extra_kwargs.get(\"reasoning_effort\")\n        reasoning_override = extra_kwargs.get(\"reasoning\")\n        kwargs.update(extra_kwargs)\n    kwargs = _compose_openai_reasoning_effort(\n        provider,\n        kwargs,\n        reasoning_effort_override,\n        reasoning_override,\n    )\n\n    # dcode's model-node middleware owns the user-visible retry budget. Resolve\n    # that budget separately, then force the provider's own retry loop off so","sourceCodeStart":5817,"sourceCodeEnd":5853,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5817-L5853","documentation":"deepagents-code applies a 'provider profile' — defaults each langchain provider integration exposes (e.g. via a profile helper) — when composing model kwargs. If that step raises, it is wrapped in ModelConfigError with advice to check the provider package installation or bypass the profile with explicit `--model-params`. The original exception is chained (`from exc`) for the full traceback.","triggerScenarios":"Building a model whose provider has a registered profile when the profile-apply call raises: typically an outdated or missing `langchain-<provider>` optional-dependency package (missing method/API drift), or an incompatible version of the underlying vendor SDK that the profile helper depends on.","commonSituations":"Installing dcode without the provider extra (`pip install deepagents-code[anthropic]`) then selecting that provider's model; a langchain integration upgrade that changed the profiled API; pinning an old provider package against a newer dcode; virtualenv mixing stale langchain-core versions.","solutions":["Install/upgrade the provider extra: `pip install 'deepagents-code[<provider>]'` or `pip install -U langchain-<provider>`.","Check the chained traceback (`from exc`) for the underlying incompatibility and fix that dependency version.","Bypass the profile by passing explicit kwargs via `--model-params` (or `[model-params]` in config.toml).","Run `uv sync` / reinstall in a clean virtualenv to remove conflicting langchain package versions."],"exampleFix":"// before: profile crashes on outdated integration\n$ dcode -m openrouter:meta-llama/llama-3\n// ModelConfigError: Failed to apply provider profile for 'openrouter:...'\n// after\n$ pip install -U 'langchain-openrouter'  # or the matching provider extra\n$ dcode -m openrouter:meta-llama/llama-3 --model-params temperature=0.2","handlingStrategy":"try-catch","validationCode":"from importlib.metadata import version, PackageNotFoundError\n\ndef check_provider_package(provider: str) -> str | None:\n    try:\n        return version(f\"langchain-{provider}\")\n    except PackageNotFoundError:\n        return None\n\nif check_provider_package(\"openrouter\") is None:\n    raise SystemExit(\"Install the provider extra: pip install 'deepagents-code[openrouter]'\")","typeGuard":null,"tryCatchPattern":"try:\n    model = build_model(provider, model_name)\nexcept ModelConfigError as exc:\n    logger.debug(\"Provider profile failure\", exc_info=exc.__cause__)\n    # fall back to explicit kwargs instead of the profile\n    model = build_model(provider, model_name, model_params={\"temperature\": 0.2})","preventionTips":["Always install the matching provider extra (`deepagents-code[<provider>]`) rather than the base package alone.","Keep langchain provider packages and dcode upgraded together in one environment.","Check the chained cause (`exc.__cause__`) whenever this error appears — it names the real API drift.","Avoid mixing langchain package versions across virtualenvs; use a lockfile."],"tags":["model-config","dependency","provider-integration","version-mismatch"],"backgroundTag":"provider-package-incompatible","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}