agentscope-ai/agentscope · error · ImportError

"ReMeMiddleware requires the `reme-ai` package. Install it w

Error message

"ReMeMiddleware requires the `reme-ai` package. Install it with `pip install \"agentscope[memory-reme]\"` (or `pip install reme-ai`)."

What it means

ReMeMiddleware delegates to the optional reme-ai package; on first start it imports reme.ReMe and re-raises ImportError with install instructions if the extra is missing.

Source

Thrown at src/agentscope/middleware/_longterm_memory/_reme/_middleware.py:237

        # finally). Keyed by ``session_id`` so one middleware shared across
        # agents keeps each session's retrieval isolated — a concurrent reply
        # in another session never clobbers this one's task.
        self._retrieval_tasks: dict[Any, asyncio.Task] = {}

    # ==================================================================
    # Embedded ReMe application lifecycle
    # ==================================================================
    def _build_app(self) -> Any:
        """Lazily build the embedded :class:`reme.ReMe` application.

        Raises:
            ImportError:
                If ``reme-ai`` is not installed.
        """
        try:
            from reme import ReMe
        except ImportError as e:  # pragma: no cover - import guard
            raise ImportError(
                "ReMeMiddleware requires the `reme-ai` package. Install "
                'it with `pip install "agentscope[memory-reme]"` (or '
                "`pip install reme-ai`).",
            ) from e

        embedding_dimensions = None
        if self._parameters.embedding_model is not None:
            embedding_dimensions = self._parameters.embedding_model.dimensions
        app_config = _build_reme_app_config(
            workspace_dir=self._workspace_dir,
            embedding_dimensions=embedding_dimensions,
        )
        return ReMe(**app_config)

    async def _ensure_started(self) -> None:
        """Build (if needed) and start the embedded app (idempotent).

        The configured ``chat_model`` / ``embedding_model`` are injected

View on GitHub (pinned to e90f1c7592)

Solutions

  1. pip install "agentscope[memory-reme]"
  2. Or pip install reme-ai directly
  3. Verify with python -c "import reme" before enabling ReMeMiddleware

Example fix

# before
pip install agentscope
# after
pip install "agentscope[memory-reme]"
Defensive patterns

Strategy: validation

Validate before calling

try:
    import reme  # noqa
except ImportError:
    raise SystemExit('Install with: pip install "agentscope[memory-reme]"')

Try / catch

try:
    mw = ReMeMiddleware(...)
except ImportError as e:
    if 'reme-ai' in str(e):
        subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'reme-ai'])
        mw = ReMeMiddleware(...)
    else:
        raise

Prevention

When it happens

Trigger: Constructing/starting ReMeMiddleware without reme-ai installed, e.g. plain `pip install agentscope`.

Common situations: Using the memory-reme feature without its extra; CI environments that install only core deps; transitive dependency pruning.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/3a384cb94d2d7f18. Report an issue: GitHub.