langchain-ai/deepagents · error · ImportError

deepagents requires langchain-openrouter>={OPENROUTER_MIN_VE

Error message

deepagents requires langchain-openrouter>={OPENROUTER_MIN_VERSION}, but {installed} is installed. Run: pip install 'langchain-openrouter>={OPENROUTER_MIN_VERSION}'

What it means

The built-in OpenRouter provider profile requires a minimum version of `langchain-openrouter` to guarantee compatible APIs. The installed version is older than `OPENROUTER_MIN_VERSION`, so the provider check raises ImportError with the exact upgrade command.

Source

Thrown at libs/deepagents/deepagents/profiles/provider/_openrouter.py:119

        return
    try:
        is_old = Version(installed) < Version(OPENROUTER_MIN_VERSION)
    except InvalidVersion:
        # Non-PEP-440 version (dev build, fork, etc.) — skip the check but
        # leave a breadcrumb so an unexpected downstream failure is traceable.
        logger.warning(
            "Skipping langchain-openrouter version check: installed version %r is not PEP 440. Minimum required is %s.",
            installed,
            OPENROUTER_MIN_VERSION,
        )
        return
    if is_old:
        msg = (
            f"deepagents requires langchain-openrouter>={OPENROUTER_MIN_VERSION}, "
            f"but {installed} is installed. "
            f"Run: pip install 'langchain-openrouter>={OPENROUTER_MIN_VERSION}'"
        )
        raise ImportError(msg)


def register() -> None:
    """Register the built-in OpenRouter provider profile."""
    _register_provider_profile_impl(
        "openrouter",
        ProviderProfile(
            pre_init=lambda _spec: check_openrouter_version(),
            init_kwargs_factory=_openrouter_attribution_kwargs,
        ),
    )

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Run `pip install 'langchain-openrouter>=<OPENROUTER_MIN_VERSION>'` as printed in the error
  2. Update requirements/pyproject pin for langchain-openrouter to the minimum version and re-install
  3. If pinned elsewhere (e.g. uv lock, constraints file), regenerate the lock with the upgraded version

Example fix

# before
langchain-openrouter==0.1.0
# after
langchain-openrouter>=0.2.0
Defensive patterns

Strategy: validation

Validate before calling

from importlib.metadata import version
from packaging.version import Version
installed = version("langchain-openrouter")
if Version(installed) < Version(OPENROUTER_MIN_VERSION):
    raise SystemExit(f"upgrade: pip install 'langchain-openrouter>={OPENROUTER_MIN_VERSION}'")

Try / catch

try:
    register_openrouter_profile()
except ImportError as e:
    if "langchain-openrouter" in str(e):
        subprocess.run([sys.executable, "-m", "pip", "install", "-U", "langchain-openrouter"], check=True)
        register_openrouter_profile()
    else:
        raise

Prevention

When it happens

Trigger: Registering/using the built-in OpenRouter provider profile (`register()` in `_openrouter.py`) with `pip show langchain-openrouter` reporting a version below the minimum.

Common situations: Stale virtualenv after upgrading deepagents; pinned requirements locking an old langchain-openrouter; environment where deepagents was upgraded but its provider deps were not.

Related errors


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