HKUDS/DeepTutor · error · RuntimeError

codebuddy-agent-sdk is not installed. Install it with `pytho

Error message

codebuddy-agent-sdk is not installed. Install it with `python -m pip install codebuddy-agent-sdk` or `pip install -e .[codebuddy]`.

What it means

The CodeBuddy provider is an optional integration backed by the third-party `codebuddy-agent-sdk` package. _load_sdk() imports it and, on ImportError, raises RuntimeError with install instructions because the extra wasn't installed.

Source

Thrown at deeptutor/services/llm/provider_core/codebuddy_provider.py:374

        for session in sessions:
            try:
                await session.close()
            except asyncio.CancelledError:
                task = asyncio.current_task()
                if task is not None:
                    task.uncancel()
            except Exception:
                pass

    def get_default_model(self) -> str:
        return self.default_model


def _load_sdk() -> ModuleType:
    try:
        import codebuddy_agent_sdk
    except ImportError as exc:  # pragma: no cover - optional dependency
        raise RuntimeError(
            "codebuddy-agent-sdk is not installed. Install it with "
            "`python -m pip install codebuddy-agent-sdk` or `pip install -e .[codebuddy]`."
        ) from exc
    if not hasattr(codebuddy_agent_sdk, "query"):
        raise RuntimeError("Installed codebuddy-agent-sdk does not expose query().")
    return codebuddy_agent_sdk


def _strip_model_prefix(model: str | None) -> str | None:
    if not model:
        return None
    if "/" not in model:
        return model
    prefix, value = model.split("/", 1)
    if prefix.lower().replace("-", "_") in {"codebuddy", "codebuddy_code", "workbuddy"}:
        return value
    return model

View on GitHub (pinned to 3e82f13042)

Solutions

  1. pip install codebuddy-agent-sdk (or pip install -e .[codebuddy] from source).
  2. If it should already be installed, check you're in the right virtualenv / interpreter (python -m pip install ...).
  3. Prevent instantiation of CodeBuddyProvider when the SDK is absent (guard on importlib.util.find_spec).

Example fix

# before
provider = CodeBuddyProvider(...)

# after
import importlib.util
if importlib.util.find_spec("codebuddy_agent_sdk") is None:
    raise SystemExit("Install extra: pip install 'deeptutor[codebuddy]'")
provider = CodeBuddyProvider(...)
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec("codebuddy_agent_sdk") is None:
    print("Run: pip install 'deeptutor[codebuddy]'")  # skip/disable CodeBuddy features

Type guard

def codebuddy_available() -> bool:
    import importlib.util
    return importlib.util.find_spec("codebuddy_agent_sdk") is not None

Try / catch

try:
    provider.run(...)
except RuntimeError as e:
    if "not installed" in str(e):
        # disable CodeBuddy path, fall back to another provider
        ...
    raise

Prevention

When it happens

Trigger: Configuring the CodeBuddy provider (or calling fetch_codebuddy_models / _run_codebuddy) without having installed the optional dependency; installing deeptutor without the [codebuddy] extra.

Common situations: Base `pip install deeptutor` or `deeptutor-cli` which omit optional extras; a fresh venv rebuilt from a partial requirements file; CI environments that prune extras.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/8b1560afd2c8faf3. Report an issue: GitHub.