langchain-ai/deepagents · error · MissingProviderPackageError

Missing package for provider '{provider}'. {install_hint}, t

Error message

Missing package for provider '{provider}'. {install_hint}, then retry with `/model`.

What it means

Raised as `MissingProviderPackageError` when `init_chat_model` raises ImportError for a provider and `importlib.util.find_spec` confirms the provider's LangChain package is NOT installed. The error carries `provider` and `package` attributes and an install hint (`/install <extra>` or a pip command) so the UI can render targeted recovery instructions.

Source

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

        else:
            from deepagents_code.extras_info import resolve_install_hint

            hint = resolve_install_hint(package)
            if hint.extra is not None:
                msg = (
                    f"Missing package for provider '{provider}'. "
                    f"Install: /install {hint.extra}"
                )
            else:
                if hint.command is not None:
                    install_hint = f"Install with: {hint.command}"
                else:
                    install_hint = f"Install the '{package}' package manually"
                msg = (
                    f"Missing package for provider '{provider}'. "
                    f"{install_hint}, then retry with `/model`."
                )
            raise MissingProviderPackageError(
                msg, provider=provider, package=package
            ) from e
        raise ModelConfigError(msg) from e
    except (ValueError, TypeError) as e:
        if not provider:
            # Both app auto-detection and `init_chat_model`'s own inference
            # failed; surface a structured error so the UI can render the
            # docs URL as a clickable link.
            raise UnknownProviderError(model_spec=model_name) from e
        spec = f"{provider}:{model_name}"
        msg = f"Invalid model configuration for '{spec}': {e}"
        raise ModelConfigError(msg) from e
    except Exception as e:  # provider SDK auth/network errors
        spec = f"{provider}:{model_name}" if provider else model_name
        msg = f"Failed to initialize model '{spec}': {e}"
        raise ModelConfigError(msg) from e

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Follow the hint: run `/install <extra>` in the CLI, or `pip install langchain-anthropic` (or the named `langchain-<provider>` package)
  2. Install the package into the same environment/venv dcode runs in, then retry with `/model`
  3. Install the composite extra: `pip install "deepagents-code[all-providers]"` if you use many providers

Example fix

// before
$ dcode -m anthropic:claude-opus-5
MissingProviderPackageError: Missing package for provider 'anthropic'...

// after
$ pip install langchain-anthropic
$ dcode -m anthropic:claude-opus-5
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

def provider_package_installed(provider: str) -> bool:
    package = {"anthropic": "langchain-anthropic", "openai": "langchain-openai",
               "google_genai": "langchain-google-genai",
               "google_vertexai": "langchain-google-vertexai",
               "google_anthropic_vertex": "langchain-google-vertexai"}.get(provider, f"langchain-{provider}")
    try:
        return importlib.util.find_spec(package.replace("-", "_")) is not None
    except (ImportError, ValueError):
        return False

Try / catch

from deepagents_code.model_config import MissingProviderPackageError
try:
    model = create_model(spec)
except MissingProviderPackageError as e:
    print(f"Provider {e.provider} needs package {e.package}; run /install or pip install {e.package}")
    raise SystemExit(1)

Prevention

When it happens

Trigger: `_create_model_via_init` maps the provider to a package (`anthropic` -> `langchain-anthropic`, else `langchain-{provider}`), `find_spec` returns False, and the message is built via `resolve_install_hint` (config.py:5446-5499). Triggered by selecting a model whose provider integration is absent from the environment.

Common situations: Minimal install without the `all-providers` extra; fresh venv where only `langchain-core` is present; selecting e.g. `xai:grok-*` before installing `langchain-xai`; Docker images built without the provider extra.

Related errors


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