{"record":{"id":"8b1560afd2c8faf3","repo":"HKUDS/DeepTutor","slug":"codebuddy-agent-sdk-is-not-installed-install-it-w","errorCode":null,"errorMessage":"codebuddy-agent-sdk is not installed. Install it with `python -m pip install codebuddy-agent-sdk` or `pip install -e .[codebuddy]`.","messagePattern":"codebuddy-agent-sdk is not installed\\. Install it with `python -m pip install codebuddy-agent-sdk` or `pip install -e \\.\\[codebuddy\\]`\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/llm/provider_core/codebuddy_provider.py","lineNumber":374,"sourceCode":"        for session in sessions:\n            try:\n                await session.close()\n            except asyncio.CancelledError:\n                task = asyncio.current_task()\n                if task is not None:\n                    task.uncancel()\n            except Exception:\n                pass\n\n    def get_default_model(self) -> str:\n        return self.default_model\n\n\ndef _load_sdk() -> ModuleType:\n    try:\n        import codebuddy_agent_sdk\n    except ImportError as exc:  # pragma: no cover - optional dependency\n        raise RuntimeError(\n            \"codebuddy-agent-sdk is not installed. Install it with \"\n            \"`python -m pip install codebuddy-agent-sdk` or `pip install -e .[codebuddy]`.\"\n        ) from exc\n    if not hasattr(codebuddy_agent_sdk, \"query\"):\n        raise RuntimeError(\"Installed codebuddy-agent-sdk does not expose query().\")\n    return codebuddy_agent_sdk\n\n\ndef _strip_model_prefix(model: str | None) -> str | None:\n    if not model:\n        return None\n    if \"/\" not in model:\n        return model\n    prefix, value = model.split(\"/\", 1)\n    if prefix.lower().replace(\"-\", \"_\") in {\"codebuddy\", \"codebuddy_code\", \"workbuddy\"}:\n        return value\n    return model\n","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/provider_core/codebuddy_provider.py#L356-L392","documentation":"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.","triggerScenarios":"Configuring the CodeBuddy provider (or calling fetch_codebuddy_models / _run_codebuddy) without having installed the optional dependency; installing deeptutor without the [codebuddy] extra.","commonSituations":"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.","solutions":["pip install codebuddy-agent-sdk (or pip install -e .[codebuddy] from source).","If it should already be installed, check you're in the right virtualenv / interpreter (python -m pip install ...).","Prevent instantiation of CodeBuddyProvider when the SDK is absent (guard on importlib.util.find_spec)."],"exampleFix":"# before\nprovider = CodeBuddyProvider(...)\n\n# after\nimport importlib.util\nif importlib.util.find_spec(\"codebuddy_agent_sdk\") is None:\n    raise SystemExit(\"Install extra: pip install 'deeptutor[codebuddy]'\")\nprovider = CodeBuddyProvider(...)","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"codebuddy_agent_sdk\") is None:\n    print(\"Run: pip install 'deeptutor[codebuddy]'\")  # skip/disable CodeBuddy features","typeGuard":"def codebuddy_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"codebuddy_agent_sdk\") is not None","tryCatchPattern":"try:\n    provider.run(...)\nexcept RuntimeError as e:\n    if \"not installed\" in str(e):\n        # disable CodeBuddy path, fall back to another provider\n        ...\n    raise","preventionTips":["Install extras explicitly in deployment: pip install 'deeptutor[codebuddy]'.","Gate CodeBuddy features behind codebuddy_available().","Pin extras in requirements/lockfile for Docker and CI."],"tags":["codebuddy","optional-dependency","import","install"],"backgroundTag":"missing-optional-dependency","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}