langchain-ai/deepagents · error · ModelConfigError

Failed to apply provider profile for '{spec}': {exc}. Check

Error message

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`.

What it means

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.

Source

Thrown at libs/code/deepagents_code/config.py:5835

        try:
            kwargs = apply_provider_profile(spec, kwargs)
        except ModelConfigError:
            raise
        except Exception as exc:
            # `pre_init` and `init_kwargs_factory` callables registered on a
            # `ProviderProfile` may raise arbitrary exceptions (e.g. an
            # `ImportError` from the OpenRouter min-version check). Surface
            # them as `ModelConfigError` so the app's error path renders an
            # actionable message instead of a raw stack trace.
            logger.debug(
                "ProviderProfile resolution for %r failed.", spec, exc_info=True
            )
            msg = (
                f"Failed to apply provider profile for '{spec}': {exc}. "
                f"Check that the provider package is installed and up to date, "
                f"or set explicit kwargs via `--model-params`."
            )
            raise ModelConfigError(msg) from exc

    # App --model-params take highest priority.
    reasoning_effort_override: object = None
    reasoning_override: object = None
    if extra_kwargs:
        extra_kwargs = dict(extra_kwargs)
        reasoning_effort_override = extra_kwargs.get("reasoning_effort")
        reasoning_override = extra_kwargs.get("reasoning")
        kwargs.update(extra_kwargs)
    kwargs = _compose_openai_reasoning_effort(
        provider,
        kwargs,
        reasoning_effort_override,
        reasoning_override,
    )

    # dcode's model-node middleware owns the user-visible retry budget. Resolve
    # that budget separately, then force the provider's own retry loop off so

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Install/upgrade the provider extra: `pip install 'deepagents-code[<provider>]'` or `pip install -U langchain-<provider>`.
  2. Check the chained traceback (`from exc`) for the underlying incompatibility and fix that dependency version.
  3. Bypass the profile by passing explicit kwargs via `--model-params` (or `[model-params]` in config.toml).
  4. Run `uv sync` / reinstall in a clean virtualenv to remove conflicting langchain package versions.

Example fix

// before: profile crashes on outdated integration
$ dcode -m openrouter:meta-llama/llama-3
// ModelConfigError: Failed to apply provider profile for 'openrouter:...'
// after
$ pip install -U 'langchain-openrouter'  # or the matching provider extra
$ dcode -m openrouter:meta-llama/llama-3 --model-params temperature=0.2
Defensive patterns

Strategy: try-catch

Validate before calling

from importlib.metadata import version, PackageNotFoundError

def check_provider_package(provider: str) -> str | None:
    try:
        return version(f"langchain-{provider}")
    except PackageNotFoundError:
        return None

if check_provider_package("openrouter") is None:
    raise SystemExit("Install the provider extra: pip install 'deepagents-code[openrouter]'")

Try / catch

try:
    model = build_model(provider, model_name)
except ModelConfigError as exc:
    logger.debug("Provider profile failure", exc_info=exc.__cause__)
    # fall back to explicit kwargs instead of the profile
    model = build_model(provider, model_name, model_params={"temperature": 0.2})

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/e9d6b879e23010a7. Report an issue: GitHub.